Skip to content
Snippets Groups Projects
Commit e6226c7e authored by lgtg20's avatar lgtg20
Browse files

Merge branch 'fix-issue-935' into 'development'

feat: add cap_code and metro_code endpoints; update income_range field reference

See merge request !453
parents f32b9971 07cad15f
No related branches found
No related tags found
1 merge request!453feat: add cap_code and metro_code endpoints; update income_range field reference
......@@ -62,6 +62,34 @@ adjustedLiquidFrequency.get('/income_range', (req, res, next) => {
next();
}, response('income_range'));
adjustedLiquidFrequency.get('/cap_code', (req, res, next) => {
req.result = []
for (let i = 11; i < 54; i++) {
if (id2str.capitalCode(i) !== 'Não informado') {
req.result.push({
id: i, name: id2str.capitalCode(i)
});
}
}
req.result.push({id: 99, name: id2str.capitalCode(99)});
next();
}, response('cap_code'));
adjustedLiquidFrequency.get('/metro_code', (req, res, next) => {
req.result = []
for (let i = 13; i < 53; i++) {
if (id2str.metroCode(i) !== 'Não informado') {
req.result.push({
id: i, name: id2str.metroCode(i)
});
}
}
req.result.push({id: 99, name: id2str.metroCode(99)});
next();
}, response('metro_code'));
adjustedLiquidFrequency.get('/gender', (req, res, next) => {
req.result = []
for (let i = 1; i < 3; i++) {
......@@ -152,6 +180,16 @@ rqf.addField({
foreign: 'cod_uf',
foreignTable: 'pnad_novo'
}
}).addValue({
name: 'cap_code',
table: 'pnad_novo',
tableField: 'cod_cap',
resultField: 'cap_code_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_cap'
}
}).addValue({
name: 'bolsa_familia',
table: 'pnad_novo',
......@@ -175,12 +213,12 @@ rqf.addField({
}).addValue({
name: 'income_range',
table: 'pnad_novo',
tableField: 'faixa_rendimento_aux_tx',
tableField: 'faixa_rendimento_aux',
resultField: 'income_range_id',
where: {
relation: '=',
type: 'integer',
field: 'faixa_rendimento_aux_tx'
field: 'faixa_rendimento_aux'
}
}).addValue({
name: 'age_range_all',
......@@ -202,6 +240,16 @@ rqf.addField({
type: 'integer',
field: 'sexo'
}
}).addValue({
name: 'metro_code',
table: 'pnad_novo',
tableField: 'cod_rm_ride',
resultField: 'metro_code_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_rm_ride'
}
}).addValue({
name: 'region',
table: 'pnad_novo',
......@@ -293,7 +341,9 @@ adjustedLiquidFrequency.get('/', rqf.parse(), (req, res, next) => {
${dimensions.gender ? " AND total_pop.gender_id = pnad_novo.sexo" : ""}
${dimensions.bolsa_familia ? "AND total_pop.bolsa_familia_id = pnad_novo.recebeu_rendimentos_de_programa_bolsa_familia" : ""}
${dimensions.new_pnad_ethnic_group ? "AND total_pop.new_pnad_ethnic_group_id = pnad_novo.cor_raca" : ""}
${dimensions.income_range ? "AND total_pop.income_range_id = pnad_novo.faixa_rendimento_aux_tx" : ""}
${dimensions.income_range ? "AND total_pop.income_range_id = pnad_novo.faixa_rendimento_aux" : ""}
${dimensions.cap_code ? "AND total_pop.cap_code_id = pnad_novo.cod_cap" : ""}
${dimensions.metro_code ? "AND pnad_novo.cod_rm_ride <> 99 AND total_pop.metro_code_id = pnad_novo.cod_rm_ride" : ""}
`
// Subquery: total_apoio_freq
......@@ -337,6 +387,12 @@ adjustedLiquidFrequency.get('/', rqf.parse(), (req, res, next) => {
if (dimensions.income_range)
mainQuery.field("total_apoio_freq.income_range_id")
if (dimensions.cap_code)
mainQuery.field("total_apoio_freq.cap_code_id")
if (dimensions.metro_code)
mainQuery.field("total_apoio_freq.metro_code_id")
req.sql = mainQuery;
next();
......
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