forked from LBRYCommunity/lbry-sdk
fix interaction between two modes
This commit is contained in:
parent
4870974161
commit
3974df4a62
2 changed files with 6 additions and 2 deletions
|
@ -287,7 +287,7 @@ class SearchIndex:
|
|||
result = list(await self.get_many(*(claim_id for claim_id, _ in reordered_hits[offset:(offset + page_size)])))
|
||||
return result, 0, len(reordered_hits)
|
||||
|
||||
def __remove_duplicates(self, search_hits: list):
|
||||
def __remove_duplicates(self, search_hits: deque) -> deque:
|
||||
known_ids = {} # claim_id -> (creation_height, hit_id), where hit_id is either reposted claim id or original
|
||||
dropped = set()
|
||||
for hit in search_hits:
|
||||
|
@ -301,7 +301,7 @@ class SearchIndex:
|
|||
dropped.add(previous_id)
|
||||
else:
|
||||
dropped.add(hit['_id'])
|
||||
return [hit for hit in search_hits if hit['_id'] not in dropped]
|
||||
return deque(hit for hit in search_hits if hit['_id'] not in dropped)
|
||||
|
||||
def __search_ahead(self, search_hits: list, page_size: int, per_channel_per_page: int):
|
||||
reordered_hits = []
|
||||
|
|
|
@ -419,6 +419,10 @@ class ClaimSearchCommand(ClaimTestCase):
|
|||
await match([channels[0], claims[0], channels[1], claims[1]] + channels[2:],
|
||||
height='>218',
|
||||
remove_duplicates=True, order_by=['^height'])
|
||||
# limit claims per channel, invert order, oldest ones are still chosen
|
||||
await match(channels[2:][::-1] + [claims[1], channels[1], claims[0], channels[0]],
|
||||
height='>218', limit_claims_per_channel=1,
|
||||
remove_duplicates=True, order_by=['height'])
|
||||
|
||||
async def test_limit_claims_per_channel_across_sorted_pages(self):
|
||||
await self.generate(10)
|
||||
|
|
Loading…
Reference in a new issue