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

Remove switch for location in enrollments route

parent 68946813
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!27Implement UC201 - Select Location
Pipeline #
...@@ -117,6 +117,10 @@ enrollmentApp.use('/', parseParams('filter', [ ...@@ -117,6 +117,10 @@ enrollmentApp.use('/', parseParams('filter', [
req.sql.join('municipio', null, 'fk_municipio_id = municipio.pk_cod_ibge'); req.sql.join('municipio', null, 'fk_municipio_id = municipio.pk_cod_ibge');
} }
if(typeof req.filter.location !== 'undefined' || typeof req.dims.location !== 'undefined') {
req.sql.join('localizacao', null, 'fk_localizacao_id = localizacao.pk_localizacao_id')
}
if(typeof req.dims.school !== 'undefined') { if(typeof req.dims.school !== 'undefined') {
req.sql.join('escola', null, 'turma.cod_entidade = escola.cod_entidade'); req.sql.join('escola', null, 'turma.cod_entidade = escola.cod_entidade');
} }
...@@ -169,9 +173,9 @@ enrollmentApp.use('/', parseParams('filter', [ ...@@ -169,9 +173,9 @@ enrollmentApp.use('/', parseParams('filter', [
} }
if(typeof req.dims.location !== 'undefined') { if(typeof req.dims.location !== 'undefined') {
req.sql.field('turma.fk_localizacao_id', 'location_name') req.sql.field('localizacao.descricao', 'location_name')
.group('turma.fk_localizacao_id') .group('localizacao.descricao')
.order('turma.fk_localizacao_id'); .order('localizacao.descricao');
} }
if(typeof req.dims.region === 'undefined' if(typeof req.dims.region === 'undefined'
...@@ -229,27 +233,6 @@ enrollmentApp.get('/', (req, res, next) => { ...@@ -229,27 +233,6 @@ enrollmentApp.get('/', (req, res, next) => {
.group('turma.ano_censo') .group('turma.ano_censo')
.order('turma.ano_censo'); .order('turma.ano_censo');
next(); next();
}, query, (req, res, next) => { }, query, response('enrollment'));
// 'Sanitize' result
let r = req.result;
r.forEach((data) => {
if(req.dims.location) {
if(data.location_name === 1) {
data.location_name = 'Urbana';
} else if (data.location_name === 2) {
data.location_name = 'Rural';
} else if (data.location_name === 3) {
data.location_name = 'Área de Assentamento';
} else if (data.location_name === 4) {
data.location_name = 'Terra Indígena';
} else if (data.location_name === 5) {
data.location_name = 'Área Remanescente de Quilombos';
} else if (data.location_name === 6) {
data.location_name = 'Unidade de uso sustentável';
}
}
});
next();
}, response('enrollment'));
module.exports = enrollmentApp; module.exports = enrollmentApp;
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