From 60c780321d40c35aa1e7698626bc5882edade17f Mon Sep 17 00:00:00 2001 From: Matthew Rowland Date: Mon, 4 Nov 2024 18:26:19 -0800 Subject: [PATCH] fix: Duplicate terms based on academic career --- apps/backend/src/scripts/update-catalog.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/backend/src/scripts/update-catalog.ts b/apps/backend/src/scripts/update-catalog.ts index c50b9f685..c6f2ac5af 100644 --- a/apps/backend/src/scripts/update-catalog.ts +++ b/apps/backend/src/scripts/update-catalog.ts @@ -297,11 +297,17 @@ const initialize = async () => { temporalPosition: { $in: ["Current", "Future"] }, }).lean(); + // Remove duplicate terms + const filteredTerms = currentTerms.filter( + ({ id }, index) => + index === currentTerms.findIndex((term) => term.id === id) + ); + console.log("\n=== UPDATE CLASSES ==="); - await updateClasses(currentTerms); + await updateClasses(filteredTerms); console.log("\n=== UPDATE SECTIONS ==="); - await updateSections(currentTerms); + await updateSections(filteredTerms); } catch (error) { console.error(error);