mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
feat(stats): record daily snapshots and serve a trend API
The aggregation worker now writes one row per UTC day to stats_snapshots. The row holds package count, total size, vulnerable package count, the four severity counts and the blocked count. The write is an idempotent upsert per day. A migration backfills package counts from cached_at and deleted_at as the number of packages alive at the end of each day. Vulnerability fields backfill from scan_results timestamps and stay empty before the first scan. GET /api/stats/trend returns daily points for 30day, 90day or 1year with a constant number of queries. The Stats page shows a chart of cached and vulnerable packages with a period selector and severity toggles. The Dashboard shows a compact version. The Lean model gains theorems for the backfill and upsert.
This commit is contained in:
Vendored
+8
@@ -265,6 +265,14 @@ func (m *MockMetadataStore) ListExpiredPackages(context.Context, time.Time, int)
|
||||
|
||||
func (m *MockMetadataStore) ClearArtifactExpiry(context.Context) (int64, error) { return 0, nil }
|
||||
|
||||
func (m *MockMetadataStore) PurgeDeletedPackages(context.Context, time.Time, int) (int64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (m *MockMetadataStore) GetStatsTrend(context.Context, time.Time) ([]*metadata.StatsSnapshot, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// API key methods are not used by the cache package; stub them out so the
|
||||
// mock continues to satisfy metadata.MetadataStore after the interface gained
|
||||
// API key persistence methods.
|
||||
|
||||
Reference in New Issue
Block a user