fix: use strict severity totals for sentinel trend
This commit is contained in:
@@ -40,16 +40,16 @@ createApp({
|
||||
});
|
||||
const selectedRun = computed(() => runs.value.find((run) => run.id === selectedRunId.value) || latestRun.value);
|
||||
const trendRows = computed(() => runs.value.slice().sort((a, b) => Date.parse(a.updatedAt || a.createdAt || "") - Date.parse(b.updatedAt || b.createdAt || "")).slice(-48));
|
||||
const trendMax = computed(() => Math.max(1, ...trendRows.value.flatMap((run) => [redCount(run), warningCount(run), findingCount(run)])));
|
||||
const trendMax = computed(() => Math.max(1, ...trendRows.value.flatMap((run) => [trendErrorCount(run), trendWarningCount(run), trendTotalCount(run)])));
|
||||
const trendPolylines = computed(() => ({
|
||||
red: trendPolyline((run) => redCount(run)),
|
||||
warning: trendPolyline((run) => warningCount(run)),
|
||||
total: trendPolyline((run) => findingCount(run)),
|
||||
red: trendPolyline((run) => trendErrorCount(run)),
|
||||
warning: trendPolyline((run) => trendWarningCount(run)),
|
||||
total: trendPolyline((run) => trendTotalCount(run)),
|
||||
}));
|
||||
const trendDots = computed(() => trendRows.value.map((run, index) => {
|
||||
const red = redCount(run);
|
||||
const warning = warningCount(run);
|
||||
const total = findingCount(run);
|
||||
const red = trendErrorCount(run);
|
||||
const warning = trendWarningCount(run);
|
||||
const total = trendTotalCount(run);
|
||||
const x = trendX(index, trendRows.value.length);
|
||||
const redY = trendY(red);
|
||||
const warningY = trendY(warning);
|
||||
@@ -570,6 +570,29 @@ function warningCount(item) {
|
||||
return number(counts.warning) + number(counts.warn) + number(counts.amber);
|
||||
}
|
||||
|
||||
function trendSeverityCounts(item) {
|
||||
const counts = item?.severityCounts;
|
||||
return counts && typeof counts === "object" && !Array.isArray(counts) ? counts : null;
|
||||
}
|
||||
|
||||
function trendErrorCount(item) {
|
||||
const counts = trendSeverityCounts(item);
|
||||
if (!counts) return 0;
|
||||
return number(counts.red) + number(counts.critical) + number(counts.error);
|
||||
}
|
||||
|
||||
function trendWarningCount(item) {
|
||||
const counts = trendSeverityCounts(item);
|
||||
if (!counts) return 0;
|
||||
return number(counts.warning) + number(counts.warn) + number(counts.amber);
|
||||
}
|
||||
|
||||
function trendTotalCount(item) {
|
||||
const counts = trendSeverityCounts(item);
|
||||
if (!counts) return 0;
|
||||
return Object.values(counts).reduce((sum, value) => sum + number(value), 0);
|
||||
}
|
||||
|
||||
function findingCount(item) {
|
||||
const counts = item?.severityCounts;
|
||||
if (counts && typeof counts === "object") return Object.values(counts).reduce((sum, value) => sum + number(value), 0);
|
||||
|
||||
Reference in New Issue
Block a user