(task_id: str)
| 2102 | items[index].update(item) |
| 2103 | else: |
| 2104 | by_key[key] = len(items) |
| 2105 | items.append(item) |
| 2106 | |
| 2107 | task["fetched_count"] = max(int(task.get("fetched_count") or 0), len(items)) |
| 2108 | if phase == "ranked": |
| 2109 | task["ranked_count"] = int(task.get("ranked_count") or 0) + 1 |
| 2110 | |
| 2111 | return callback |
| 2112 | |
| 2113 | |
| 2114 | def _finish_daily_task(task_id: str) -> None: |
| 2115 | with _DAILY_TASK_LOCK: |
| 2116 | task = _DAILY_TASKS.get(task_id) |
| 2117 | if not task: |
| 2118 | return |
| 2119 | task["status"] = "running" |
| 2120 | task["started_at"] = _task_timestamp() |
| 2121 | task["updated_at"] = task["started_at"] |
| 2122 | user_id = str(task["user_id"]) |
| 2123 | days = int(task.get("days") or 1) |
| 2124 | limit_per_source = _configured_daily_limit(task.get("limit_per_source")) |
| 2125 | arxiv_categories = task.get("arxiv_categories") |
| 2126 | conferences = task.get("conferences") |
| 2127 | journals = task.get("journals") |
| 2128 | target_date = task.get("target_date") |
| 2129 | |
| 2130 | try: |
| 2131 | result = run_daily_push( |
| 2132 | user_id, |
| 2133 | days=days, |
| 2134 | limit_per_source=limit_per_source, |
| 2135 | arxiv_categories=arxiv_categories, |
| 2136 | conferences=conferences, |
| 2137 | journals=journals, |
| 2138 | target_date=target_date, |
| 2139 | progress_callback=_make_daily_progress_callback(task_id), |
| 2140 | ) |
| 2141 | except Exception as exc: # pragma: no cover - exercised through GUI/server boundary |
| 2142 | with _DAILY_TASK_LOCK: |
| 2143 | task = _DAILY_TASKS.get(task_id) |
| 2144 | if task: |
| 2145 | task["status"] = "failed" |
| 2146 | task["error"] = str(exc) |
| 2147 | task["completed_at"] = _task_timestamp() |
| 2148 | task["updated_at"] = task["completed_at"] |
| 2149 | return |
| 2150 | |
| 2151 | with _DAILY_TASK_LOCK: |
nothing calls this directly
no test coverage detected