Skip to content
Snippets Groups Projects
Commit f59c4775 authored by Fernando Erd's avatar Fernando Erd :ok_hand:
Browse files

Fix state and city filter in idhm

parent 119dea6f
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!60IDHMR and IDHM routes
Pipeline #
......@@ -99,15 +99,32 @@ rqf.addField({
field: 'ano_censo'
}
});
idhmApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
log.debug(req.sql.toParam());
req.sql.field('(adh_idh.idhm)', 'IDHM')
.field("'Brasil'", 'name')
.field('adh_idh.municipio_id', 'municipio_id')
.field('adh_idh.estado_id', 'estado_id')
.field('adh_idh.ano_censo', 'year')
.from('adh_idh')
next();
if(typeof req.filter === 'undefined' || Object.keys(req.filter).length === 0 ) {
res.status(400);
next({
status: 400,
message: 'Wrong/No filter specified'
});
}
if ("state" in req.filter) {
req.sql.field('(adh_idh_uf.idhm)', 'IDHM')
.field("'Brasil'", 'name')
.field('adh_idh_uf.estado_id', 'estado_id')
.field('adh_idh_uf.ano_censo', 'year')
.from('adh_idh_uf')
} else if ("city" in req.filter) {
req.sql.field('(adh_idh.idhm)', 'IDHM')
.field("'Brasil'", 'name')
.field('adh_idh.municipio_id', 'municipio_id')
.field('adh_idh.estado_id', 'estado_id')
.field('adh_idh.ano_censo', 'year')
.from('adh_idh')
}
next();
}, query, id2str.transform(true), response('idhm'));
module.exports = idhmApp;
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