(
*,
user_id: str,
push_id: str,
selected_numbers: Iterable[Any],
skipped_numbers: Iterable[Any],
later_numbers: Iterable[Any] = (),
)
| 2310 | days: int = 1, |
| 2311 | limit_per_source: Optional[int] = None, |
| 2312 | arxiv_categories: Optional[Iterable[Any]] = None, |
| 2313 | conferences: Optional[Iterable[Any]] = None, |
| 2314 | journals: Optional[Iterable[Any]] = None, |
| 2315 | target_date: Optional[str] = None, |
| 2316 | force_refresh: bool = False, |
| 2317 | ) -> Dict[str, Any]: |
| 2318 | cleaned_user_id = str(user_id or "").strip() |
| 2319 | if not cleaned_user_id: |
| 2320 | raise ValueError("user_id is required") |
| 2321 | normalized_target_date = _normalize_push_date(target_date) |
| 2322 | requested_days = max(1, int(days or 1)) |
| 2323 | requested_limit = _configured_daily_limit(limit_per_source) |
| 2324 | requested_sources = _configured_daily_sources( |
| 2325 | arxiv_categories=arxiv_categories, |
| 2326 | conferences=conferences, |
| 2327 | journals=journals, |
| 2328 | ) |
| 2329 | |
| 2330 | if not force_refresh: |
| 2331 | cached_push = _push_payload(db_ops.get_push_for_date(cleaned_user_id, normalized_target_date)) |
| 2332 | if cached_push is not None and _daily_cache_matches_settings( |
| 2333 | cached_push, |
| 2334 | days=requested_days, |
| 2335 | limit_per_source=requested_limit, |
| 2336 | target_date=normalized_target_date, |
| 2337 | sources=requested_sources, |
| 2338 | ): |
| 2339 | metadata = dict(cached_push.get("metadata") or {}) |
| 2340 | metadata["cached"] = True |
| 2341 | metadata["cached_for_date"] = normalized_target_date |
| 2342 | cached_push["metadata"] = metadata |
| 2343 | now = _task_timestamp() |
| 2344 | cached_task = { |
| 2345 | "task_id": f"cached_{normalized_target_date}_{cleaned_user_id}", |
| 2346 | "kind": "daily_push", |
| 2347 | "user_id": cleaned_user_id, |
| 2348 | "status": "completed", |
| 2349 | "days": requested_days, |
| 2350 | "limit_per_source": requested_limit, |
| 2351 | "arxiv_categories": cached_push.get("metadata", {}).get("arxiv_categories"), |
| 2352 | "conferences": cached_push.get("metadata", {}).get("conferences"), |
| 2353 | "journals": cached_push.get("metadata", {}).get("journals"), |
| 2354 | "target_date": normalized_target_date, |
| 2355 | "cached": True, |
| 2356 | "created_at": now, |
| 2357 | "updated_at": now, |
| 2358 | "started_at": now, |
| 2359 | "completed_at": now, |
| 2360 | "error": None, |
| 2361 | "result": { |
| 2362 | "success": True, |
| 2363 | "push_id": cached_push.get("push_id"), |
| 2364 | "cached": True, |
| 2365 | "target_date": normalized_target_date, |
| 2366 | }, |
| 2367 | "push": cached_push, |
| 2368 | "preview_items": [], |
| 2369 | "preview_mode": "cached", |
no test coverage detected