Skip to content
Snippets Groups Projects
Commit 3de1afee authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Fix spare enrollments

parent 5d356af1
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -286,13 +286,25 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
j = 0;
let educationLevelSet = new Set();
let enrollment = enrollments[j];
// FIXME: Performance
while(enrollmentMatch && j < enrollments.length) {
enrollment = enrollments[j];
// Remove se o período é nulo (não dá pra usar no cálculo)
if(enrollment.period_id == null) {
enrollments.splice(j, 1);
continue;
}
if(typeof enrollment === 'undefined') {
++j;
continue;
}
if(enrollment.city_id != classroom.city_id) { // Se as cidades não são iguais, já passamos do range
if(classroom.city_name < enrollment.city_name) { // Se as cidades não são iguais, já passamos do range
enrollmentMatch = false;
continue;
} else if(classroom.city_name > enrollment.city_name) {
++j;
continue;
}
......@@ -302,11 +314,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
continue;
}
// Remove se o período é nulo (não dá pra usar no cálculo)
if(enrollment.period_id == null) {
enrollments.splice(j, 1);
continue;
}
// Temos uma matrícula com cidade, ano e localidades certos
// "Consome" a matrícula (remove do vetor de matrículas)
......@@ -499,7 +506,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
}
}
req.result = {result: reduction, enrollments} // reduction || result;
req.result = reduction || result;
next();
}, response('classroom_count'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment