From 214a7490dab54e30c82e235d74deb658de162db0 Mon Sep 17 00:00:00 2001 From: Barry Dwyer Date: Fri, 19 Dec 2025 13:23:01 +0200 Subject: [PATCH] Remove reinstate action with associated archive Makes as if the archive never happened --- v1-to-v2-data-migration/helpers/transform.ts | 9 +++++++++ v1-to-v2-data-migration/helpers/types.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/v1-to-v2-data-migration/helpers/transform.ts b/v1-to-v2-data-migration/helpers/transform.ts index 69fb176..24ea250 100644 --- a/v1-to-v2-data-migration/helpers/transform.ts +++ b/v1-to-v2-data-migration/helpers/transform.ts @@ -317,6 +317,7 @@ function legacyHistoryItemToV2ActionType( UNASSIGNED: 'UNASSIGN', VIEWED: 'READ', VERIFIED: 'VALIDATE', + REINSTATED: 'REINSTATE', } const type = historyItem.action ? actionMap[historyItem.action] : undefined @@ -340,6 +341,7 @@ const preProcessHistory = (eventRegistration: EventRegistration) => { const processedHistory: any[] = [] const issued: any[] = [] const corrections: any[] = [] + const reinstated: any[] = [] let issuances = 0 for (const historyItem of eventRegistration.history.sort( (a, b) => new Date(b.date).valueOf() - new Date(a.date).valueOf() @@ -402,6 +404,13 @@ const preProcessHistory = (eventRegistration: EventRegistration) => { certificates: [historyItem.certificates?.reverse()?.[issuances]], }) issuances++ + } else if (historyItem.action === 'REINSTATED') { + reinstated.push(historyItem) + } else if (!historyItem.action && historyItem.regStatus === 'ARCHIVED') { + const wasReinstate = reinstated.pop() + if (!wasReinstate) { + processedHistory.push(historyItem) + } } else { processedHistory.push(historyItem) } diff --git a/v1-to-v2-data-migration/helpers/types.ts b/v1-to-v2-data-migration/helpers/types.ts index 20ce769..bbd19d3 100644 --- a/v1-to-v2-data-migration/helpers/types.ts +++ b/v1-to-v2-data-migration/helpers/types.ts @@ -232,6 +232,7 @@ export type ActionType = | 'MARK_AS_DUPLICATE' | 'MARK_AS_NOT_DUPLICATE' | 'READ' + | 'REINSTATE' export interface ActionContent { templateId?: string