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

feat: add age range conversion for 19 to 64 years and update related routes

parent 089976d8
No related branches found
No related tags found
1 merge request!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';
}
};
......@@ -128,6 +128,7 @@ const totalDoc = require(`${libs}/convert/totalDoc`);
const educationDegreeEntity = require(`${libs}/convert/educationDegreeEntity`);
const revenue = require(`${libs}/convert/revenue`);
const studentCost = require(`${libs}/convert/studentCost`);
const ageRange19to64 = require(`${libs}/convert/ageRange19to64`);
const ids = {
gender_id: gender,
......@@ -248,7 +249,8 @@ const ids = {
total_doc: totalDoc,
education_degree_entity: educationDegreeEntity,
receitas_id: revenue,
student_cost: studentCost
student_cost: studentCost,
age_range_19_to_64_id: ageRange19to64
};
function transform(removeId=false) {
......@@ -258,7 +260,6 @@ function transform(removeId=false) {
}
// Para cada objeto do resultado
req.result.forEach((obj) => {
console.log(obj),
Object.keys(obj).forEach((key) => {
// Se não há uma função especificada, retorna
if(typeof ids[key] === 'undefined') return;
......@@ -392,5 +393,6 @@ module.exports = {
totalDoc,
educationDegreeEntity,
revenue,
studentCost
studentCost,
ageRange19to64
};
......@@ -242,16 +242,16 @@ basicEducationConclusion.get('/state', (req, res, next) => {
next();
}, response('state'));
basicEducationConclusion.get('/age_range_all', (req, res, next) => {
basicEducationConclusion.get('/age_range_19_to_64', (req, res, next) => {
req.result = []
for (let i = 1; i < 12; i++) {
for (let i = 6; i <= 11; i++) {
req.result.push({
id: i, name: id2str.ageRangeAll(i)
id: i, name: id2str.ageRange19to64(i)
});
}
next();
}, response('age_range_all'));
}, response('age_range_19_to_64'));
basicEducationConclusion.get('/location', (req, res, next) => {
req.result = []
......@@ -414,10 +414,10 @@ rqf.addField({
field: 'cor_raca'
}
}).addValue({
name: 'age_range_all',
name: 'age_range_19_to_64',
table: 'pnad_novo',
tableField: 'faixa_etaria',
resultField: 'age_range_all_id',
resultField: 'age_range_19_to_64_id',
where: {
relation: '=',
type: 'integer',
......
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