Skip to content

Commit

Permalink
added ignore module pattern to calculate the first semester, solves e…
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo1212 committed Feb 15, 2022
1 parent d364416 commit 05c98de
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/components/module_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const updateModuleTypeList = async (oldModuleTypeList, jsonFilePath) => {
return Object.assign(oldModuleTypeList, patch);
}



const ModuleParser = {

/**
Expand Down Expand Up @@ -129,6 +131,22 @@ const ModuleParser = {
}
return false
},
/**
* list of modules that should be ignored to calculate the first semester
* check if moduleName matches ignore pattern
*/
shouldModuleBeIgnored: (hsluModuleName) => {
const ignoreModulePatterns = ['INFO_ABEND'];
let dontIgnore = true;
ignoreModulePatterns.forEach(ignorePattern => {
if(hsluModuleName.includes(ignorePattern)) {
console.log(`ignoring module ${hsluModuleName} for first semester calculation`)
dontIgnore = false;
}
})

return dontIgnore;
},
/**
* Generates an array of module objects using the API and the module type mapping json file.
*/
Expand Down Expand Up @@ -157,6 +175,8 @@ const ModuleParser = {
firstModule = anlasslistApiResponse.items
.slice()
.reverse()
//check if module is is in the ignore list
.filter(modul => ModuleParser.shouldModuleBeIgnored(modul.anlassnumber))
.find(modul => ModuleParser.isAutumnSemester(modul.anlassnumber) != undefined);

const passedMessage = await i18n.getMessage("Bestanden");
Expand Down Expand Up @@ -202,7 +222,7 @@ const ModuleParser = {
// sets the UseInStats to true by default
parsedModule.UseInStats = true;
if (ignoreInStatsModules != undefined && ignoreInStatsModules[parsedModule.name]) {
parsedModule.UseInStats = false;
parsedModule.UseInStats = false;
}
myCampusModulesList[parsedModule.name] = {
acronym: parsedModule.name,
Expand Down

0 comments on commit 05c98de

Please sign in to comment.