reflect fee_currency, fee_amount and duration on repost searches

This commit is contained in:
Victor Shyba 2021-08-04 17:57:45 -03:00 committed by Victor Shyba
parent a56d14086b
commit 152dbfd5d1
2 changed files with 24 additions and 15 deletions

View file

@ -822,6 +822,9 @@ class SQLDB:
(select cr.claim_type from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_claim_type,
(select cr.stream_type from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_stream_type,
(select cr.media_type from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_media_type,
(select cr.duration from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_duration,
(select cr.fee_amount from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_fee_amount,
(select cr.fee_currency from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_fee_currency,
claim.*
FROM claim LEFT JOIN claimtrie USING (claim_hash)
WHERE claim.claim_hash in (SELECT claim_hash FROM changelog)
@ -834,6 +837,9 @@ class SQLDB:
claim['has_source'] = bool(claim.pop('reposted_has_source') or claim['has_source'])
claim['stream_type'] = claim.pop('reposted_stream_type') or claim['stream_type']
claim['media_type'] = claim.pop('reposted_media_type') or claim['media_type']
claim['fee_amount'] = claim.pop('reposted_fee_amount') or claim['fee_amount']
claim['fee_currency'] = claim.pop('reposted_fee_currency') or claim['fee_currency']
claim['duration'] = claim.pop('reposted_duration') or claim['duration']
for reason_id in id_set:
if reason_id in self.blocked_streams:
claim['censor_type'] = 2

View file

@ -304,13 +304,15 @@ class ClaimSearchCommand(ClaimTestCase):
claim3 = await self.stream_create('claim3', fee_amount='0.5', fee_currency='lbc')
claim4 = await self.stream_create('claim4', fee_amount='0.1', fee_currency='lbc')
claim5 = await self.stream_create('claim5', fee_amount='1.0', fee_currency='usd')
repost1 = await self.stream_repost(self.get_claim_id(claim1), 'repost1')
repost5 = await self.stream_repost(self.get_claim_id(claim5), 'repost5')
await self.assertFindsClaims([claim5, claim4, claim3, claim2, claim1], fee_amount='>0')
await self.assertFindsClaims([claim4, claim3, claim2, claim1], fee_currency='lbc')
await self.assertFindsClaims([claim3, claim2, claim1], fee_amount='>0.1', fee_currency='lbc')
await self.assertFindsClaims([repost5, repost1, claim5, claim4, claim3, claim2, claim1], fee_amount='>0')
await self.assertFindsClaims([repost1, claim4, claim3, claim2, claim1], fee_currency='lbc')
await self.assertFindsClaims([repost1, claim3, claim2, claim1], fee_amount='>0.1', fee_currency='lbc')
await self.assertFindsClaims([claim4, claim3, claim2], fee_amount='<1.0', fee_currency='lbc')
await self.assertFindsClaims([claim3], fee_amount='0.5', fee_currency='lbc')
await self.assertFindsClaims([claim5], fee_currency='usd')
await self.assertFindsClaims([repost5, claim5], fee_currency='usd')
async def test_search_by_language(self):
claim1 = await self.stream_create('claim1', fee_amount='1.0', fee_currency='lbc')
@ -476,7 +478,8 @@ class ClaimSearchCommand(ClaimTestCase):
octet = await self.stream_create()
video = await self.stream_create('chrome', file_path=self.video_file_name)
image = await self.stream_create('blank-image', data=self.image_data, suffix='.png')
repost = await self.stream_repost(self.get_claim_id(image))
image_repost = await self.stream_repost(self.get_claim_id(image), 'image-repost')
video_repost = await self.stream_repost(self.get_claim_id(video), 'video-repost')
collection = await self.collection_create('a-collection', claims=[self.get_claim_id(video)])
channel = await self.channel_create()
unknown = self.sout(tx)
@ -484,25 +487,25 @@ class ClaimSearchCommand(ClaimTestCase):
# claim_type
await self.assertFindsClaims([image, video, octet, unknown], claim_type='stream')
await self.assertFindsClaims([channel], claim_type='channel')
await self.assertFindsClaims([repost], claim_type='repost')
await self.assertFindsClaims([video_repost, image_repost], claim_type='repost')
await self.assertFindsClaims([collection], claim_type='collection')
# stream_type
await self.assertFindsClaims([octet, unknown], stream_types=['binary'])
await self.assertFindsClaims([video], stream_types=['video'])
await self.assertFindsClaims([repost, image], stream_types=['image'])
await self.assertFindsClaims([repost, image, video], stream_types=['video', 'image'])
await self.assertFindsClaims([video_repost, video], stream_types=['video'])
await self.assertFindsClaims([image_repost, image], stream_types=['image'])
await self.assertFindsClaims([video_repost, image_repost, image, video], stream_types=['video', 'image'])
# media_type
await self.assertFindsClaims([octet, unknown], media_types=['application/octet-stream'])
await self.assertFindsClaims([video], media_types=['video/mp4'])
await self.assertFindsClaims([repost, image], media_types=['image/png'])
await self.assertFindsClaims([repost, image, video], media_types=['video/mp4', 'image/png'])
await self.assertFindsClaims([video_repost, video], media_types=['video/mp4'])
await self.assertFindsClaims([image_repost, image], media_types=['image/png'])
await self.assertFindsClaims([video_repost, image_repost, image, video], media_types=['video/mp4', 'image/png'])
# duration
await self.assertFindsClaim(video, duration='>14')
await self.assertFindsClaim(video, duration='<16')
await self.assertFindsClaim(video, duration=15)
await self.assertFindsClaims([video_repost, video], duration='>14')
await self.assertFindsClaims([video_repost, video], duration='<16')
await self.assertFindsClaims([video_repost, video], duration=15)
await self.assertFindsClaims([], duration='>100')
await self.assertFindsClaims([], duration='<14')