feat: sidebar exchange counts respect selected time range
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 2m47s
CI / docker (push) Successful in 48s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 36s

The /routes/catalog endpoint now accepts optional from/to query
parameters instead of hardcoding a 24h window. The UI passes the
global filter time range so sidebar counts match what the user sees.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-03-26 12:21:10 +01:00
parent f4bf38fcba
commit 056a6f0ff5
3 changed files with 19 additions and 9 deletions

View File

@@ -14,6 +14,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.sql.Timestamp;
@@ -44,7 +45,9 @@ public class RouteCatalogController {
@Operation(summary = "Get route catalog",
description = "Returns all applications with their routes, agents, and health status")
@ApiResponse(responseCode = "200", description = "Catalog returned")
public ResponseEntity<List<AppCatalogEntry>> getCatalog() {
public ResponseEntity<List<AppCatalogEntry>> getCatalog(
@RequestParam(required = false) String from,
@RequestParam(required = false) String to) {
List<AgentInfo> allAgents = registryService.findAll();
// Group agents by application name
@@ -63,9 +66,10 @@ public class RouteCatalogController {
routesByApp.put(entry.getKey(), routes);
}
// Query route-level stats for the last 24 hours
// Time range for exchange counts — use provided range or default to last 24h
Instant now = Instant.now();
Instant from24h = now.minus(24, ChronoUnit.HOURS);
Instant rangeFrom = from != null ? Instant.parse(from) : now.minus(24, ChronoUnit.HOURS);
Instant rangeTo = to != null ? Instant.parse(to) : now;
Instant from1m = now.minus(1, ChronoUnit.MINUTES);
// Route exchange counts from continuous aggregate
@@ -82,7 +86,7 @@ public class RouteCatalogController {
Timestamp ts = rs.getTimestamp("last_seen");
if (ts != null) routeLastSeen.put(key, ts.toInstant());
},
Timestamp.from(from24h), Timestamp.from(now));
Timestamp.from(rangeFrom), Timestamp.from(rangeTo));
} catch (Exception e) {
// Continuous aggregate may not exist yet
}