Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions v1-to-v2-data-migration/helpers/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ function legacyHistoryItemToV2ActionType(
UNASSIGNED: 'UNASSIGN',
VIEWED: 'READ',
VERIFIED: 'VALIDATE',
REINSTATED: 'REINSTATE',
}

const type = historyItem.action ? actionMap[historyItem.action] : undefined
Expand All @@ -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()
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions v1-to-v2-data-migration/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export type ActionType =
| 'MARK_AS_DUPLICATE'
| 'MARK_AS_NOT_DUPLICATE'
| 'READ'
| 'REINSTATE'

export interface ActionContent {
templateId?: string
Expand Down