Fix forecast chart bar order and snapshot month derivation

Flip stacked bar chart so non-compliant (orange) renders on top and
compliant (blue) on bottom for better visual emphasis.

Use the file's report_date for compliance_snapshots month instead of
the current date, so historical uploads land in the correct monthly
bucket. Also fix rollback to delete the correct month's snapshot.

Remove cve-frontend systemd service ( Express serves theredundant
built frontend on port 3001).
This commit is contained in:
Jordan Ramos
2026-05-21 12:22:52 -06:00
parent ae2b7e0433
commit 940cb3251c
2 changed files with 15 additions and 14 deletions

View File

@@ -144,7 +144,8 @@ async function persistMultiVerticalUpload({ items, summary, reportDate, filename
// Use summary data for accurate totals (compliance_items only has non-compliant devices). // Use summary data for accurate totals (compliance_items only has non-compliant devices).
// IMPORTANT: Only use "ALL:" rollup rows to avoid double-counting. Each Summary sheet // IMPORTANT: Only use "ALL:" rollup rows to avoid double-counting. Each Summary sheet
// has sub-team rows AND a rollup row per metric — the rollup already includes sub-teams. // has sub-team rows AND a rollup row per metric — the rollup already includes sub-teams.
const currentMonth = new Date().toISOString().slice(0, 7); // Use the file's report_date month for the snapshot so historical uploads land in the correct bucket.
const snapshotMonth = reportDate ? reportDate.slice(0, 7) : new Date().toISOString().slice(0, 7);
let totalDevices = 0, snapshotCompliant = 0, snapshotNonCompliant = 0; let totalDevices = 0, snapshotCompliant = 0, snapshotNonCompliant = 0;
if (summary && summary.entries && summary.entries.length > 0) { if (summary && summary.entries && summary.entries.length > 0) {
@@ -165,7 +166,7 @@ async function persistMultiVerticalUpload({ items, summary, reportDate, filename
VALUES ($1, $2, $3, $4, $5, $6) VALUES ($1, $2, $3, $4, $5, $6)
ON CONFLICT (snapshot_month, vertical) ON CONFLICT (snapshot_month, vertical)
DO UPDATE SET total_devices = $3, compliant = $4, non_compliant = $5, compliance_pct = $6`, DO UPDATE SET total_devices = $3, compliant = $4, non_compliant = $5, compliance_pct = $6`,
[currentMonth, vertical, totalDevices, snapshotCompliant, snapshotNonCompliant, compPct] [snapshotMonth, vertical, totalDevices, snapshotCompliant, snapshotNonCompliant, compPct]
); );
return { uploadId, newCount, recurringCount, resolvedCount }; return { uploadId, newCount, recurringCount, resolvedCount };
@@ -1195,10 +1196,10 @@ function createVCLMultiVerticalRouter(upload) {
await client.query(`DELETE FROM vcl_multi_vertical_summary WHERE upload_id = $1`, [uploadId]); await client.query(`DELETE FROM vcl_multi_vertical_summary WHERE upload_id = $1`, [uploadId]);
await client.query(`DELETE FROM compliance_uploads WHERE id = $1`, [uploadId]); await client.query(`DELETE FROM compliance_uploads WHERE id = $1`, [uploadId]);
const currentMonth = new Date().toISOString().slice(0, 7); const rollbackMonth = upload.report_date ? upload.report_date.slice(0, 7) : new Date().toISOString().slice(0, 7);
await client.query( await client.query(
`DELETE FROM compliance_snapshots WHERE vertical = $1 AND snapshot_month = $2`, `DELETE FROM compliance_snapshots WHERE vertical = $1 AND snapshot_month = $2`,
[upload.vertical, currentMonth] [upload.vertical, rollbackMonth]
); );
await client.query('COMMIT'); await client.query('COMMIT');

View File

@@ -1486,16 +1486,6 @@ function ForecastBurndownChart({ metricId }) {
label={{ value: 'Forecast →', position: 'top', style: { fontSize: 9, fill: PURPLE } }} label={{ value: 'Forecast →', position: 'top', style: { fontSize: 9, fill: PURPLE } }}
/> />
)} )}
<Bar
yAxisId="left"
dataKey="non_compliant"
name="Non-Compliant"
stackId="devices"
fill="#F97316"
shape={renderNonCompliantBar}
label={renderNonCompliantLabel}
barSize={36}
/>
<Bar <Bar
yAxisId="left" yAxisId="left"
dataKey="compliant" dataKey="compliant"
@@ -1506,6 +1496,16 @@ function ForecastBurndownChart({ metricId }) {
label={renderTotalLabel} label={renderTotalLabel}
barSize={36} barSize={36}
/> />
<Bar
yAxisId="left"
dataKey="non_compliant"
name="Non-Compliant"
stackId="devices"
fill="#F97316"
shape={renderNonCompliantBar}
label={renderNonCompliantLabel}
barSize={36}
/>
<Line <Line
yAxisId="right" yAxisId="right"
type="monotone" type="monotone"