Skip to content
Snippets Groups Projects

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

Merged lgtg20 requested to merge fix-issue-935 into development
1 file
+ 59
3
Compare changes
  • Side-by-side
  • Inline
@@ -62,6 +62,34 @@ adjustedLiquidFrequency.get('/income_range', (req, res, next) => {
@@ -62,6 +62,34 @@ adjustedLiquidFrequency.get('/income_range', (req, res, next) => {
next();
next();
}, response('income_range'));
}, 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) => {
adjustedLiquidFrequency.get('/gender', (req, res, next) => {
req.result = []
req.result = []
for (let i = 1; i < 3; i++) {
for (let i = 1; i < 3; i++) {
@@ -152,6 +180,16 @@ rqf.addField({
@@ -152,6 +180,16 @@ rqf.addField({
foreign: 'cod_uf',
foreign: 'cod_uf',
foreignTable: 'pnad_novo'
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({
}).addValue({
name: 'bolsa_familia',
name: 'bolsa_familia',
table: 'pnad_novo',
table: 'pnad_novo',
@@ -175,12 +213,12 @@ rqf.addField({
@@ -175,12 +213,12 @@ rqf.addField({
}).addValue({
}).addValue({
name: 'income_range',
name: 'income_range',
table: 'pnad_novo',
table: 'pnad_novo',
tableField: 'faixa_rendimento_aux_tx',
tableField: 'faixa_rendimento_aux',
resultField: 'income_range_id',
resultField: 'income_range_id',
where: {
where: {
relation: '=',
relation: '=',
type: 'integer',
type: 'integer',
field: 'faixa_rendimento_aux_tx'
field: 'faixa_rendimento_aux'
}
}
}).addValue({
}).addValue({
name: 'age_range_all',
name: 'age_range_all',
@@ -202,6 +240,16 @@ rqf.addField({
@@ -202,6 +240,16 @@ rqf.addField({
type: 'integer',
type: 'integer',
field: 'sexo'
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({
}).addValue({
name: 'region',
name: 'region',
table: 'pnad_novo',
table: 'pnad_novo',
@@ -293,7 +341,9 @@ adjustedLiquidFrequency.get('/', rqf.parse(), (req, res, next) => {
@@ -293,7 +341,9 @@ adjustedLiquidFrequency.get('/', rqf.parse(), (req, res, next) => {
${dimensions.gender ? " AND total_pop.gender_id = pnad_novo.sexo" : ""}
${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.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.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
// Subquery: total_apoio_freq
@@ -337,6 +387,12 @@ adjustedLiquidFrequency.get('/', rqf.parse(), (req, res, next) => {
@@ -337,6 +387,12 @@ adjustedLiquidFrequency.get('/', rqf.parse(), (req, res, next) => {
if (dimensions.income_range)
if (dimensions.income_range)
mainQuery.field("total_apoio_freq.income_range_id")
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;
req.sql = mainQuery;
next();
next();
Loading