filter whole channels

This commit is contained in:
Victor Shyba 2020-11-05 19:02:50 -03:00 committed by Lex Berezhny
parent a5eccb9a92
commit 90e7821283
2 changed files with 10 additions and 2 deletions

View file

@ -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
)

View file

@ -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