Skip to content

Commit 4a55f03

Browse files
committed
fix(webapp): keep the clipped queue metric window ordered
A date range that ends before the plan's earliest queryable time had its start pulled forward past its own end, sending an inverted window to ClickHouse. It now collapses to an empty window, which is what the enforced lower bound in executeQuery produces for the same request: no rows.
1 parent 7c6cbec commit 4a55f03

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

apps/webapp/app/components/queues/queueMetricsPeriod.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,16 @@ export function clampQueueMetricsPeriod(period: string, maxPeriodDays: number):
9797
* applies to every metric query. Queue-metric queries that go straight to ClickHouse (the queues
9898
* list table, the concurrency-keys endpoint) have to apply it themselves, otherwise a hand-typed
9999
* `?period=` reaches further back than the plan allows.
100+
*
101+
* A range that ends before the plan's earliest queryable time collapses to an empty window rather
102+
* than an inverted one, which is what the enforced lower bound in `executeQuery` yields for the
103+
* same request: no rows.
100104
*/
101105
export function clipQueueMetricsWindow(
102106
window: { from: Date; to: Date },
103107
maxPeriodDays: number
104108
): { from: Date; to: Date } {
105109
const earliest = new Date(Date.now() - maxPeriodDays * DAY_MS);
106-
return { from: window.from < earliest ? earliest : window.from, to: window.to };
110+
const from = window.from < earliest ? earliest : window.from;
111+
return { from, to: window.to < from ? from : window.to };
107112
}

0 commit comments

Comments
 (0)