Skip to content

Commit fa9a90e

Browse files
committed
refactor: restore and compute public key metrics in dashboard data
1 parent a084dac commit fa9a90e

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

core/dashboard.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import (
1616
type DashboardData struct {
1717
AccountCount int
1818
ActiveAccountCount int
19-
// PublicKeyCount int
20-
// GlobalKeyCount int
21-
// AlgoCounts map[string]int
22-
HostsUpToDate int
23-
HostsOutdated int
24-
SystemKeySerial int
25-
RecentLogs []model.AuditLogEntry
19+
PublicKeyCount int
20+
GlobalKeyCount int
21+
AlgoCounts map[string]int
22+
HostsUpToDate int
23+
HostsOutdated int
24+
SystemKeySerial int
25+
RecentLogs []model.AuditLogEntry
2626
}
2727

2828
// BuildDashboardData collects accounts, keys, system key and recent audit logs,
@@ -70,6 +70,14 @@ func BuildDashboardData(reader DashboardReader) (DashboardData, error) {
7070
for _, k := range keys {
7171
keysByID[k.ID] = k
7272
}
73+
out.PublicKeyCount = len(keys)
74+
out.AlgoCounts = make(map[string]int)
75+
for _, k := range keys {
76+
if k.IsGlobal {
77+
out.GlobalKeyCount++
78+
}
79+
out.AlgoCounts[k.Algorithm]++
80+
}
7381
}
7482
}
7583

@@ -87,15 +95,6 @@ func BuildDashboardData(reader DashboardReader) (DashboardData, error) {
8795
}
8896
}
8997

90-
// out.PublicKeyCount = len(klist)
91-
// out.AlgoCounts = make(map[string]int)
92-
// for _, k := range klist {
93-
// if k.IsGlobal {
94-
// out.GlobalKeyCount++
95-
// }
96-
// out.AlgoCounts[k.Algorithm]++
97-
// }
98-
9998
if sysKey != nil {
10099
out.SystemKeySerial = sysKey.Serial
101100
}

0 commit comments

Comments
 (0)