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

Merge branch 'hotfix_liquid' into v1.1.1

parents c2e0970b e1ba546f
......@@ -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();
......
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