From b153e4bb9fa673727a72bb2adebc957bea239f4b Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Tue, 16 Feb 2021 10:27:47 -0500 Subject: [PATCH] added support to claim_search for filtering collections via --claim_type --- lbry/extras/daemon/daemon.py | 2 +- lbry/wallet/server/db/common.py | 5 +++-- lbry/wallet/server/db/writer.py | 2 ++ tests/integration/blockchain/test_claim_commands.py | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index 52876baf7..28a349e3f 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -2451,7 +2451,7 @@ class Daemon(metaclass=JSONRPCServerType): --reposted_claim_id=: (str) all reposts of the specified original claim id --reposted= : (int) claims reposted this many times (supports equality constraints) - --claim_type= : (str) filter by 'channel', 'stream' or 'unknown' + --claim_type= : (str) filter by 'channel', 'stream', 'repost' or 'collection' --stream_types= : (list) filter by 'video', 'image', 'document', etc --media_types= : (list) filter by 'video/mp4', 'image/png', etc --fee_currency= : (string) specify fee currency: LBC, BTC, USD diff --git a/lbry/wallet/server/db/common.py b/lbry/wallet/server/db/common.py index a1cf53fa8..c0fdc4f3f 100644 --- a/lbry/wallet/server/db/common.py +++ b/lbry/wallet/server/db/common.py @@ -1,7 +1,8 @@ CLAIM_TYPES = { 'stream': 1, 'channel': 2, - 'repost': 3 + 'repost': 3, + 'collection': 4, } STREAM_TYPES = { @@ -10,7 +11,7 @@ STREAM_TYPES = { 'image': 3, 'document': 4, 'binary': 5, - 'model': 6 + 'model': 6, } # 9/21/2020 diff --git a/lbry/wallet/server/db/writer.py b/lbry/wallet/server/db/writer.py index 9ca72e746..792a38bab 100644 --- a/lbry/wallet/server/db/writer.py +++ b/lbry/wallet/server/db/writer.py @@ -393,6 +393,8 @@ class SQLDB: claim_record['reposted_claim_hash'] = claim.repost.reference.claim_hash elif claim.is_channel: claim_record['claim_type'] = CLAIM_TYPES['channel'] + elif claim.is_collection: + claim_record['claim_type'] = CLAIM_TYPES['collection'] languages[(language, claim_hash)] = (language, claim_hash, tx.height) diff --git a/tests/integration/blockchain/test_claim_commands.py b/tests/integration/blockchain/test_claim_commands.py index 1c08beb0d..ce9859de6 100644 --- a/tests/integration/blockchain/test_claim_commands.py +++ b/tests/integration/blockchain/test_claim_commands.py @@ -365,6 +365,7 @@ class ClaimSearchCommand(ClaimTestCase): video = await self.stream_create('chrome', file_path=self.video_file_name) image = await self.stream_create('blank-image', data=self.image_data, suffix='.png') repost = await self.stream_repost(self.get_claim_id(image)) + collection = await self.collection_create('a-collection', claims=[self.get_claim_id(video)]) channel = await self.channel_create() unknown = self.sout(tx) @@ -372,6 +373,7 @@ class ClaimSearchCommand(ClaimTestCase): await self.assertFindsClaims([image, video, octet, unknown], claim_type='stream') await self.assertFindsClaims([channel], claim_type='channel') await self.assertFindsClaims([repost], claim_type='repost') + await self.assertFindsClaims([collection], claim_type='collection') # stream_type await self.assertFindsClaims([octet, unknown], stream_types=['binary'])