diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 5c77b66b5ad2a9056498b37042f7abbf3e0b07cb..c258ba03f471d0e8b4d49b98a30dd4145ba76b48 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -808,7 +808,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let city = result[i]; let obj = { year: city.year, - name: city.name + name: city.name, + count: 1 } if(req.dims.state) { @@ -828,6 +829,16 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { currentObj = obj; } else { // Está ordenado, podemos pegar o último currentObj = reduction[reduction.length - 1]; + currentObj.count++; + } + + if (currentObj.count == 1) + currentObj.percentage_teacher_career = city.percentage_teacher_career + else { + // Incrementa valores percentuais de cada nivel de carreira no objeto atual + currentObj.percentage_teacher_career.forEach((item, ind, thisArr) => { + thisArr[ind].percentage += city.percentage_teacher_career[ind].percentage + }) } // Fazer "merge" do array locations da cidade com o da agregação @@ -974,6 +985,10 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ++i; } for (let state of reduction){ + state.percentage_teacher_career.forEach((item, ind, thisArr) => { + thisArr[ind] /= state.count; + }) + delete state.count for (let location of state.locations){ for (let educationLevel of location.education_level){ let total = educationLevel.enrollment.integral_time_total;