Skip to content

Commit

Permalink
Further improve pagination on Gitea & Pagure
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Oct 21, 2023
1 parent c55bf44 commit dc1a608
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions services/gitea.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def _get_paginated2(
entries: list[dict] = []

def get_page(page: int) -> list[dict]:
params["page"] = str(page)
try:
params["page"] = str(page)
got = self.session.get(url, params=params)
got.raise_for_status()
return got.json()
Expand All @@ -74,7 +74,7 @@ def get_page(page: int) -> list[dict]:
)
return []

with ThreadPoolExecutor(max_workers=10) as executor:
with ThreadPoolExecutor(max_workers=min(10, last_page - 1)) as executor:
pages_to_fetch = range(2, last_page + 1)
results = executor.map(get_page, pages_to_fetch)
for result in results:
Expand Down
4 changes: 2 additions & 2 deletions services/pagure.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def _get_paginated2(
entries: list[dict] = []

def get_page(page: int) -> list[dict]:
params["page"] = str(page)
try:
params["page"] = str(page)
got = self.session.get(url, params=params)
got.raise_for_status()
data = got.json()
Expand All @@ -84,7 +84,7 @@ def get_page(page: int) -> list[dict]:
)
return []

with ThreadPoolExecutor(max_workers=10) as executor:
with ThreadPoolExecutor(max_workers=min(10, last_page - 1)) as executor:
pages_to_fetch = range(2, last_page + 1)
results = executor.map(get_page, pages_to_fetch)
for result in results:
Expand Down

0 comments on commit dc1a608

Please sign in to comment.