diff --git a/schemas.py b/schemas.py index 7ab5322..94bbbd8 100644 --- a/schemas.py +++ b/schemas.py @@ -6,7 +6,10 @@ from datetime import datetime class ScrapeRequest(BaseModel): username: str seller_id: UUID + # existing field max_count: int = Field(default=5, ge=1, le=50) + # NEW: accept "count" from older/other callers; ignored if not present + count: Optional[int] = Field(default=None, ge=1, le=50) class ScrapedPost(BaseModel): ig_post_id: str diff --git a/scraper.py b/scraper.py index 9a8b42a..3da0d3b 100644 --- a/scraper.py +++ b/scraper.py @@ -116,7 +116,11 @@ def _collect_raw_not_in_db( return raw_to_save, final_cursor, pages def scrape_and_store(db: Session, req: ScrapeRequest) -> List[ScrapedPost]: - target = int(req.max_count) + # Prefer "count" if provided by the caller, otherwise fall back to "max_count" + target = int((req.count if getattr(req, "count", None) is not None else req.max_count)) + + # Optional debug line + print(f"[SCRAPER] requested count={getattr(req, 'count', None)} max_count={req.max_count} → resolved target={target}") # since_taken_at (optional) since_ts: Optional[int] = None