Unverified Commit 0edd35e5 authored by Estelle Veisemburger's avatar Estelle Veisemburger Committed by Florent Chehab
Browse files

feat(filter): using majorMinorMappings in the filter

parent 0c322690
import { getMostNRecentSemesters } from "../utils/compareSemesters"; import { getMostNRecentSemesters } from "../utils/compareSemesters";
import UniversityService from "./data/UniversityService"; import UniversityService from "./data/UniversityService";
import CountryService from "./data/CountryService"; import CountryService from "./data/CountryService";
import { getUpdatedMajor, getUpdatedMinor } from "../utils/majorMinorMappings";
/** /**
* Class that handle all the filter manipulation with caching * Class that handle all the filter manipulation with caching
...@@ -50,7 +51,7 @@ class FilterService { ...@@ -50,7 +51,7 @@ class FilterService {
})); }));
this._destinationOpenCount = universities.filter( this._destinationOpenCount = universities.filter(
u => u.denormalized_infos.is_destination_open === true (u) => u.denormalized_infos.is_destination_open === true
).length; ).length;
} }
...@@ -110,20 +111,17 @@ class FilterService { ...@@ -110,20 +111,17 @@ class FilterService {
allowedSemesters === null ? true : allowedSemesters.includes(sem) allowedSemesters === null ? true : allowedSemesters.includes(sem)
) )
.map(([, forSemester]) => forSemester) .map(([, forSemester]) => forSemester)
.flatMap(forSemester => Object.entries(forSemester)) .flatMap((forSemester) => Object.entries(forSemester))
.flatMap(([major, minors]) => .flatMap(([major, minors]) =>
minors.map(minor => { minors.map((minor) => {
if (major === "GSM" || major === "GM") { const maj = getUpdatedMajor(major);
major = "IM"; const min = getUpdatedMinor(major, minor);
} return `${maj}${min}`;
return `${major}${minor}`;
}) })
); );
const extraMinors = this.getMajorInUniv(univObj).map(major => { const extraMinors = this.getMajorInUniv(univObj).map((major) => {
if (major === "GSM" || major === "GM") { major = getUpdatedMajor(major);
major = "IM";
}
return `${major} — Toutes filières confondues`; return `${major} — Toutes filières confondues`;
}); });
return [...new Set(realMinors), ...extraMinors]; return [...new Set(realMinors), ...extraMinors];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment