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

Fix bug with state and country aggregation in classroom_count

Related: simcaq/SCRUM#408
parent 3a3bf614
No related branches found
No related tags found
2 merge requests!162V1.8.0,!159Issue/408
Pipeline #17943 failed
...@@ -534,10 +534,11 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ...@@ -534,10 +534,11 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
continue; continue;
} }
// Fazer "merge" do array education_level // Faz "merge" do array education_level
// Se a localidade atual não tem o vetor
if(currentLocation.education_level.length == 0) { if(currentLocation.education_level.length == 0) {
currentLocation.education_level = [...cityLocation.education_level]; currentLocation.education_level = [...cityLocation.education_level];
} else { } else { // Caso já tenha, atualiza os valores
let l = 0; let l = 0;
while(l < cityLocation.education_level.length) { while(l < cityLocation.education_level.length) {
let cityEducation = cityLocation.education_level[l]; let cityEducation = cityLocation.education_level[l];
...@@ -557,6 +558,42 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ...@@ -557,6 +558,42 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
currentEducation.enrollment.day_classes += cityEducation.enrollment.day_classes; currentEducation.enrollment.day_classes += cityEducation.enrollment.day_classes;
currentEducation.enrollment.night_classes += cityEducation.enrollment.night_classes; currentEducation.enrollment.night_classes += cityEducation.enrollment.night_classes;
currentEducation.enrollment.total_classrooms_needed += cityEducation.enrollment.total_classrooms_needed; currentEducation.enrollment.total_classrooms_needed += cityEducation.enrollment.total_classrooms_needed;
if((typeof cityEducation.classes_school_year !== 'undefined') && (typeof currentEducation.classes_school_year !== 'undefined')) {
let n = 0;
let o = 0;
let cityClass = null;
let currentClass = null;
while((typeof cityClass !== 'undefined') && (typeof currentClass !== 'undefined')) {
cityClass = cityEducation.classes_school_year[o];
currentClass = currentEducation.classes_school_year[n];
// Se a série escolar é menor que a atual, ela não está no vetor, pois o vetor está ordenado e tem range limitado
if(cityClass.school_year_id < currentClass.school_year_id) {
currentEducation.classes_school_year.splice(n, 0, cityClass);
++o;
continue;
} else if(cityClass.school_year_id > currentClass.school_year_id) {
currentClass = currentEducation.classes_school_year[++n];
// Se o ano escolar da cidade é maior que a localidade do objeto atual E o vetor de ano escolar do objeto atual
// acaba, então este ano escolar falta no objeto atual, pois os anos escolares estão ordenados
if(typeof currentClass == 'undefined' && typeof cityClass !== 'undefined') {
currentEducation.classes_school_year[n] = cityClass;
currentClass = currentEducation.classes_school_year[n];
}
continue;
}
currentClass.total_enrollment_day += cityClass.total_enrollment_day;
currentClass.total_enrollment_night += cityClass.total_enrollment_night;
currentClass.full_period_classes += cityClass.full_period_classes;
currentClass.day_classes += cityClass.day_classes;
currentClass.night_classes += cityClass.night_classes;
currentClass.total_classrooms_needed += cityClass.total_classrooms_needed;
cityClass = cityEducation.classes_school_year[++o];
}
}
} else { } else {
if(currentEducation.education_level_short_id < cityEducation.education_level_short_id) { if(currentEducation.education_level_short_id < cityEducation.education_level_short_id) {
currentLocation.education_level.splice(++m, 0, cityEducation); currentLocation.education_level.splice(++m, 0, cityEducation);
......
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