fix: separate sentinel check counts from samples
This commit is contained in:
@@ -888,6 +888,9 @@ function dashboardRunSummary(config: WebProbeSentinelServiceConfig, db: Database
|
||||
const id = stringOrNull(row.id);
|
||||
const severityCounts = id === null ? {} : severityCountsForRun(config, db, id);
|
||||
const maxSeverity = maxSeverityFromCounts(severityCounts);
|
||||
const findingTypeCount = numberOr(row.finding_count, 0);
|
||||
const findingSampleCount = Object.values(severityCounts).reduce((sum, value) => sum + numberOr(value, 0), 0);
|
||||
const findingAlertSampleCount = alertSeveritySampleCount(severityCounts);
|
||||
return {
|
||||
id,
|
||||
runId: id,
|
||||
@@ -903,8 +906,11 @@ function dashboardRunSummary(config: WebProbeSentinelServiceConfig, db: Database
|
||||
stateDir: stringOrNull(row.state_dir),
|
||||
report_json_sha256: stringOrNull(row.report_json_sha256),
|
||||
reportJsonSha256: stringOrNull(row.report_json_sha256),
|
||||
finding_count: numberOr(row.finding_count, 0),
|
||||
findingCount: numberOr(row.finding_count, 0),
|
||||
finding_count: findingTypeCount,
|
||||
findingCount: findingTypeCount,
|
||||
findingTypeCount,
|
||||
findingSampleCount,
|
||||
findingAlertSampleCount,
|
||||
artifact_count: numberOr(row.artifact_count, 0),
|
||||
artifactCount: numberOr(row.artifact_count, 0),
|
||||
maintenance: numberOr(row.maintenance, 0) === 1,
|
||||
@@ -921,6 +927,15 @@ function dashboardRunSummary(config: WebProbeSentinelServiceConfig, db: Database
|
||||
};
|
||||
}
|
||||
|
||||
function alertSeveritySampleCount(counts: Record<string, number>): number {
|
||||
return numberOr(counts.red, 0)
|
||||
+ numberOr(counts.critical, 0)
|
||||
+ numberOr(counts.error, 0)
|
||||
+ numberOr(counts.warning, 0)
|
||||
+ numberOr(counts.warn, 0)
|
||||
+ numberOr(counts.amber, 0);
|
||||
}
|
||||
|
||||
function dashboardOverallStatus(health: Record<string, unknown>, latestRun: Record<string, unknown> | null, severityCounts: Record<string, number>): string {
|
||||
if (health.ok !== true) return "degraded";
|
||||
const latestStatus = latestRun === null ? null : stringOrNull(latestRun.status);
|
||||
|
||||
Reference in New Issue
Block a user