snapshot: prune speedtests older than 30 days (retention via existing storage primitive)
This commit is contained in:
@@ -43,7 +43,16 @@ type snapshot struct {
|
||||
// buildSpeedtestSnapshot collects the last 200 speedtest rows + per-node
|
||||
// medians over 24h/7d/30d windows. Aggregate errors are logged but
|
||||
// non-fatal — the rest of the snapshot still ships.
|
||||
//
|
||||
// Side effect: prunes speedtests older than 30 days. Retention is colocated
|
||||
// with snapshot rebuild because both run on the same timer cadence and the
|
||||
// storage layer already has the DeleteSpeedTestsBefore primitive.
|
||||
func buildSpeedtestSnapshot(ctx context.Context, st *storage.Store) (*SpeedtestSnapshot, error) {
|
||||
if deleted, err := st.DeleteSpeedTestsBefore(ctx, time.Now().Add(-30*24*time.Hour).Unix()); err != nil {
|
||||
log.Printf("speedtests retention (non-fatal): %v", err)
|
||||
} else if deleted > 0 {
|
||||
log.Printf("speedtests retention: pruned %d rows older than 30 days", deleted)
|
||||
}
|
||||
recent, err := st.ListRecentSpeedTests(ctx, 200)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user