Fix regional flood area pagination
This commit is contained in:
@@ -131,13 +131,23 @@ def resolve_areas(
|
||||
project_id: str,
|
||||
members: Sequence[ScopeMember],
|
||||
) -> list[ResolvedArea]:
|
||||
areas = unwrap(
|
||||
session.get(
|
||||
f"{base_url}/api/v1/projects/{project_id}/areas",
|
||||
params={"limit": 500, "offset": 0},
|
||||
timeout=60,
|
||||
areas: list[dict[str, Any]] = []
|
||||
limit = 200
|
||||
offset = 0
|
||||
while True:
|
||||
page = unwrap(
|
||||
session.get(
|
||||
f"{base_url}/api/v1/projects/{project_id}/areas",
|
||||
params={"limit": limit, "offset": offset},
|
||||
timeout=60,
|
||||
)
|
||||
)
|
||||
)["items"]
|
||||
page_items = list(page["items"])
|
||||
areas.extend(page_items)
|
||||
total = int(page.get("total", len(areas)))
|
||||
if len(areas) >= total or len(page_items) < limit:
|
||||
break
|
||||
offset += limit
|
||||
resolved: list[ResolvedArea] = []
|
||||
missing: list[str] = []
|
||||
for member in members:
|
||||
|
||||
Reference in New Issue
Block a user