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

Fixed State in IDHM

parent ced1531a
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!68Fix dims in IDHM and IDHMR
Pipeline #
module.exports = function stateName(id) {
switch (id) {
case 11:
return 'Rondônia';
case 12:
return 'Acre';
case 13:
return 'Amazonas';
case 14:
return 'Roraima';
case 15:
return 'Pará';
case 16:
return 'Amapá';
case 17:
return 'Tocantins';
case 21:
return 'Maranhão';
case 22:
return'Piauí';
case 23:
return 'Ceará';
case 24:
return 'Rio Grande do Norte';
case 25:
return 'Paraíba';
case 26:
return 'Pernambuco';
case 27:
return 'Alagoas';
case 28:
return 'Sergipe';
case 29:
return 'Bahia';
case 31:
return 'Minas Gerais';
case 32:
return 'Espírito Santo';
case 33:
return 'Rio de Janeiro ';
case 35:
return 'São Paulo';
case 41:
return 'Paraná';
case 42:
return 'Santa Catarina';
case 43:
return 'Rio Grande do Sul';
case 50:
return 'Mato Grosso do Sul';
case 51:
return 'Mato Grosso';
case 52:
return 'Goiás';
case 53:
return 'Distrito Federal';
}
};
......@@ -15,6 +15,7 @@ const educationType = require(`${libs}/convert/educationType`);
const citySize = require(`${libs}/convert/citySize`);
const incomeLevel = require(`${libs}/convert/incomeLevel`);
const idhmLevel = require(`${libs}/convert/idhmLevel`);
const stateName = require(`${libs}/convert/stateName`);
const ids = {
gender_id: gender,
......@@ -62,7 +63,8 @@ const ids = {
education_type_id: educationType,
income_level_id: incomeLevel,
city_size_id: citySize,
idhm_level_id: idhmLevel
idhm_level_id: idhmLevel,
state_id: stateName
};
function transform(removeId=false) {
......
......@@ -132,13 +132,14 @@ rqf.addField({
idhmApp.get('/', rqf.parse(), (req, res, next) => {
log.debug(req.sql.toParam());
if((Object.keys(req.filter).length === 0) && (Object.keys(req.dims).length === 0)) {
res.status(400);
next({
status: 400,
message: 'Wrong/No filter specified'
});
}
if ("state" in req.filter && !("city" in req.filter)) {
req.sql.from('adh_idh_uf')
.field('adh_idh_uf.idhm', 'total')
.field('adh_idh_uf.ano_censo', 'year')
.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.filter && !("city" in req.filter)) {
req.sql.from('adh_idh_uf')
.field('adh_idh_uf.idhm', 'total')
.field('adh_idh_uf.ano_censo', 'year')
......@@ -157,10 +158,13 @@ idhmApp.get('/', rqf.parse(), (req, res, next) => {
.group('adh_idh.municipio_id')
.group('adh_idh.estado_id')
} else {
next({
status: 400,
message: 'Wrong/No filter specified'
});
req.sql.from('adh_idh_uf')
.field('adh_idh_uf.idhm', 'total')
.field('adh_idh_uf.ano_censo', 'year')
.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')
}
next();
}, rqf.build(), query, id2str.transform(), 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