fix: reclassify BU reassignment round-trips and fix backfill date-ordering bug

This commit is contained in:
root
2026-05-01 17:36:28 +00:00
parent 3202b0707c
commit bfa52c7f8f
3 changed files with 123 additions and 11 deletions

View File

@@ -315,10 +315,11 @@ async function detectArchiveChanges(db, previousFindings, currentFindings) {
const returnClassification = { bu_reassignment: 0, severity_drift: 0, closed_on_platform: 0, decommissioned: 0 };
for (const archiveId of returnedArchiveIds) {
try {
// Find the most recent ARCHIVED transition reason for this archive record
// Find the most recent ARCHIVED transition reason *before* this return
const transition = await dbGet(db,
`SELECT reason FROM ivanti_archive_transitions
WHERE archive_id = ? AND to_state = 'ARCHIVED'
AND transitioned_at <= datetime('now')
ORDER BY transitioned_at DESC LIMIT 1`,
[archiveId]
);