Skip to content

Commit

Permalink
Develop (#50)
Browse files Browse the repository at this point in the history
* Handle JSON.parse errors

* Handle Grado SyS 2024

* v6.3.9
  • Loading branch information
pablomatiasgomez committed Aug 1, 2023
1 parent 29816cc commit edb6861
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
15 changes: 13 additions & 2 deletions js/guarani/DataCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ UtnBaHelper.DataCollector = function (store, pagesDataParser, apiConnector) {
},
];

let shouldSaveLastTimeCollected = false;
let promise = Promise.resolve();
collectMethods.filter(collectMethod => {
// Never collected or min time has passed.
Expand All @@ -53,12 +54,16 @@ UtnBaHelper.DataCollector = function (store, pagesDataParser, apiConnector) {
promise = promise.then(() => {
return collectMethod.method();
}).then(() => {
// If at least one collect method is executed, we need to save the last time collected info to local storage.
shouldSaveLastTimeCollected = true;
lastTimeCollected[collectMethod.key] = Date.now();
});
});

return promise.then(() => {
saveLastTimeCollected(hashedStudentId, lastTimeCollected);
if (shouldSaveLastTimeCollected) {
saveLastTimeCollected(hashedStudentId, lastTimeCollected);
}
});
});
};
Expand All @@ -78,7 +83,13 @@ UtnBaHelper.DataCollector = function (store, pagesDataParser, apiConnector) {
// -----

let getLastTimeCollectedByHashedStudentId = function () {
let lastTimeCollectedByHashedStudentId = JSON.parse(localStorage.getItem(LOCAL_STORAGE_DATA_COLLECTOR_KEY));
let lastTimeCollectedByHashedStudentId;
try {
// Don't know why, but some cases were failing with json parsing errors... We simply consider those as not present.
lastTimeCollectedByHashedStudentId = JSON.parse(localStorage.getItem(LOCAL_STORAGE_DATA_COLLECTOR_KEY));
} catch (e) {
console.error(`Error parsing localStorage item...`, e);
}
if (!lastTimeCollectedByHashedStudentId) {
lastTimeCollectedByHashedStudentId = {};
localStorage.setItem(LOCAL_STORAGE_DATA_COLLECTOR_KEY, JSON.stringify(lastTimeCollectedByHashedStudentId));
Expand Down
4 changes: 3 additions & 1 deletion js/guarani/PagesDataParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ UtnBaHelper.PagesDataParser = function (utils) {
"Anual": "A",
"Primer Cuatrimestre": "1C",
"Segundo Cuatrimestre": "2C",
"ASS": "A", // Weird case, was found in "Grado ASS 2022" (seems to be specific to courseCode: 950454)
// Weird cases, was found in "Grado ASS 2022", and "Grado SyS 2024" (seems to be specific to courseCode: 950454 -> "Análisis de Señales y Sistemas")
"ASS": "A",
"SyS": "A",
};
const yearAndQuarterRegex = new RegExp(`^Grado (${Object.keys(quarterTxtMapping).join("|")}) (\\d{4})$`);
let groups = yearAndQuarterRegex.exec(periodTxt);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "UTN.BA Helper (ex Siga Helper)",
"short_name": "UTN.BA Helper",
"version": "6.3.8",
"version": "6.3.9",
"description": "UTN.BA Helper facilita el uso de la web de la UTN - FRBA.",
"author": "Pablo Matías Gomez",
"icons": {
Expand Down

0 comments on commit edb6861

Please sign in to comment.