Metrics says history is kept for 31 days regardless of the retention setting #141

Closed
opened 2026-10-10 14:33:50 -04:00 by goddard · 1 comment
Collaborator

About this report always says history is kept for 31 days, even when an administrator has changed the metrics retention.

  • +page.svelte:379 hard-codes "History is retained for 31 days."
  • fleet/metrics.ts:34-36 and retention.ts:570-573 delete samples using metricsKeepDays, which Admin → Settings can change. A value of 0 keeps them indefinitely.
  • metrics.md:93 documents the period as configurable.

Screenshots

The preview's metrics retention is set to 90 days in Admin → Settings.

Before:
Before

After (mockup):
After (mockup)

Fix

  • Show the configured metricsKeepDays in About this report, including when samples are kept indefinitely
About this report always says history is kept for 31 days, even when an administrator has changed the metrics retention. - `+page.svelte:379` hard-codes "History is retained for 31 days." - `fleet/metrics.ts:34-36` and `retention.ts:570-573` delete samples using `metricsKeepDays`, which Admin → Settings can change. A value of 0 keeps them indefinitely. - `metrics.md:93` documents the period as configurable. **Screenshots** The preview's metrics retention is set to 90 days in Admin → Settings. Before: ![Before](https://gitea.thewrightserver.net/attachments/d9157ce2-5b64-421b-a6d2-4c56f691990f) After (mockup): ![After (mockup)](https://gitea.thewrightserver.net/attachments/bf9040c5-729e-4e56-8a70-7566a0f892c9) **Fix** - Show the configured `metricsKeepDays` in About this report, including when samples are kept indefinitely
goddard added the
priority
low
type/bug
labels 2026-10-10 14:33:50 -04:00
josh was assigned by goddard 2026-10-10 14:33:50 -04:00
Author
Collaborator

Reviewed d6041e40ef. The fix item is done, so I'm closing this.

Checklist

  • Show the configured metricsKeepDays. readMetrics now returns metricsKeepDays from the fleet settings (fleet/metrics.ts:510), and About this report says "Occupancy history is retained indefinitely" for 0 or "for N days" otherwise (+page.svelte:408-410). No hard-coded 31-day text is left on the page or in the metrics components.

Review notes

  • Good extra catch: the report worker adds metricsKeepDays to its cache key (reports/worker.ts:32-33), so a retention change shows on the next load without waiting for new samples. fleetSettings() reads the database on every call (settings.ts:5-10), so the worker thread never sees a stale value.
  • The refresh validator rejects reports without a whole, non-negative metricsKeepDays (metrics-refresh.ts:47-48).
  • The touched test files (metrics, metrics-refresh, ui-metrics-page) pass locally as part of the 100-test run above. The page test covers 0 as "indefinitely".
  • Minor and non-blocking: the API section of metrics.md doesn't mention the new metricsKeepDays field.
Reviewed d6041e40ef0168306c454d828af57db43ef18349. The fix item is done, so I'm closing this. **Checklist** - [x] **Show the configured `metricsKeepDays`.** `readMetrics` now returns `metricsKeepDays` from the fleet settings (`fleet/metrics.ts:510`), and About this report says "Occupancy history is retained indefinitely" for 0 or "for N days" otherwise (`+page.svelte:408-410`). No hard-coded 31-day text is left on the page or in the metrics components. **Review notes** - Good extra catch: the report worker adds `metricsKeepDays` to its cache key (`reports/worker.ts:32-33`), so a retention change shows on the next load without waiting for new samples. `fleetSettings()` reads the database on every call (`settings.ts:5-10`), so the worker thread never sees a stale value. - The refresh validator rejects reports without a whole, non-negative `metricsKeepDays` (`metrics-refresh.ts:47-48`). - The touched test files (`metrics`, `metrics-refresh`, `ui-metrics-page`) pass locally as part of the 100-test run above. The page test covers 0 as "indefinitely". - Minor and non-blocking: the API section of `metrics.md` doesn't mention the new `metricsKeepDays` field.
Sign in to join this conversation.