Skip to content
Snippets Groups Projects
Commit 40db46fd authored by Gabriel Ruschel's avatar Gabriel Ruschel
Browse files

Fix filters

parent 9b31c6d1
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!65Fix filters
Pipeline #
......@@ -90,12 +90,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: '@'
}
});
......@@ -107,22 +107,24 @@ idhmeApp.get('/', rqf.parse(), (req, res, next) => {
message: 'Wrong/No filter specified'
});
}
if ("state" in req.filter) {
// console.log("sim");
req.sql.from('adh_idh_uf')
.field('adh_idh_uf.idhm_e', 'total')
.field('adh_idh_uf.ano_censo', 'year')
.field('adh_idh_uf.estado_id', 'state_id');
} else if ("city" in req.filter) {
if (!("state" in req.filter) && !("city" in req.filter)) {
next({
status: 400,
message: 'Wrong/No filter specified'
});
}
if ("city" in req.filter) {
req.sql.from('adh_idh')
.field('adh_idh.idhm_e', 'total')
.field('adh_idh.ano_censo', 'year')
.field('adh_idh.municipio_id', 'city_id');
} else {
next({
status: 400,
message: 'Wrong/No filter specified'
});
// console.log("sim");
req.sql.from('adh_idh_uf')
.field('adh_idh_uf.idhm_e', 'total')
.field('adh_idh_uf.ano_censo', 'year')
.field('adh_idh_uf.estado_id', 'state_id');
}
next();
}, rqf.build(), query, response('idhme'));
......
......@@ -90,12 +90,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: '@'
}
});
......@@ -107,21 +107,23 @@ idhmlApp.get('/', rqf.parse(), (req, res, next) => {
message: 'Wrong/No filter specified'
});
}
if ("state" in req.filter) {
req.sql.from('adh_idh_uf')
.field('adh_idh_uf.idhm_l', 'total')
.field('adh_idh_uf.ano_censo', 'year')
.field('adh_idh_uf.estado_id', 'state_id');
} else if ("city" in req.filter) {
if (!("state" in req.filter) && !("city" in req.filter)) {
next({
status: 400,
message: 'Wrong/No filter specified'
});
}
if ("city" in req.filter) {
req.sql.from('adh_idh')
.field('adh_idh.idhm_l', 'total')
.field('adh_idh.ano_censo', 'year')
.field('adh_idh.municipio_id', 'city_id');
} else {
next({
status: 400,
message: 'Wrong/No filter specified'
});
// console.log("sim");
req.sql.from('adh_idh_uf')
.field('adh_idh_uf.idhm_l', 'total')
.field('adh_idh_uf.ano_censo', 'year')
.field('adh_idh_uf.estado_id', 'state_id');
}
next();
}, rqf.build(), query, response('idhml'));
......
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