Move failed count and avg duration from page-derived to backend stats
All stat card values now come from the /search/stats endpoint which queries the full time window, not just the current page of results. Consolidated into a single ClickHouse query for efficiency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -89,16 +89,18 @@ public class ClickHouseSearchEngine implements SearchEngine {
|
||||
|
||||
@Override
|
||||
public ExecutionStats stats(Instant from, Instant to) {
|
||||
Long p99 = jdbcTemplate.queryForObject(
|
||||
"SELECT toInt64(quantile(0.99)(duration_ms)) FROM route_executions " +
|
||||
"WHERE start_time >= ? AND start_time <= ?",
|
||||
Long.class, Timestamp.from(from), Timestamp.from(to));
|
||||
Long active = jdbcTemplate.queryForObject(
|
||||
"SELECT count() FROM route_executions WHERE status = 'RUNNING'",
|
||||
Long.class);
|
||||
return new ExecutionStats(
|
||||
p99 != null ? p99 : 0L,
|
||||
active != null ? active : 0L);
|
||||
return jdbcTemplate.queryForObject(
|
||||
"SELECT countIf(status = 'FAILED') AS failed_count, " +
|
||||
"toInt64(avg(duration_ms)) AS avg_duration_ms, " +
|
||||
"toInt64(quantile(0.99)(duration_ms)) AS p99_duration_ms, " +
|
||||
"countIf(status = 'RUNNING') AS active_count " +
|
||||
"FROM route_executions WHERE start_time >= ? AND start_time <= ?",
|
||||
(rs, rowNum) -> new ExecutionStats(
|
||||
rs.getLong("failed_count"),
|
||||
rs.getLong("avg_duration_ms"),
|
||||
rs.getLong("p99_duration_ms"),
|
||||
rs.getLong("active_count")),
|
||||
Timestamp.from(from), Timestamp.from(to));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user