Skip to content

Commit

Permalink
Merge pull request #2362 from HHS/kw-fix-duplicate-programs
Browse files Browse the repository at this point in the history
[TTAHUB-3388] Deduplicate programs from HSES
  • Loading branch information
kryswisnaskas authored Sep 11, 2024
2 parents fc53441 + ec1180c commit df6c32b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/updateGrantsRecipients.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,13 @@ export async function processFiles(hashSumHex) {

await updateCDIGrantsWithOldGrantData(cdiGrantsToLink);

// Deduplicate based on 'id'
const uniqueProgramsForDb = Array.from(
new Map(programsForDb.map((item) => [item.id, item])).values(),
);

await Program.bulkCreate(
programsForDb,
uniqueProgramsForDb,
{
updateOnDuplicate: ['programType', 'startYear', 'startDate', 'endDate', 'status', 'name'],
transaction,
Expand Down

0 comments on commit df6c32b

Please sign in to comment.