add no_source claim_search filter
This commit is contained in:
parent
74660704e3
commit
a54e9b64aa
3 changed files with 14 additions and 4 deletions
|
@ -53,7 +53,7 @@ SEARCH_PARAMS = {
|
|||
'any_locations', 'all_locations', 'not_locations',
|
||||
'any_languages', 'all_languages', 'not_languages',
|
||||
'is_controlling', 'limit', 'offset', 'order_by',
|
||||
'no_totals',
|
||||
'no_totals', 'no_source'
|
||||
} | INTEGER_PARAMS
|
||||
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ class SQLDB:
|
|||
description text,
|
||||
|
||||
claim_type integer,
|
||||
no_source bool,
|
||||
reposted integer default 0,
|
||||
|
||||
-- streams
|
||||
|
@ -354,6 +355,7 @@ class SQLDB:
|
|||
'author': None,
|
||||
'duration': None,
|
||||
'claim_type': None,
|
||||
'no_source': False,
|
||||
'stream_type': None,
|
||||
'media_type': None,
|
||||
'release_time': None,
|
||||
|
@ -371,6 +373,7 @@ class SQLDB:
|
|||
|
||||
if claim.is_stream:
|
||||
claim_record['claim_type'] = CLAIM_TYPES['stream']
|
||||
claim_record['no_source'] = not claim.stream.has_source
|
||||
claim_record['media_type'] = claim.stream.source.media_type
|
||||
claim_record['stream_type'] = STREAM_TYPES[guess_stream_type(claim_record['media_type'])]
|
||||
claim_record['title'] = claim.stream.title
|
||||
|
@ -421,12 +424,12 @@ class SQLDB:
|
|||
self.executemany("""
|
||||
INSERT OR IGNORE INTO claim (
|
||||
claim_hash, claim_id, claim_name, normalized, txo_hash, tx_position, amount,
|
||||
claim_type, media_type, stream_type, timestamp, creation_timestamp,
|
||||
claim_type, media_type, stream_type, timestamp, creation_timestamp, no_source,
|
||||
fee_currency, fee_amount, title, description, author, duration, height, reposted_claim_hash,
|
||||
creation_height, release_time, activation_height, expiration_height, short_url)
|
||||
VALUES (
|
||||
:claim_hash, :claim_id, :claim_name, :normalized, :txo_hash, :tx_position, :amount,
|
||||
:claim_type, :media_type, :stream_type, :timestamp, :timestamp,
|
||||
:claim_type, :media_type, :stream_type, :timestamp, :timestamp, :no_source,
|
||||
: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 :normalized NOT IN (SELECT normalized FROM claimtrie) THEN :height END,
|
||||
|
@ -444,7 +447,7 @@ class SQLDB:
|
|||
UPDATE claim SET
|
||||
txo_hash=:txo_hash, tx_position=:tx_position, amount=:amount, height=:height,
|
||||
claim_type=:claim_type, media_type=:media_type, stream_type=:stream_type,
|
||||
timestamp=:timestamp, fee_amount=:fee_amount, fee_currency=:fee_currency,
|
||||
timestamp=:timestamp, fee_amount=:fee_amount, fee_currency=:fee_currency, no_source=:no_source
|
||||
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
|
||||
WHERE claim_hash=:claim_hash;
|
||||
|
|
|
@ -158,6 +158,13 @@ class ClaimSearchCommand(ClaimTestCase):
|
|||
await self.stream_abandon(txid=signed2['txid'], nout=0)
|
||||
await self.assertFindsClaims([], channel_ids=[channel_id2])
|
||||
|
||||
async def test_source_filter(self):
|
||||
# no source
|
||||
no_source = await self.stream_create('no_source', data=None)
|
||||
normal = await self.stream_create('normal', data=b'normal')
|
||||
await self.assertFindsClaims([no_source], no_source=True)
|
||||
await self.assertFindsClaims([normal], no_source=False)
|
||||
|
||||
async def test_pagination(self):
|
||||
await self.create_channel()
|
||||
await self.create_lots_of_streams()
|
||||
|
|
Loading…
Reference in a new issue