fix: dashboard populates Updates-by-Type and gives honest severity bars
The stats handler initialized updates_by_type but never filled it, so the "Updates by Type" card always rendered empty (Codeberg #10). Add UpdateQueries.GetUpdatesByType (grouped by package_type, non-terminal scope) and wire it into GetDashboardStats. Severity bars were sized against total_updates (all statuses) while the severity counts are scoped to non-terminal rows — a scope mismatch. Bars now size against the sum of the scoped severity values, so they form a true breakdown that always sums to 100% and never overflows. Also closed the silent error-swallows in GetDashboardStats: each sub-count failure is now logged [ERROR] [server] [stats] instead of vanishing.
This commit is contained in:
parent
b8cdb91a21
commit
9be8aba073
3 changed files with 53 additions and 1 deletions
|
|
@ -61,6 +61,12 @@ const Dashboard: React.FC = () => {
|
|||
{ label: 'Low', value: stats?.low_updates ?? 0, color: 'bg-gray-600' },
|
||||
];
|
||||
|
||||
// Bars show each severity's share of the actionable (non-terminal) severity
|
||||
// counts the server returns. Sizing against this sum — not total_updates,
|
||||
// which also counts installed/failed — keeps numerator and denominator in the
|
||||
// same scope so bars always sum to 100% and never overflow. UI-DASHBOARD-AUDIT #2.
|
||||
const severityTotal = severityBreakdown.reduce((sum, s) => sum + s.value, 0);
|
||||
|
||||
const updateTypeBreakdown = Object.entries(stats?.updates_by_type ?? {}).map(([type, count]) => ({
|
||||
type: type.charAt(0).toUpperCase() + type.slice(1),
|
||||
value: count,
|
||||
|
|
@ -151,7 +157,7 @@ const Dashboard: React.FC = () => {
|
|||
<div
|
||||
className={`h-2 rounded-full ${severity.color}`}
|
||||
style={{
|
||||
width: `${(stats?.total_updates ?? 0) > 0 ? (severity.value / (stats?.total_updates ?? 1)) * 100 : 0}%`
|
||||
width: `${severityTotal > 0 ? (severity.value / severityTotal) * 100 : 0}%`
|
||||
}}
|
||||
></div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue