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

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

Fix issue 953

See merge request !452
parents 8f348ce3 22690a1e
Branches
No related tags found
4 merge requests!501[hotfix] capital filter working for superior education conclusion tax...,!499[hotfix] capital filter working for superior education conclusion tax...,!454Development,!452Fix issue 953
/*
Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
This file is part of simcaq-node.
simcaq-node is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
simcaq-node is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with simcaq-node. If not, see <https://www.gnu.org/licenses/>.
*/
module.exports = function ageRange19to64(id) {
switch (id) {
case 6:
return '19 a 24 anos';
case 7:
return '25 a 29 anos';
case 8:
return '30 a 40 anos';
case 9:
return '41 a 50 anos';
case 10:
return '51 a 64 anos';
case 11:
return 'Mais que 64 anos';
default:
return 'Não declarada';
}
};
...@@ -129,6 +129,7 @@ const educationDegreeEntity = require(`${libs}/convert/educationDegreeEntity`); ...@@ -129,6 +129,7 @@ const educationDegreeEntity = require(`${libs}/convert/educationDegreeEntity`);
const expenses = require(`${libs}/convert/expenses.js`) const expenses = require(`${libs}/convert/expenses.js`)
const revenue = require(`${libs}/convert/revenue`); const revenue = require(`${libs}/convert/revenue`);
const studentCost = require(`${libs}/convert/studentCost`); const studentCost = require(`${libs}/convert/studentCost`);
const ageRange19to64 = require(`${libs}/convert/ageRange19to64`);
const ids = { const ids = {
gender_id: gender, gender_id: gender,
...@@ -250,7 +251,8 @@ const ids = { ...@@ -250,7 +251,8 @@ const ids = {
education_degree_entity: educationDegreeEntity, education_degree_entity: educationDegreeEntity,
despesas_id: expenses, despesas_id: expenses,
receitas_id: revenue, receitas_id: revenue,
student_cost: studentCost student_cost: studentCost,
age_range_19_to_64_id: ageRange19to64
}; };
function transform(removeId=false) { function transform(removeId=false) {
...@@ -260,7 +262,6 @@ function transform(removeId=false) { ...@@ -260,7 +262,6 @@ function transform(removeId=false) {
} }
// Para cada objeto do resultado // Para cada objeto do resultado
req.result.forEach((obj) => { req.result.forEach((obj) => {
console.log(obj),
Object.keys(obj).forEach((key) => { Object.keys(obj).forEach((key) => {
// Se não há uma função especificada, retorna // Se não há uma função especificada, retorna
if(typeof ids[key] === 'undefined') return; if(typeof ids[key] === 'undefined') return;
...@@ -395,5 +396,6 @@ module.exports = { ...@@ -395,5 +396,6 @@ module.exports = {
educationDegreeEntity, educationDegreeEntity,
expenses, expenses,
revenue, revenue,
studentCost studentCost,
ageRange19to64
}; };
...@@ -120,7 +120,6 @@ basicEducationConclusion.get('/cap_code', (req, res, next) => { ...@@ -120,7 +120,6 @@ basicEducationConclusion.get('/cap_code', (req, res, next) => {
}); });
} }
} }
req.result.push({id: 99, name: id2str.capitalCode(99)});
next(); next();
}, response('cap_code')); }, response('cap_code'));
...@@ -159,7 +158,7 @@ basicEducationConclusion.get('/income_range', (req, res, next) => { ...@@ -159,7 +158,7 @@ basicEducationConclusion.get('/income_range', (req, res, next) => {
id: i, name: id2str.incomeRange(i) id: i, name: id2str.incomeRange(i)
}); });
} }
req.result.push({id: 10, name: id2str.incomeRange(10)}); req.result.push({ id: 9, name: id2str.incomeRange(9) });
next(); next();
}, response('income_range')); }, response('income_range'));
...@@ -242,16 +241,16 @@ basicEducationConclusion.get('/state', (req, res, next) => { ...@@ -242,16 +241,16 @@ basicEducationConclusion.get('/state', (req, res, next) => {
next(); next();
}, response('state')); }, response('state'));
basicEducationConclusion.get('/age_range_all', (req, res, next) => { basicEducationConclusion.get('/age_range_19_to_64', (req, res, next) => {
req.result = [] req.result = []
for (let i = 1; i < 12; i++) { for (let i = 6; i <= 11; i++) {
req.result.push({ req.result.push({
id: i, name: id2str.ageRangeAll(i) id: i, name: id2str.ageRange19to64(i)
}); });
} }
next(); next();
}, response('age_range_all')); }, response('age_range_19_to_64'));
basicEducationConclusion.get('/location', (req, res, next) => { basicEducationConclusion.get('/location', (req, res, next) => {
req.result = [] req.result = []
...@@ -414,10 +413,10 @@ rqf.addField({ ...@@ -414,10 +413,10 @@ rqf.addField({
field: 'cor_raca' field: 'cor_raca'
} }
}).addValue({ }).addValue({
name: 'age_range_all', name: 'age_range_19_to_64',
table: 'pnad_novo', table: 'pnad_novo',
tableField: 'faixa_etaria', tableField: 'faixa_etaria',
resultField: 'age_range_all_id', resultField: 'age_range_19_to_64_id',
where: { where: {
relation: '=', relation: '=',
type: 'integer', type: 'integer',
...@@ -426,12 +425,12 @@ rqf.addField({ ...@@ -426,12 +425,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: 'gender', name: 'gender',
...@@ -599,9 +598,8 @@ basicEducationConclusion.get('/', rqf.parse(), rqf.build(), (req, res, next) => ...@@ -599,9 +598,8 @@ basicEducationConclusion.get('/', rqf.parse(), rqf.build(), (req, res, next) =>
.group("ano_ref") .group("ano_ref")
.order("ano_ref"); .order("ano_ref");
if (req.query.dims && req.query.dims.includes("income_range")) { if (req.query.dims && req.query.dims.includes("cap_code")) {
totalPopMaior19.where("faixa_rendimento_aux_tx is not null"); totalPopMaior19.where("cod_cap < 99");
totalPopEdBasMaior19.where("faixa_rendimento_aux_tx is not null");
} }
req.querySet.push(totalPopEdBasMaior19); req.querySet.push(totalPopEdBasMaior19);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment