From 90e7821283b26c90d4a4d573579c3b91406af57c Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 5 Nov 2020 19:02:50 -0300 Subject: [PATCH] filter whole channels --- lbry/db/queries/search.py | 7 +++++-- tests/integration/blockchain/test_blockchain.py | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lbry/db/queries/search.py b/lbry/db/queries/search.py index 0401baffb..e9b84d1a9 100644 --- a/lbry/db/queries/search.py +++ b/lbry/db/queries/search.py @@ -103,7 +103,7 @@ def search_support_count(**constraints) -> int: channel_claim = Claim.alias('channel') -BASE_SELECT_CLAIM_COLUMNS = BASE_SELECT_TXO_COLUMNS + [ +BASE_SELECT_CLAIM_COLUMNS = [Claim.c.claim_hash.distinct()] + BASE_SELECT_TXO_COLUMNS + [ Claim.c.activation_height, Claim.c.takeover_height, Claim.c.creation_height, @@ -278,7 +278,10 @@ def select_claims(cols: List = None, for_count=False, **constraints) -> Select: .select_from( Claim.join(TXO).join(TX).join(Trending, Trending.c.claim_hash == Claim.c.claim_hash, isouter=True) .join(channel_claim, Claim.c.channel_hash == channel_claim.c.claim_hash, isouter=True) - .join(ClaimFilter, (ClaimFilter.c.claim_hash == Claim.c.claim_hash) | (ClaimFilter.c.claim_hash == Claim.c.reposted_claim_hash), isouter=True) + .join(ClaimFilter, + (ClaimFilter.c.claim_hash == Claim.c.claim_hash) | + (ClaimFilter.c.claim_hash == Claim.c.reposted_claim_hash) | + (ClaimFilter.c.claim_hash == Claim.c.channel_hash), isouter=True) ), **constraints ) diff --git a/tests/integration/blockchain/test_blockchain.py b/tests/integration/blockchain/test_blockchain.py index 09b159a6d..065bc0771 100644 --- a/tests/integration/blockchain/test_blockchain.py +++ b/tests/integration/blockchain/test_blockchain.py @@ -1400,6 +1400,11 @@ class TestClaimtrieSync(SyncingBlockchainTestCase): results = await self.db.search_claims(channel="@some_channel") self.assertEqual(len(results.rows), 1) self.assertEqual(results.censor.censored.get(moderator_chan.claim_hash), 2) + await self.create_claim(sign=moderator_chan, name="blocking_bad", repost=user_chan.claim_id) + await self.generate(1) + results = await self.db.search_claims(channel="@some_channel") + self.assertEqual(len(results.rows), 0) + self.assertEqual(results.censor.censored.get(moderator_chan.claim_hash), 3) # good, bad and repost @skip