diff --git a/src/libs/convert/ageRange19to64.js b/src/libs/convert/ageRange19to64.js new file mode 100644 index 0000000000000000000000000000000000000000..470208675967b09f129effcdfe114f7386a02219 --- /dev/null +++ b/src/libs/convert/ageRange19to64.js @@ -0,0 +1,38 @@ +/* +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'; + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index 730d620e18c1bc1708af165eebd5de1b3a54c931..e144fb97466631e6f4c542d62d59e0eab215d80e 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -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 }; diff --git a/src/libs/routes_v1/basicEducationConclusion.js b/src/libs/routes_v1/basicEducationConclusion.js index fb7452990b4a1be888247802cea0e9e424af606c..0d84822cfc99e566f6615672b1a7534b48bef008 100644 --- a/src/libs/routes_v1/basicEducationConclusion.js +++ b/src/libs/routes_v1/basicEducationConclusion.js @@ -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',