From bbed9b94c179fcc2be3208d93ac10039d3f7794b Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 5 Nov 2020 21:23:49 -0500 Subject: [PATCH] null language filtering for claim search --- lbry/wallet/server/db/common.py | 1 + lbry/wallet/server/db/writer.py | 5 ++--- tests/integration/blockchain/test_claim_commands.py | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lbry/wallet/server/db/common.py b/lbry/wallet/server/db/common.py index 99655753b..a1cf53fa8 100644 --- a/lbry/wallet/server/db/common.py +++ b/lbry/wallet/server/db/common.py @@ -231,6 +231,7 @@ COMMON_TAGS = { } INDEXED_LANGUAGES = [ + 'none', 'en', 'aa', 'ab', diff --git a/lbry/wallet/server/db/writer.py b/lbry/wallet/server/db/writer.py index e83f9f7ac..9ca72e746 100644 --- a/lbry/wallet/server/db/writer.py +++ b/lbry/wallet/server/db/writer.py @@ -330,7 +330,7 @@ class SQLDB: #self.logger.exception(f"Could not decode claim name for {tx.id}:{txo.position}.") continue - language = None + language = 'none' try: if txo.claim.is_stream and txo.claim.stream.languages: language = txo.claim.stream.languages[0].language @@ -394,8 +394,7 @@ class SQLDB: elif claim.is_channel: claim_record['claim_type'] = CLAIM_TYPES['channel'] - if language: - languages[(language, claim_hash)] = (language, claim_hash, tx.height) + languages[(language, claim_hash)] = (language, claim_hash, tx.height) for tag in clean_tags(claim.message.tags): tags[(tag, claim_hash)] = (tag, claim_hash, tx.height) diff --git a/tests/integration/blockchain/test_claim_commands.py b/tests/integration/blockchain/test_claim_commands.py index 409264f93..a9c0591ec 100644 --- a/tests/integration/blockchain/test_claim_commands.py +++ b/tests/integration/blockchain/test_claim_commands.py @@ -271,6 +271,8 @@ class ClaimSearchCommand(ClaimTestCase): claim5 = await self.stream_create('claim5', fee_amount='1.0', fee_currency='usd', languages='es') await self.assertFindsClaims([claim4, claim3], any_languages=['en']) + await self.assertFindsClaims([claim2, claim1], any_languages=['none']) + await self.assertFindsClaims([claim4, claim3, claim2, claim1], any_languages=['none', 'en']) await self.assertFindsClaims([claim5], any_languages=['es']) await self.assertFindsClaims([claim5, claim4, claim3], any_languages=['en', 'es']) await self.assertFindsClaims([], fee_currency='foo')