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

Merge branch 'hotfix_1.2.2' into development

parents f70a7374 789d62cf
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ...@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## 1.2.2 - 2018-05-22
### Changed
- Fixed bug with missing education levels in classroom count
## 1.2.1 - 2018-05-22 ## 1.2.1 - 2018-05-22
### Changed ### Changed
- Add state id in infrastructure - Add state id in infrastructure
......
...@@ -184,7 +184,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ...@@ -184,7 +184,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
.from('matricula') .from('matricula')
.group('matricula.ano_censo') .group('matricula.ano_censo')
.order('matricula.ano_censo') .order('matricula.ano_censo')
.where('matricula.tipo<=3'); .where('matricula.tipo<=3')
.where('matricula.dependencia_adm_id < 4');
next(); next();
}, rqf.build(), query, id2str.transform(), (req, res, next) => { }, rqf.build(), query, id2str.transform(), (req, res, next) => {
...@@ -225,7 +226,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ...@@ -225,7 +226,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
.from('escola') .from('escola')
.group('escola.ano_censo') .group('escola.ano_censo')
.order('escola.ano_censo') .order('escola.ano_censo')
.where('escola.situacao_de_funcionamento = 1 AND escola.local_func_predio_escolar = 1'); .where('escola.situacao_de_funcionamento = 1 AND escola.local_func_predio_escolar = 1')
.where('escola.dependencia_adm_id < 4');
next(); next();
}, rqf.build(), query, id2str.transform(), (req, res, next) => { }, rqf.build(), query, id2str.transform(), (req, res, next) => {
...@@ -243,6 +245,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ...@@ -243,6 +245,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
let j = 0; let j = 0;
let result = []; let result = [];
let hashSet = new Set(); let hashSet = new Set();
let enrollments = [...req.enrollment];
while (i < req.classroom.length) { while (i < req.classroom.length) {
let classroom = req.classroom[i]; let classroom = req.classroom[i];
// Cria hash única para cada espacialidade, dado um ano // Cria hash única para cada espacialidade, dado um ano
...@@ -282,14 +285,15 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ...@@ -282,14 +285,15 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
let enrollmentMatch = true; let enrollmentMatch = true;
j = 0; j = 0;
let educationLevelSet = new Set(); let educationLevelSet = new Set();
while(enrollmentMatch && j < req.enrollment.length) { let enrollment = enrollments[j];
let enrollment = req.enrollment[j]; while(enrollmentMatch && j < enrollments.length) {
enrollment = enrollments[j];
if(typeof enrollment === 'undefined') { if(typeof enrollment === 'undefined') {
enrollmentMatch = false; ++j;
continue; continue;
} }
if(enrollment.city_id != classroom.city_id) { // Se as cidades não são iguais, já passamos do range if(enrollment.city_id != classroom.city_id) { // Se as cidades não são iguais, já passamos do range
enrollmentMatch = false; ++j;
continue; continue;
} }
...@@ -300,13 +304,13 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ...@@ -300,13 +304,13 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
// Remove se o período é nulo (não dá pra usar no cálculo) // Remove se o período é nulo (não dá pra usar no cálculo)
if(enrollment.period_id == null) { if(enrollment.period_id == null) {
req.enrollment.splice(j, 1); enrollments.splice(j, 1);
continue; continue;
} }
// Temos uma matrícula com cidade, ano e localidades certos // Temos uma matrícula com cidade, ano e localidades certos
// "Consome" a matrícula (remove do vetor de matrículas) // "Consome" a matrícula (remove do vetor de matrículas)
req.enrollment.splice(j, 1); enrollments.splice(j, 1);
// Cria a etapa de ensino adequada // Cria a etapa de ensino adequada
let enrollmentEducationLevel = req.educationSchoolYear[enrollment.school_year_id]; let enrollmentEducationLevel = req.educationSchoolYear[enrollment.school_year_id];
...@@ -377,6 +381,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ...@@ -377,6 +381,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
if(educationLevel.enrollment.night_classes > educationLevel.enrollment.day_classes) educationLevel.enrollment.total_classrooms_needed += (educationLevel.enrollment.night_classes - educationLevel.enrollment.day_classes); if(educationLevel.enrollment.night_classes > educationLevel.enrollment.day_classes) educationLevel.enrollment.total_classrooms_needed += (educationLevel.enrollment.night_classes - educationLevel.enrollment.day_classes);
enrollment = enrollments[j];
} }
// Calculamos o total classroom be built para o município usando reduce // Calculamos o total classroom be built para o município usando reduce
...@@ -487,7 +492,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ...@@ -487,7 +492,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
} }
} }
req.result = reduction || result; req.result = /*{result, enrollments} //*/ reduction || result;
next(); next();
}, response('classroom_count')); }, 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