Add oldest and newest route timestamps to status page
Display oldest and newest route timestamps in the Routing Table card on the /status page. Timestamps are shown as relative times (e.g., "5m ago", "2h 30m ago"). Changes: - Add OldestRoute and NewestRoute fields to database.Stats - Query MIN/MAX of last_updated across live_routes_v4 and v6 tables - Include timestamps in both /status.json and /api/v1/stats responses - Add formatRelativeTime JavaScript function for display
This commit is contained in:
@@ -946,6 +946,23 @@ func (d *Database) GetStatsContext(ctx context.Context) (Stats, error) {
|
||||
}
|
||||
stats.LiveRoutes = v4Count + v6Count
|
||||
|
||||
// Get oldest and newest route timestamps
|
||||
routeTimestampQuery := `
|
||||
SELECT MIN(last_updated), MAX(last_updated) FROM (
|
||||
SELECT last_updated FROM live_routes_v4
|
||||
UNION ALL
|
||||
SELECT last_updated FROM live_routes_v6
|
||||
)
|
||||
`
|
||||
var oldestRoute, newestRoute *time.Time
|
||||
err = d.db.QueryRowContext(ctx, routeTimestampQuery).Scan(&oldestRoute, &newestRoute)
|
||||
if err != nil {
|
||||
d.logger.Warn("Failed to get route timestamps", "error", err)
|
||||
} else {
|
||||
stats.OldestRoute = oldestRoute
|
||||
stats.NewestRoute = newestRoute
|
||||
}
|
||||
|
||||
// Get prefix distribution
|
||||
stats.IPv4PrefixDistribution, stats.IPv6PrefixDistribution, err = d.GetPrefixDistributionContext(ctx)
|
||||
if err != nil {
|
||||
|
||||
@@ -18,6 +18,8 @@ type Stats struct {
|
||||
Peers int
|
||||
FileSizeBytes int64
|
||||
LiveRoutes int
|
||||
OldestRoute *time.Time
|
||||
NewestRoute *time.Time
|
||||
IPv4PrefixDistribution []PrefixDistribution
|
||||
IPv6PrefixDistribution []PrefixDistribution
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user