Skip to content

Commit

Permalink
simplify pagination fetching logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Samweli committed Dec 9, 2021
1 parent 8a5446e commit ff5d445
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/qgis_stac/api/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,15 @@ def run(self):
pages = 1
items = 0
self.pagination = ResourcePagination()
for i, page in enumerate(response.get_item_collections()):
pages = pages + i
items += len(page.items)
self.pagination.total_pages = pages
self.pagination.total_items = items

for i, collection in enumerate(response.get_item_collections()):
pages = pages + i
items += len(collection.items)
if self.search_params.page == (i + 1):
self.response = collection
break

self.pagination.total_pages = pages
self.pagination.total_items = items

elif self.resource_type == \
ResourceType.COLLECTION:
Expand Down

0 comments on commit ff5d445

Please sign in to comment.