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

Merge branch 'v1.1.1'

Merges !127
parents c2e0970b f7331f0f
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -4,6 +4,12 @@ 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.1.1 - 2018-05-10
### Changed
- Fix bug in gloss enrollment ratio route
- Fix bug in liquid enrollment ratio route
## 1.1.0 - 2018-05-02
### Added
- Out of school population indicator
......
......@@ -298,7 +298,13 @@ glossEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => {
.field('matricula.ano_censo', 'year')
.group('matricula.ano_censo')
.order('matricula.ano_censo')
.where('matricula.tipo <= 3')
if ( "education_level_basic" in req.dims ) {
req.sql.field('matricula.etapas_mod_ensino_segmento_id', 'age_range')
req.sql.where('matricula.etapas_mod_ensino_segmento_id = 1 OR matricula.etapas_mod_ensino_segmento_id = 2 OR matricula.etapas_mod_ensino_segmento_id = 4 OR matricula.etapas_mod_ensino_segmento_id = 5 OR matricula.etapas_mod_ensino_segmento_id = 6')
req.sql.group('matricula.etapas_mod_ensino_segmento_id', 'age_range');
}
next();
}, rqf.build(), query, id2str.transform(), (req, res, next) => {
req.numerator = req.result;
......@@ -332,9 +338,13 @@ glossEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => {
}
string_query = string_query + convert(req.filter.education_level_basic[req.filter.education_level_basic.length - 1]);
req.sql.where(string_query);
} else {
req.sql.where(convert(req.filter.education_level_basic));
req.sql.field('pnad.faixa_etaria_31_03','age_range')
req.sql.group('pnad.faixa_etaria_31_03', 'age_range')
}
} else if ( "education_level_basic" in req.dims ) {
req.sql.field('pnad.faixa_etaria_31_03','age_range')
req.sql.where('pnad.faixa_etaria_31_03 = 1 OR pnad.faixa_etaria_31_03 = 2 OR pnad.faixa_etaria_31_03 = 3 OR pnad.faixa_etaria_31_03 = 4 OR pnad.faixa_etaria_31_03 = 5')
req.sql.group('pnad.faixa_etaria_31_03', 'age_range');
} else {
res.status(400);
next({
......@@ -354,7 +364,16 @@ glossEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => {
next();
}, rqf.build(), query, id2str.transform(), (req, res, next) => {
req.denominator = req.result;
//change age range in denominator to match with numerator result
for(let i = 0; i < req.denominator.length; i++) {
if (req.denominator[i].age_range > 2) {
req.denominator[i].age_range = req.denominator[i].age_range + 1;
}
}
// log.debug("Numerador");
// log.debug(req.numerator);
// log.debug("Denominador");
// log.debug(req.denominator);
req.result = []
let glossEnrollment = matchQueries(req.denominator, req.numerator);
req.result = glossEnrollment;
......
......@@ -299,18 +299,19 @@ liquidEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => {
.field('matricula.ano_censo', 'year')
.group('matricula.ano_censo')
.order('matricula.ano_censo')
.where('matricula.tipo <= 3')
function ConvertMatricula(result) {
if (result == 1) {
return 'matricula.faixa_etaria_31_03 = 1'
return '(matricula.faixa_etaria_31_03 = 1 AND matricula.etapas_mod_ensino_segmento_id = 1)'
} else if (result == 2) {
return 'matricula.faixa_etaria_31_03 = 2'
return '(matricula.faixa_etaria_31_03 = 2 AND matricula.etapas_mod_ensino_segmento_id = 2)'
} else if (result == 4) {
return 'matricula.faixa_etaria_31_03 = 3'
return '(matricula.faixa_etaria_31_03 = 3 AND matricula.etapas_mod_ensino_segmento_id = 4)'
} else if (result == 5) {
return 'matricula.faixa_etaria_31_03 = 4'
return '(matricula.faixa_etaria_31_03 = 4 AND matricula.etapas_mod_ensino_segmento_id = 5)'
} else if (result == 6) {
return 'matricula.faixa_etaria_31_03 = 5'
return '(matricula.faixa_etaria_31_03 = 5 AND matricula.etapas_mod_ensino_segmento_id = 6)'
}
}
if ("education_level_basic" in req.filter) {
......@@ -318,12 +319,18 @@ liquidEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => {
var string_query_enrollment = '';
for(let i = 0; i < req.filter.education_level_basic.length - 1; i++) {
string_query_enrollment = string_query_enrollment + ConvertMatricula(req.filter.education_level_basic[i]) + ' OR ';
}
string_query_enrollment = string_query_enrollment + ConvertMatricula(req.filter.education_level_basic[req.filter.education_level_basic.length - 1]);
req.sql.where(string_query_enrollment);
} else {
req.sql.where(ConvertMatricula(req.filter.education_level_basic));
}
string_query_enrollment = string_query_enrollment + ConvertMatricula(req.filter.education_level_basic[req.filter.education_level_basic.length - 1]);
delete req.filter.education_level_basic;
req.sql.where(string_query_enrollment);
req.sql.field('matricula.faixa_etaria_31_03', 'age_range')
req.sql.group('matricula.faixa_etaria_31_03', 'age_range');
}
} else if ( "education_level_basic" in req.dims ) {
req.sql.field('matricula.faixa_etaria_31_03', 'age_range')
req.sql.where('(matricula.etapas_mod_ensino_segmento_id = 1 AND matricula.faixa_etaria_31_03 = 1) OR (matricula.etapas_mod_ensino_segmento_id = 2 AND matricula.faixa_etaria_31_03 = 2) OR (matricula.etapas_mod_ensino_segmento_id = 4 AND matricula.faixa_etaria_31_03 = 3) OR (matricula.etapas_mod_ensino_segmento_id = 5 AND matricula.faixa_etaria_31_03 = 4) OR (matricula.etapas_mod_ensino_segmento_id = 6 AND matricula.faixa_etaria_31_03 = 5)');
req.sql.group('matricula.faixa_etaria_31_03', 'age_range');
} else {
res.status(400);
next({
......@@ -365,9 +372,19 @@ liquidEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => {
}
string_query = string_query + convertPnad(req.filter.education_level_basic[req.filter.education_level_basic.length - 1]);
req.sql.where(string_query);
} else {
req.sql.where(convertPnad(req.filter.education_level_basic));
}
req.sql.field('pnad.faixa_etaria_31_03', 'age_range')
req.sql.group('pnad.faixa_etaria_31_03', 'age_range');
} else if ( "education_level_basic" in req.dims ) {
req.sql.field('pnad.faixa_etaria_31_03','age_range')
req.sql.where('pnad.faixa_etaria_31_03 = 1 OR pnad.faixa_etaria_31_03 = 2 OR pnad.faixa_etaria_31_03 = 3 OR pnad.faixa_etaria_31_03 = 4 OR pnad.faixa_etaria_31_03 = 5')
req.sql.group('pnad.faixa_etaria_31_03', 'age_range');
} else {
res.status(400);
next({
status: 400,
message: 'Wrong/No filter specified'
});
}
next();
......
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