forked from LBRYCommunity/lbry-sdk
change column to has_source and document both flags
This commit is contained in:
parent
1e5cd3d7a1
commit
74df4fab83
4 changed files with 15 additions and 9 deletions
|
@ -2330,6 +2330,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
[--not_locations=<not_locations>...]
|
[--not_locations=<not_locations>...]
|
||||||
[--order_by=<order_by>...] [--no_totals] [--page=<page>] [--page_size=<page_size>]
|
[--order_by=<order_by>...] [--no_totals] [--page=<page>] [--page_size=<page_size>]
|
||||||
[--wallet_id=<wallet_id>] [--include_purchase_receipt] [--include_is_my_output]
|
[--wallet_id=<wallet_id>] [--include_purchase_receipt] [--include_is_my_output]
|
||||||
|
[--has_source | --has_no_source]
|
||||||
[--new_sdk_server=<new_sdk_server>]
|
[--new_sdk_server=<new_sdk_server>]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
@ -2438,6 +2439,8 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
has purchased the claim
|
has purchased the claim
|
||||||
--include_is_my_output : (bool) lookup and include a boolean indicating
|
--include_is_my_output : (bool) lookup and include a boolean indicating
|
||||||
if claim being resolved is yours
|
if claim being resolved is yours
|
||||||
|
--has_source : (bool) find claims containing a source field
|
||||||
|
--has_no_source : (bool) find claims not containing a source field
|
||||||
--new_sdk_server=<new_sdk_server> : (str) URL of the new SDK server (EXPERIMENTAL)
|
--new_sdk_server=<new_sdk_server> : (str) URL of the new SDK server (EXPERIMENTAL)
|
||||||
|
|
||||||
Returns: {Paginated[Output]}
|
Returns: {Paginated[Output]}
|
||||||
|
@ -2449,6 +2452,8 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
kwargs['signature_valid'] = 1
|
kwargs['signature_valid'] = 1
|
||||||
if kwargs.pop('invalid_channel_signature', False):
|
if kwargs.pop('invalid_channel_signature', False):
|
||||||
kwargs['signature_valid'] = 0
|
kwargs['signature_valid'] = 0
|
||||||
|
if 'has_no_source' in kwargs:
|
||||||
|
kwargs['has_source'] = not kwargs.pop('has_no_source')
|
||||||
page_num, page_size = abs(kwargs.pop('page', 1)), min(abs(kwargs.pop('page_size', DEFAULT_PAGE_SIZE)), 50)
|
page_num, page_size = abs(kwargs.pop('page', 1)), min(abs(kwargs.pop('page_size', DEFAULT_PAGE_SIZE)), 50)
|
||||||
kwargs.update({'offset': page_size * (page_num - 1), 'limit': page_size})
|
kwargs.update({'offset': page_size * (page_num - 1), 'limit': page_size})
|
||||||
txos, blocked, _, total = await self.ledger.claim_search(wallet.accounts, **kwargs)
|
txos, blocked, _, total = await self.ledger.claim_search(wallet.accounts, **kwargs)
|
||||||
|
|
|
@ -53,7 +53,7 @@ SEARCH_PARAMS = {
|
||||||
'any_locations', 'all_locations', 'not_locations',
|
'any_locations', 'all_locations', 'not_locations',
|
||||||
'any_languages', 'all_languages', 'not_languages',
|
'any_languages', 'all_languages', 'not_languages',
|
||||||
'is_controlling', 'limit', 'offset', 'order_by',
|
'is_controlling', 'limit', 'offset', 'order_by',
|
||||||
'no_totals', 'no_source'
|
'no_totals', 'has_source'
|
||||||
} | INTEGER_PARAMS
|
} | INTEGER_PARAMS
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ class SQLDB:
|
||||||
description text,
|
description text,
|
||||||
|
|
||||||
claim_type integer,
|
claim_type integer,
|
||||||
no_source bool,
|
has_source bool,
|
||||||
reposted integer default 0,
|
reposted integer default 0,
|
||||||
|
|
||||||
-- streams
|
-- streams
|
||||||
|
@ -355,7 +355,7 @@ class SQLDB:
|
||||||
'author': None,
|
'author': None,
|
||||||
'duration': None,
|
'duration': None,
|
||||||
'claim_type': None,
|
'claim_type': None,
|
||||||
'no_source': False,
|
'has_source': False,
|
||||||
'stream_type': None,
|
'stream_type': None,
|
||||||
'media_type': None,
|
'media_type': None,
|
||||||
'release_time': None,
|
'release_time': None,
|
||||||
|
@ -373,7 +373,7 @@ class SQLDB:
|
||||||
|
|
||||||
if claim.is_stream:
|
if claim.is_stream:
|
||||||
claim_record['claim_type'] = CLAIM_TYPES['stream']
|
claim_record['claim_type'] = CLAIM_TYPES['stream']
|
||||||
claim_record['no_source'] = not claim.stream.has_source
|
claim_record['has_source'] = claim.stream.has_source
|
||||||
claim_record['media_type'] = claim.stream.source.media_type
|
claim_record['media_type'] = claim.stream.source.media_type
|
||||||
claim_record['stream_type'] = STREAM_TYPES[guess_stream_type(claim_record['media_type'])]
|
claim_record['stream_type'] = STREAM_TYPES[guess_stream_type(claim_record['media_type'])]
|
||||||
claim_record['title'] = claim.stream.title
|
claim_record['title'] = claim.stream.title
|
||||||
|
@ -424,12 +424,12 @@ class SQLDB:
|
||||||
self.executemany("""
|
self.executemany("""
|
||||||
INSERT OR IGNORE INTO claim (
|
INSERT OR IGNORE INTO claim (
|
||||||
claim_hash, claim_id, claim_name, normalized, txo_hash, tx_position, amount,
|
claim_hash, claim_id, claim_name, normalized, txo_hash, tx_position, amount,
|
||||||
claim_type, media_type, stream_type, timestamp, creation_timestamp, no_source,
|
claim_type, media_type, stream_type, timestamp, creation_timestamp, has_source,
|
||||||
fee_currency, fee_amount, title, description, author, duration, height, reposted_claim_hash,
|
fee_currency, fee_amount, title, description, author, duration, height, reposted_claim_hash,
|
||||||
creation_height, release_time, activation_height, expiration_height, short_url)
|
creation_height, release_time, activation_height, expiration_height, short_url)
|
||||||
VALUES (
|
VALUES (
|
||||||
:claim_hash, :claim_id, :claim_name, :normalized, :txo_hash, :tx_position, :amount,
|
:claim_hash, :claim_id, :claim_name, :normalized, :txo_hash, :tx_position, :amount,
|
||||||
:claim_type, :media_type, :stream_type, :timestamp, :timestamp, :no_source,
|
:claim_type, :media_type, :stream_type, :timestamp, :timestamp, :has_source,
|
||||||
:fee_currency, :fee_amount, :title, :description, :author, :duration, :height, :reposted_claim_hash, :height,
|
:fee_currency, :fee_amount, :title, :description, :author, :duration, :height, :reposted_claim_hash, :height,
|
||||||
CASE WHEN :release_time IS NOT NULL THEN :release_time ELSE :timestamp END,
|
CASE WHEN :release_time IS NOT NULL THEN :release_time ELSE :timestamp END,
|
||||||
CASE WHEN :normalized NOT IN (SELECT normalized FROM claimtrie) THEN :height END,
|
CASE WHEN :normalized NOT IN (SELECT normalized FROM claimtrie) THEN :height END,
|
||||||
|
@ -447,7 +447,7 @@ class SQLDB:
|
||||||
UPDATE claim SET
|
UPDATE claim SET
|
||||||
txo_hash=:txo_hash, tx_position=:tx_position, amount=:amount, height=:height,
|
txo_hash=:txo_hash, tx_position=:tx_position, amount=:amount, height=:height,
|
||||||
claim_type=:claim_type, media_type=:media_type, stream_type=:stream_type,
|
claim_type=:claim_type, media_type=:media_type, stream_type=:stream_type,
|
||||||
timestamp=:timestamp, fee_amount=:fee_amount, fee_currency=:fee_currency, no_source=:no_source,
|
timestamp=:timestamp, fee_amount=:fee_amount, fee_currency=:fee_currency, has_source=:has_source,
|
||||||
title=:title, duration=:duration, description=:description, author=:author, reposted_claim_hash=:reposted_claim_hash,
|
title=:title, duration=:duration, description=:description, author=:author, reposted_claim_hash=:reposted_claim_hash,
|
||||||
release_time=CASE WHEN :release_time IS NOT NULL THEN :release_time ELSE release_time END
|
release_time=CASE WHEN :release_time IS NOT NULL THEN :release_time ELSE release_time END
|
||||||
WHERE claim_hash=:claim_hash;
|
WHERE claim_hash=:claim_hash;
|
||||||
|
|
|
@ -162,8 +162,9 @@ class ClaimSearchCommand(ClaimTestCase):
|
||||||
# no source
|
# no source
|
||||||
no_source = await self.stream_create('no_source', data=None)
|
no_source = await self.stream_create('no_source', data=None)
|
||||||
normal = await self.stream_create('normal', data=b'normal')
|
normal = await self.stream_create('normal', data=b'normal')
|
||||||
await self.assertFindsClaims([no_source], no_source=True)
|
await self.assertFindsClaims([no_source], has_no_source=True)
|
||||||
await self.assertFindsClaims([normal], no_source=False)
|
await self.assertFindsClaims([normal], has_source=True)
|
||||||
|
await self.assertFindsClaims([normal, no_source])
|
||||||
|
|
||||||
async def test_pagination(self):
|
async def test_pagination(self):
|
||||||
await self.create_channel()
|
await self.create_channel()
|
||||||
|
|
Loading…
Reference in a new issue