Properly check if pagination is present

This commit is contained in:
Mark Veidemanis 2023-03-11 22:07:56 +00:00
parent 6d6b370327
commit fa2a6c9c77
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 31 additions and 28 deletions

View File

@ -292,14 +292,15 @@ class LocalPlatformClient(ABC):
if "pagination" in ads: if "pagination" in ads:
if ads["pagination"]: if ads["pagination"]:
if "next" in ads["pagination"]: if "next" in ads["pagination"]:
page += 1 if ads["pagination"]["next"] is not None:
ads_iter = await self.enum_ad_ids(page) page += 1
if ads_iter is None: ads_iter = await self.enum_ad_ids(page)
return False if ads_iter is None:
if ads_iter is False: return False
return False if ads_iter is False:
for ad in ads_iter: return False
ads_total.append(ad) for ad in ads_iter:
ads_total.append(ad)
return ads_total return ads_total
async def enum_ads(self, requested_asset=None, page=0): async def enum_ads(self, requested_asset=None, page=0):
@ -321,14 +322,15 @@ class LocalPlatformClient(ABC):
if "pagination" in ads: if "pagination" in ads:
if ads["pagination"]: if ads["pagination"]:
if "next" in ads["pagination"]: if "next" in ads["pagination"]:
page += 1 if ads["pagination"]["next"] is not None:
ads_iter = await self.enum_ads(requested_asset, page) page += 1
if ads_iter is None: ads_iter = await self.enum_ads(requested_asset, page)
return False if ads_iter is None:
if ads_iter is False: return False
return False if ads_iter is False:
for ad in ads_iter: return False
ads_total.append([ad[0], ad[1], ad[2], ad[3], ad[4]]) for ad in ads_iter:
ads_total.append([ad[0], ad[1], ad[2], ad[3], ad[4]])
return ads_total return ads_total
def last_online_recent(self, date): def last_online_recent(self, date):
@ -413,18 +415,19 @@ class LocalPlatformClient(ABC):
if "pagination" in ads: if "pagination" in ads:
if ads["pagination"]: if ads["pagination"]:
if "next" in ads["pagination"]: if "next" in ads["pagination"]:
page += 1 if ads["pagination"]["next"] is not None:
ads_iter = await self.enum_public_ads( page += 1
asset, currency, provider, page ads_iter = await self.enum_public_ads(
) asset, currency, provider, page
if ads_iter is None: )
return False if ads_iter is None:
if ads_iter is False: return False
return False if ads_iter is False:
for ad in ads_iter: return False
to_append = [ad[0], ad[1], ad[2], ad[3], ad[4], ad[5]] for ad in ads_iter:
if to_append not in to_return: to_append = [ad[0], ad[1], ad[2], ad[3], ad[4], ad[5]]
to_return.append(to_append) if to_append not in to_return:
to_return.append(to_append)
return to_return return to_return
async def cheat(self, assets=None): async def cheat(self, assets=None):