(task: Dict[str, Any])
| 322 | |
| 323 | |
| 324 | def _preview_payload(task: Dict[str, Any]) -> Optional[Dict[str, Any]]: |
| 325 | items = list(task.get("preview_items") or []) |
| 326 | if not items: |
| 327 | return None |
| 328 | return { |
| 329 | "push_id": task.get("task_id"), |
| 330 | "push_time": task.get("started_at") or task.get("created_at"), |
| 331 | "papers": [_paper_card(paper, index) for index, paper in enumerate(items, start=1)], |
| 332 | "metadata": { |
| 333 | "preview": True, |
| 334 | "phase": task.get("progress_phase") or task.get("status"), |
| 335 | "fetched_count": int(task.get("fetched_count") or 0), |
| 336 | "ranked_count": int(task.get("ranked_count") or 0), |
| 337 | "total_fetched": int(task.get("fetched_count") or len(items)), |
| 338 | }, |
| 339 | } |
| 340 | |
| 341 | |
| 342 | def _profile_summary(profile: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: |
no test coverage detected