MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / start_daily_push_task

Function start_daily_push_task

deployments/desktop/shared/agents.py:2151–2259  ·  view source on GitHub ↗
(
    user_id: str,
    days: int = 1,
    limit_per_source: Optional[int] = None,
    arxiv_categories: Optional[Iterable[Any]] = None,
    conferences: Optional[Iterable[Any]] = None,
    journals: Optional[Iterable[Any]] = None,
    target_date: Optional[str] = None,
    force_refresh: bool = False,
)

Source from the content-addressed store, hash-verified

2149 return
2150
2151 with _DAILY_TASK_LOCK:
2152 task = _DAILY_TASKS.get(task_id)
2153 if task:
2154 task["status"] = "completed"
2155 task["result"] = result.get("result")
2156 task["push"] = result.get("push")
2157 task["completed_at"] = _task_timestamp()
2158 task["updated_at"] = task["completed_at"]
2159
2160
2161def start_daily_push_task(
2162 user_id: str,
2163 days: int = 1,
2164 limit_per_source: Optional[int] = None,
2165 arxiv_categories: Optional[Iterable[Any]] = None,
2166 conferences: Optional[Iterable[Any]] = None,
2167 journals: Optional[Iterable[Any]] = None,
2168 target_date: Optional[str] = None,
2169 force_refresh: bool = False,
2170) -> Dict[str, Any]:
2171 cleaned_user_id = str(user_id or "").strip()
2172 if not cleaned_user_id:
2173 raise ValueError("user_id is required")
2174 normalized_target_date = _normalize_push_date(target_date)
2175 requested_days = max(1, int(days or 1))
2176 requested_limit = _configured_daily_limit(limit_per_source)
2177 requested_sources = _configured_daily_sources(
2178 arxiv_categories=arxiv_categories,
2179 conferences=conferences,
2180 journals=journals,
2181 )
2182
2183 if not force_refresh:
2184 cached_push = _push_payload(db_ops.get_push_for_date(cleaned_user_id, normalized_target_date))
2185 if cached_push is not None and _daily_cache_matches_settings(
2186 cached_push,
2187 days=requested_days,
2188 limit_per_source=requested_limit,
2189 target_date=normalized_target_date,
2190 sources=requested_sources,
2191 ):
2192 metadata = dict(cached_push.get("metadata") or {})
2193 metadata["cached"] = True
2194 metadata["cached_for_date"] = normalized_target_date
2195 cached_push["metadata"] = metadata
2196 now = _task_timestamp()
2197 cached_task = {
2198 "task_id": f"cached_{normalized_target_date}_{cleaned_user_id}",
2199 "kind": "daily_push",
2200 "user_id": cleaned_user_id,
2201 "status": "completed",
2202 "days": requested_days,
2203 "limit_per_source": requested_limit,
2204 "arxiv_categories": cached_push.get("metadata", {}).get("arxiv_categories"),
2205 "conferences": cached_push.get("metadata", {}).get("conferences"),
2206 "journals": cached_push.get("metadata", {}).get("journals"),
2207 "target_date": normalized_target_date,
2208 "cached": True,

Callers

nothing calls this directly

Calls 10

_normalize_push_dateFunction · 0.85
_configured_daily_limitFunction · 0.85
_push_payloadFunction · 0.85
_task_timestampFunction · 0.85
_daily_task_payloadFunction · 0.85
getMethod · 0.80
nowMethod · 0.80
startMethod · 0.80

Tested by

no test coverage detected