Let a pinned minute read runs from the whole day
/observability/runs gains since/until, so the throughput chart's pin asks the server for its minute instead of filtering a fixed recent list. This engine writes ~60 runs a minute, so any minute but the newest read empty. since is inclusive and until exclusive, matching the minute buckets the charts are drawn from. Hover stays the client-side preview it was: scrubbing a day would otherwise be a request per minute rested on. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017MeiWk3Yq12n2pTvnQWYvt
This commit is contained in:
@@ -97,6 +97,11 @@ def _since(hours: int) -> datetime:
|
||||
return datetime.now(timezone.utc) - timedelta(hours=hours)
|
||||
|
||||
|
||||
def _aware(when: datetime) -> datetime:
|
||||
"""A bound as the columns store it. A naive one is read as UTC."""
|
||||
return when if when.tzinfo else when.replace(tzinfo=timezone.utc)
|
||||
|
||||
|
||||
@router.get("/summary", response_model=HealthSummary)
|
||||
async def read_summary(
|
||||
request: Request, controller: FlowControllerDep, session: SessionDep
|
||||
@@ -275,14 +280,24 @@ def read_runs(
|
||||
session: SessionDep,
|
||||
flow: str | None = None,
|
||||
status: str | None = None,
|
||||
since: datetime | None = None,
|
||||
until: datetime | None = None,
|
||||
limit: int = 50,
|
||||
) -> Any:
|
||||
"""Recent cascades, newest first."""
|
||||
"""Recent cascades, newest first.
|
||||
|
||||
``since`` is inclusive and ``until`` exclusive, so a window of one minute
|
||||
holds exactly the runs of the minute bucket the charts are drawn from.
|
||||
"""
|
||||
statement = select(FlowRun).order_by(col(FlowRun.started_at).desc())
|
||||
if flow:
|
||||
statement = statement.where(col(FlowRun.flow) == flow)
|
||||
if status:
|
||||
statement = statement.where(col(FlowRun.status) == status)
|
||||
if since:
|
||||
statement = statement.where(col(FlowRun.started_at) >= _aware(since))
|
||||
if until:
|
||||
statement = statement.where(col(FlowRun.started_at) < _aware(until))
|
||||
return list(session.exec(statement.limit(min(limit, 200))))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user