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 0.0
2150
2151
2152def _prune_task_registry(
2153 tasks: Dict[str, Dict[str, Any]],
2154 *,
2155 by_user: Optional[Dict[str, str]] = None,
2156) -> None:
2157 """Drop old terminal tasks. Caller must already hold the matching lock.
2158
2159 Only terminal tasks are eligible: a queued or running task is still owned by
2160 a live thread. Age is the primary criterion; the count cap is a backstop for
2161 bursts that all finish within the retention window.
2162 """
2163 now = datetime.now().replace(microsecond=0)
2164 finished = [
2165 (task_id, task)
2166 for task_id, task in tasks.items()
2167 if str(task.get("status") or "") in _TERMINAL_TASK_STATUSES
2168 ]
2169
2170 expired = {
2171 task_id
2172 for task_id, task in finished
2173 if _task_age_seconds(task, now) > _TASK_RETENTION_SECONDS
2174 }
2175
2176 # Oldest-first so the cap keeps the most recent results.
2177 if len(finished) - len(expired) > _TASK_RETENTION_MAX:
2178 remaining = sorted(
2179 ((task_id, task) for task_id, task in finished if task_id not in expired),
2180 key=lambda item: _task_age_seconds(item[1], now),
2181 reverse=True,
2182 )
2183 overflow = len(remaining) - _TASK_RETENTION_MAX
2184 expired.update(task_id for task_id, _ in remaining[:overflow])
2185
2186 for task_id in expired:
2187 tasks.pop(task_id, None)
2188
2189 if by_user is not None:
2190 for user_id, task_id in list(by_user.items()):
2191 if task_id not in tasks:
2192 by_user.pop(user_id, None)
2193
2194
2195def _daily_task_payload(task: Dict[str, Any]) -> Dict[str, Any]:
2196 payload = deepcopy(
2197 {
2198 key: value
2199 for key, value in task.items()
2200 if key not in {"thread", "preview_items_by_key"}
2201 }
2202 )
2203 payload["preview_push"] = _preview_payload(task)
2204 return payload
2205
2206
2207def _make_daily_progress_callback(task_id: str):
2208 def callback(event: Dict[str, Any]) -> None:

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