Review funkt

This commit is contained in:
2026-08-09 21:56:00 +00:00
parent f522ae9953
commit fe9dfa4519
11366 changed files with 2335077 additions and 97 deletions

View File

@@ -0,0 +1,14 @@
-- Metrics for a queue/kind: the cumulative meta `count` and the per-minute data
-- points (newest first), sliced to [start, end] with Redis LRANGE semantics
-- (index 0 is the newest point; a negative end means "to the oldest").
-- Params: $1 queue, $2 kind ('completed' | 'failed'), $3 start, $4 end.
SELECT
COALESCE((SELECT count FROM metrics
WHERE queue = $1 AND kind = $2), 0)::bigint AS total,
COALESCE((
SELECT CASE
WHEN $4 < 0 THEN data[($3 + 1) : ]
ELSE data[($3 + 1) : ($4 + 1)]
END
FROM metrics WHERE queue = $1 AND kind = $2
), ARRAY[]::bigint[]) AS data;