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.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
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
### Changed
- Add state id in infrastructure
......
......@@ -184,7 +184,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
.from('matricula')
.group('matricula.ano_censo')
.order('matricula.ano_censo')
.where('matricula.tipo<=3');
.where('matricula.tipo<=3')
.where('matricula.dependencia_adm_id < 4');
next();
}, rqf.build(), query, id2str.transform(), (req, res, next) => {
......@@ -225,7 +226,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
.from('escola')
.group('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();
}, rqf.build(), query, id2str.transform(), (req, res, next) => {
......@@ -243,6 +245,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
let j = 0;
let result = [];
let hashSet = new Set();
let enrollments = [...req.enrollment];
while (i < req.classroom.length) {
let classroom = req.classroom[i];
// Cria hash única para cada espacialidade, dado um ano
......@@ -282,14 +285,15 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
let enrollmentMatch = true;
j = 0;
let educationLevelSet = new Set();
while(enrollmentMatch && j < req.enrollment.length) {
let enrollment = req.enrollment[j];
let enrollment = enrollments[j];
while(enrollmentMatch && j < enrollments.length) {
enrollment = enrollments[j];
if(typeof enrollment === 'undefined') {
enrollmentMatch = false;
++j;
continue;
}
if(enrollment.city_id != classroom.city_id) { // Se as cidades não são iguais, já passamos do range
enrollmentMatch = false;
++j;
continue;
}
......@@ -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)
if(enrollment.period_id == null) {
req.enrollment.splice(j, 1);
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)
req.enrollment.splice(j, 1);
enrollments.splice(j, 1);
// Cria a etapa de ensino adequada
let enrollmentEducationLevel = req.educationSchoolYear[enrollment.school_year_id];
......@@ -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);
enrollment = enrollments[j];
}
// Calculamos o total classroom be built para o município usando reduce
......@@ -487,7 +492,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
}
}
req.result = reduction || result;
req.result = /*{result, enrollments} //*/ 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