forked from LBRYCommunity/lbry-sdk
add a test for normal repost mixed with blocking repost, use inner queries
This commit is contained in:
parent
04a823c7d0
commit
745bc24343
2 changed files with 12 additions and 6 deletions
|
@ -263,13 +263,17 @@ def _get_claims(cols, for_count=False, **constraints) -> Tuple[str, Dict]:
|
|||
if 'blocklist_channel_ids' in constraints:
|
||||
blocklist_ids = constraints.pop('blocklist_channel_ids')
|
||||
if blocklist_ids:
|
||||
not_repost_from_channel_ids = [
|
||||
blocking_channels = [
|
||||
sqlite3.Binary(unhexlify(channel_id)[::-1]) for channel_id in blocklist_ids
|
||||
]
|
||||
constraints['null_or_not_reposted_by__or'] = {
|
||||
'repost.channel_hash__not_in': not_repost_from_channel_ids,
|
||||
'repost.channel_hash__is_null': True
|
||||
}
|
||||
constraints.update({
|
||||
f'$blocking_channels{i}': a for i, a in enumerate(blocking_channels)
|
||||
})
|
||||
blocklist = ', '.join([f':$blocking_channels{i}' for i in range(len(blocking_channels))])
|
||||
constraints['claim.claim_hash__not_in'] = f"""
|
||||
SELECT reposted_claim_hash FROM claim
|
||||
WHERE channel_hash IN ({blocklist})
|
||||
"""
|
||||
if 'signature_valid' in constraints:
|
||||
has_channel_signature = constraints.pop('has_channel_signature', False)
|
||||
if has_channel_signature:
|
||||
|
@ -314,7 +318,7 @@ def _get_claims(cols, for_count=False, **constraints) -> Tuple[str, Dict]:
|
|||
constraints["order_by"] = FTS_ORDER_BY
|
||||
select = f"SELECT {cols} FROM search JOIN claim ON (search.rowid=claim.rowid)"
|
||||
else:
|
||||
select = f"SELECT {cols} FROM claim LEFT JOIN claim as repost ON (claim.claim_hash=repost.reposted_claim_hash)"
|
||||
select = f"SELECT {cols} FROM claim"
|
||||
|
||||
sql, values = query(
|
||||
select if for_count else select+"""
|
||||
|
|
|
@ -761,6 +761,8 @@ class StreamCommands(ClaimTestCase):
|
|||
await self.out(self.stream_create('not_bad', '1.1', channel_name='@badstuff'))
|
||||
tx = await self.out(self.stream_create('too_bad', '1.1', channel_name='@badstuff'))
|
||||
claim_id = tx['outputs'][0]['claim_id']
|
||||
await self.out(self.channel_create('@reposts', '1.0'))
|
||||
await self.stream_repost(claim_id, 'normal_repost', '1.2', channel_name='@reposts')
|
||||
filtering1 = await self.out(self.channel_create('@filtering1', '1.0'))
|
||||
filtering1 = filtering1['outputs'][0]['claim_id']
|
||||
await self.stream_repost(claim_id, 'filter1', '1.1', channel_name='@filtering1')
|
||||
|
|
Loading…
Reference in a new issue