Skip to content

Commit

Permalink
Remove enrolments deleted from Sisu
Browse files Browse the repository at this point in the history
  • Loading branch information
Keskimaki committed Feb 20, 2024
1 parent aedef1a commit 5bf9d52
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/updater/updateStudentFeedbackTargets.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const deleteInactiveEnrolments = async (enrolments) => {
},
})

if (deleted) logger.info('Deleted student feedback target', { userId: ufbt.userId, feedbackTargetId: ufbt.feedbackTargetId })
if (deleted) logger.debug('Deleted student feedback target', { userId: ufbt.userId, feedbackTargetId: ufbt.feedbackTargetId })
})
}

Expand Down Expand Up @@ -95,11 +95,12 @@ const createEnrolmentFallback = async (ufbt) => {
}

const enrolmentsHandler = async (enrolments) => {
const [activeEnrolments, inactiveEnrolments] = _.partition(enrolments, (enrolment) => enrolment.state === 'ENROLLED')
const [activeEnrolments, deletedEnrolments] = _.partition(enrolments, (enrolment) => enrolment.documentState === 'ACTIVE')
const [acceptedEnrolments, rejectedEnrolments] = _.partition(activeEnrolments, (enrolment) => enrolment.state === 'ENROLLED')

await deleteInactiveEnrolments(inactiveEnrolments)
await deleteInactiveEnrolments(deletedEnrolments.concat(rejectedEnrolments))

const userFeedbackTargets = await createEnrolmentTargets(activeEnrolments)
const userFeedbackTargets = await createEnrolmentTargets(acceptedEnrolments)

const newUfbts = await safeBulkCreate({
entityName: 'UserFeedbackTarget',
Expand Down

0 comments on commit 5bf9d52

Please sign in to comment.