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

Dims & Filters fixed

parent c9feaabd
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!60IDHMR and IDHM routes
Pipeline #
......@@ -86,12 +86,12 @@ rqf.addField({
relation: '=',
type: 'integer',
field: 'estado_id',
table: 'adh_idh_uf'
table: '@'
},
join: {
primary: 'id',
foreign: 'estado_id',
foreignTable: 'adh_idh_uf'
foreignTable: '@'
}
}).addValue({
name: 'min_year',
......@@ -115,12 +115,23 @@ rqf.addField({
table: '@',
field: 'ano_censo'
}
}).addValue({
name: 'IDHM_level',
table: '@',
tableField: 'idhm_nivel',
resultField: 'idhm_nivel_id',
where: {
relation: '=',
type: 'integer',
table: '@',
field: 'idhm_nivel'
}
});
idhmApp.get('/', rqf.parse(), (req, res, next) => {
log.debug(req.sql.toParam());
if(typeof req.filter === 'undefined' || Object.keys(req.filter).length === 0 ) {
if((Object.keys(req.filter).length === 0) && (Object.keys(req.dims).length === 0)) {
res.status(400);
next({
status: 400,
......@@ -128,16 +139,43 @@ idhmApp.get('/', rqf.parse(), (req, res, next) => {
});
}
if ("state" in req.filter) {
console.log("BBBBB");
req.sql.from('adh_idh_uf')
.field('adh_idh_uf.idhm', 'IDHM')
.field('adh_idh_uf.ano_censo', 'year')
.field('adh_idh_uf.estado_id', 'state_id');
.field('adh_idh_uf.estado_id', 'state_id')
.group('adh_idh_uf.idhm')
.group('adh_idh_uf.ano_censo')
.group('adh_idh_uf.estado_id')
} else if ("state" in req.dims) {
console.log("AAAAAAAAA");
req.sql.from('adh_idh')
.field('adh_idh.idhm', 'IDHM')
.field('adh_idh.ano_censo', 'year')
.field('adh_idh.municipio_id', 'city_id')
.field('adh_idh.estado_id', 'state_id')
.group('adh_idh.idhm')
.group('adh_idh.ano_censo')
.group('adh_idh.municipio_id')
.group('adh_idh.estado_id')
} else if ("city" in req.filter) {
req.sql.from('adh_idh')
.field('adh_idh.idhm', 'IDHM')
.field('adh_idh.ano_censo', 'year')
.field('adh_idh.municipio_id', 'city_id');
}
.field('adh_idh.municipio_id', 'city_id')
.group('adh_idh.idhm')
.group('adh_idh.ano_censo')
.group('adh_idh.municipio_id')
} else if ("city" in req.dims) {
req.sql.from('adh_idh')
.field('adh_idh.idhm', 'IDHM')
.field('adh_idh.ano_censo', 'year')
.field('adh_idh.municipio_id', 'city_id')
.group('adh_idh.idhm')
.group('adh_idh.ano_censo')
.group('adh_idh.municipio_id')
.group('adh_idh.estado_id')
}
next();
}, rqf.build(),query, response('idhm'));
......
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