From 9b8d3b5e643996e86b1ca68985fc8543ee43ad32 Mon Sep 17 00:00:00 2001 From: Henri Remonen Date: Tue, 23 Apr 2024 10:28:20 +0300 Subject: [PATCH] fix: course unit filtering logic --- .../updateCoursesAndTeacherFeedbackTargets.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/updater/updateCoursesAndTeacherFeedbackTargets/updateCoursesAndTeacherFeedbackTargets.js b/src/updater/updateCoursesAndTeacherFeedbackTargets/updateCoursesAndTeacherFeedbackTargets.js index fd5a4ef..debed5c 100644 --- a/src/updater/updateCoursesAndTeacherFeedbackTargets/updateCoursesAndTeacherFeedbackTargets.js +++ b/src/updater/updateCoursesAndTeacherFeedbackTargets/updateCoursesAndTeacherFeedbackTargets.js @@ -403,7 +403,10 @@ const getArchivedCoursesToDelete = async (courses) => { const coursesHandler = async (courses) => { // Filter out old AY courses. Already existing ones remain in db. - const courseUnits = [].concat(...courses.map((course) => course.courseUnits)).filter(({ code }) => code.startsWith('AY') && !code.match('^AY[0-9]+$')) + const courseUnits = courses + .flatMap((course) => course.courseUnits) + .filter(({ code }) => !(code.startsWith('AY') && !code.match('^AY[0-9]+$'))) + await createCourseUnits(courseUnits) const includeCurs = await getIncludeCurs()