fixed small pagination issue in execute_pagination/added availability field in mongo schema

This commit is contained in:
TPV committed 2026-07-14 12:02:07 -07:00
1 parent ae8b204a2c
commit f2e50819ac
3 files changed
+14 -5

No files matched your search

+10 -5
View File
@@ -84,7 +84,9 @@ async def init_monitor(
async def setup_config(
monitor_name: str, development_mode: DevelopmentMode
) -> tuple[list[str] | dict[str, str], dict[str, str | list[str]], AsyncIOMotorCollection]:
) -> tuple[
list[str] | dict[str, str], dict[str, str | list[str]], AsyncIOMotorCollection
]:
"""Load monitor config and resolve the Mongo collection for the mode.
Testing mode reads the configs_testing collection and appends a _testing
@@ -275,14 +277,15 @@ async def execute_pagination(
session: aiohttp.ClientSession | AsyncSession,
*,
max_concurrent_tasks: int = 5,
start_offset: int = 24,
start_offset: int = 0,
pagination_mode: str = "offset",
**kwargs,
):
"""Paginate a category by dispatching concurrent page or offset tasks to func.
Runs pages 2..N under a semaphore, retries failed pages with exponential
backoff, and logs any pages that still fail after retries.
backoff, and logs any pages that still fail after retries. Page 1 is
assumed to have been fetched by the caller.
Args:
category_identifier: Label used for logging only; not passed to func.
@@ -292,7 +295,9 @@ async def execute_pagination(
offset or page_number depending on pagination_mode.
session: HTTP session forwarded to each func call.
max_concurrent_tasks: Semaphore limit for concurrent page fetches.
start_offset: Base offset added when pagination_mode is offset.
start_offset: Additive base applied to every offset, for APIs whose
offset space does not begin at zero. Page N requests offset
start_offset + (N - 1) * products_per_page.
pagination_mode: Either offset or page, selecting the kwarg sent to func.
**kwargs: Forwarded verbatim to every func call. Any identifier func
needs (category_id, category_name, category_path, or bestbuy's
@@ -317,7 +322,7 @@ async def execute_pagination(
return
if pagination_mode == "offset":
current_offset = start_offset + page_index * products_per_page
current_offset = start_offset + (page_index - 1) * products_per_page
await func(
session=session,
offset=current_offset,