feat(worker): ручной пересчёт метрик через очередь, диагностика шагов и heartbeat

POST /metrics/refresh ставит задачу в sync_job (source=METRICS_JOB) и отвечает 202, пересчёт делает worker; GET /metrics/status отдаёт refreshing и consistent. metric_refresh_log хранит failed_step и step_timings. Источники с needs="tinvest_token" не попадают в расписание без токена, tinvest/moex добавлены в default_schedule. Воркер трогает heartbeat-файл для healthcheck.
This commit is contained in:
Dmitry
2026-09-19 21:54:30 +03:00
parent 989a780f9f
commit 3b3ee4d682
11 changed files with 341 additions and 30 deletions
+5
View File
@@ -135,6 +135,11 @@ class MetricRefreshLog(Base):
trigger: Mapped[str] = mapped_column(String(32))
"""sync:<source> | manual | cli"""
error: Mapped[str | None] = mapped_column(Text)
failed_step: Mapped[str | None] = mapped_column(String(64))
"""Name of the step that raised. Steps before it committed and the ones after it did not
run, so the metric tables then come from two different runs."""
step_timings: Mapped[dict[str, Any] | None]
"""Seconds per step that completed, in run order."""
class MetricPortfolioValueDaily(Base):