Commit c3545d77 authored by Fernando Erd's avatar Fernando Erd 👌

Fix dims in gloss enrollment ratio

parent 601259ee
Pipeline #14836 failed with stage
in 60 minutes and 5 seconds
......@@ -298,7 +298,11 @@ glossEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => {
.field('matricula.ano_censo', 'year')
.group('matricula.ano_censo')
.order('matricula.ano_censo')
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 +336,11 @@ 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));
}
} 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 +360,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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment