-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b64ae0a
commit abb0b2b
Showing
13 changed files
with
156 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* eslint-disable no-restricted-syntax */ | ||
/* eslint-disable no-loop-func */ | ||
import { Op } from 'sequelize'; | ||
import { auditLogger } from '../logger'; | ||
import { ActivityReport, ActivityRecipient, NonGrantee } from '../models'; | ||
|
||
const hubNonGrantees = { | ||
HSCO: 'Head Start Collaboration Office', | ||
'Local/State Education System': 'State Education System', | ||
'State Early Learning System / Guidelines': 'State Early Learning Standards', | ||
'State Advisory Council': 'QRIS System', | ||
'Regional TTA Team / Specialists': 'Regional TTA/Other Specialists', | ||
'State Early Learning Standards / Guidelines': | ||
'State Early Learning Standards', | ||
}; | ||
|
||
const populateLegacyNonGrantees = async () => { | ||
const nonGranteeReports = await ActivityReport.findAll({ | ||
where: { | ||
[Op.and]: [ | ||
{ legacyId: { [Op.ne]: null } }, | ||
{ | ||
imported: { | ||
nonGranteeActivity: { | ||
[Op.ne]: '', | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
for await (const nonGranteeReport of nonGranteeReports) { | ||
const nonGranteeArray = nonGranteeReport.imported.nonGranteeActivity.split( | ||
'\n', | ||
); | ||
for await (const nonGranteeName of nonGranteeArray) { | ||
const translatedNonGranteeName = hubNonGrantees[nonGranteeName] || nonGranteeName; | ||
const nonGrantee = await NonGrantee.findOne({ | ||
where: { name: translatedNonGranteeName }, | ||
}); | ||
if (nonGrantee) { | ||
auditLogger.info( | ||
`Processing non-grantee ${nonGrantee.id} for activity report ${nonGranteeReport.id}`, | ||
); | ||
await ActivityRecipient.findOrCreate({ | ||
where: { | ||
activityReportId: nonGranteeReport.id, | ||
nonGranteeId: nonGrantee.id, | ||
}, | ||
}); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
export default populateLegacyNonGrantees; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import populateLegacyNonGrantees from './populateLegacyNonGrantees'; | ||
import { auditLogger } from '../logger'; | ||
|
||
populateLegacyNonGrantees().catch((e) => { | ||
auditLogger.error(e); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters