diff --git a/internal/store/host_repo_stats.go b/internal/store/host_repo_stats.go index 9889b29..681788f 100644 --- a/internal/store/host_repo_stats.go +++ b/internal/store/host_repo_stats.go @@ -211,6 +211,21 @@ func (s *Store) UpsertHostRepoStats(ctx context.Context, hostID string, patch Ho ); err != nil { return fmt.Errorf("store: upsert host_repo_stats: %w", err) } + + // Project total_size_bytes onto the dashboard's host row so the + // "Repo size" column and FleetSummary.SUM(repo_size_bytes) stay in + // sync with the latest report. We only write a non-nil size — a + // patch that doesn't carry a size (e.g. a prune-only ack) leaves + // the prior row value alone. + if cur.TotalSizeBytes != nil { + if _, err = tx.ExecContext(ctx, + `UPDATE hosts SET repo_size_bytes = ? WHERE id = ?`, + *cur.TotalSizeBytes, hostID, + ); err != nil { + return fmt.Errorf("store: project repo_size_bytes onto hosts row: %w", err) + } + } + return tx.Commit() } diff --git a/web/templates/pages/dashboard.html b/web/templates/pages/dashboard.html index 5a8587d..e95ff78 100644 --- a/web/templates/pages/dashboard.html +++ b/web/templates/pages/dashboard.html @@ -213,10 +213,10 @@
-