Skip to content

Commit a90f873

Browse files
authored
Keep all references to the same course in search (#433)
This is because a user might see a course in "Informatica" that is in common with "Sicurezza informatica" and not know that the course (and therefore the group) is in common for both degrees.
1 parent f090514 commit a90f873

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pages/search/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ export const getServerSideProps: GetServerSideProps<SearchPageProps> = async (co
149149
const courses = query ? (searchResult.value?.courses ?? []) : []
150150

151151
// Filter out duplicate courses (same course, different degree)
152-
const coursesMap = new Map<number, CourseDegree>()
152+
const coursesMap = new Map<[number, String], CourseDegree>()
153153
courses.forEach((course) => {
154-
if (!coursesMap.has(course.course.pk)) {
155-
coursesMap.set(course.course.pk, course)
154+
if (!coursesMap.has([course.course.pk, course.degree_name])) {
155+
coursesMap.set([course.course.pk, course.degree_name], course)
156156
}
157157
})
158158
const uniqueCourses = Array.from(coursesMap.values()).filter((course) => course.course.group !== null && course.course.group.invite_link) // Filter out courses without a group

0 commit comments

Comments
 (0)