Fix AEO compliance page not showing metric health cards on dev
The /summary endpoint was fetching the most recent upload regardless of vertical, which on dev was a PRDCT_VSO multi-vertical upload. Now it looks for AEO uploads (vertical IS NULL) first, then falls back to the NTS_AEO multi-vertical upload. The /items endpoint now includes items from both vertical IS NULL and vertical = 'NTS_AEO' so the AEO compliance page shows devices uploaded through either flow.
This commit is contained in:
@@ -497,9 +497,15 @@ function createComplianceRouter(upload) {
|
|||||||
if (team && !ALLOWED_TEAMS.has(team)) return res.status(400).json({ error: 'Invalid team' });
|
if (team && !ALLOWED_TEAMS.has(team)) return res.status(400).json({ error: 'Invalid team' });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { rows: latestRows } = await pool.query(
|
// Try AEO uploads first (vertical IS NULL), fall back to NTS_AEO multi-vertical upload
|
||||||
`SELECT id, summary_json, report_date, uploaded_at FROM compliance_uploads ORDER BY id DESC LIMIT 1`
|
let { rows: latestRows } = await pool.query(
|
||||||
|
`SELECT id, summary_json, report_date, uploaded_at FROM compliance_uploads WHERE vertical IS NULL ORDER BY id DESC LIMIT 1`
|
||||||
);
|
);
|
||||||
|
if (latestRows.length === 0 || !latestRows[0].summary_json) {
|
||||||
|
({ rows: latestRows } = await pool.query(
|
||||||
|
`SELECT id, summary_json, report_date, uploaded_at FROM compliance_uploads WHERE vertical = 'NTS_AEO' ORDER BY id DESC LIMIT 1`
|
||||||
|
));
|
||||||
|
}
|
||||||
const latestUpload = latestRows[0];
|
const latestUpload = latestRows[0];
|
||||||
if (!latestUpload || !latestUpload.summary_json) return res.json({ entries: [], overall_scores: {}, upload: null });
|
if (!latestUpload || !latestUpload.summary_json) return res.json({ entries: [], overall_scores: {}, upload: null });
|
||||||
|
|
||||||
@@ -533,6 +539,7 @@ function createComplianceRouter(upload) {
|
|||||||
if (!['active', 'resolved'].includes(status)) return res.status(400).json({ error: 'Invalid status' });
|
if (!['active', 'resolved'].includes(status)) return res.status(400).json({ error: 'Invalid status' });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Include items from both AEO uploads (vertical IS NULL) and NTS_AEO multi-vertical uploads
|
||||||
const { rows } = await pool.query(
|
const { rows } = await pool.query(
|
||||||
`SELECT ci.hostname, ci.ip_address, ci.device_type, ci.team, ci.metric_id, ci.metric_desc, ci.category, ci.status, ci.seen_count,
|
`SELECT ci.hostname, ci.ip_address, ci.device_type, ci.team, ci.metric_id, ci.metric_desc, ci.category, ci.status, ci.seen_count,
|
||||||
fu.report_date AS first_seen, lu.report_date AS last_seen, ru.report_date AS resolved_on
|
fu.report_date AS first_seen, lu.report_date AS last_seen, ru.report_date AS resolved_on
|
||||||
@@ -540,7 +547,7 @@ function createComplianceRouter(upload) {
|
|||||||
LEFT JOIN compliance_uploads fu ON ci.first_seen_upload_id = fu.id
|
LEFT JOIN compliance_uploads fu ON ci.first_seen_upload_id = fu.id
|
||||||
LEFT JOIN compliance_uploads lu ON ci.upload_id = lu.id
|
LEFT JOIN compliance_uploads lu ON ci.upload_id = lu.id
|
||||||
LEFT JOIN compliance_uploads ru ON ci.resolved_upload_id = ru.id
|
LEFT JOIN compliance_uploads ru ON ci.resolved_upload_id = ru.id
|
||||||
WHERE ci.team = $1 AND ci.status = $2
|
WHERE ci.team = $1 AND ci.status = $2 AND (ci.vertical IS NULL OR ci.vertical = 'NTS_AEO')
|
||||||
ORDER BY ci.hostname, ci.metric_id`,
|
ORDER BY ci.hostname, ci.metric_id`,
|
||||||
[team, status]
|
[team, status]
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user