Skip to content

Commit 11bdf56

Browse files
patch project query, allow for pagination in query_projects
1 parent a2b2fc0 commit 11bdf56

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

mp_api/client/contribs/client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ def search_future(search_term):
797797
ret = self.projects.queryProjects(**query).result() # first page
798798
total_count, total_pages = ret["total_count"], ret["total_pages"]
799799

800-
if total_pages < 2:
800+
if total_pages < 2 or ("page" in query):
801801
return (
802802
_convert_to_model( # type: ignore[return-value]
803803
ret["data"],
@@ -828,7 +828,12 @@ def search_future(search_term):
828828
]
829829
responses = _run_futures(futures, total=total_count, timeout=timeout)
830830

831-
ret["data"].extend([resp["result"]["data"] for resp in responses.values()])
831+
# NOTE: resp["result"]["data"] is a dict where each key is an int,
832+
# and each value is a **list** of projects as dict
833+
# Double iteration is necessary because of this nested structure
834+
ret["data"].extend(
835+
[entry for resp in responses.values() for entry in resp["result"]["data"]]
836+
)
832837

833838
return (
834839
_convert_to_model( # type: ignore[return-value]

0 commit comments

Comments
 (0)