From 585e6c363dca04c6a9678f557b3c28d2dfbf64d4 Mon Sep 17 00:00:00 2001 From: fgs21 <fgs21@inf.ufpr.br> Date: Fri, 16 Feb 2024 09:53:41 -0300 Subject: [PATCH] [ADD] filters 'attendModality, attendsSchool, capitalCode, ethnicGroupNewPnad, metroCode and regionCode' added to convert files and id2str --- src/libs/convert/attendedModality.js | 2 +- src/libs/convert/attendsSchool.js | 3 + src/libs/convert/capitalCode.js | 81 ++++++++++++++++++++++++++ src/libs/convert/ethnicGroupNewPnad.js | 36 ++++++++++++ src/libs/convert/metroCode.js | 68 +++++++++++++++++++++ src/libs/convert/regionCode.js | 34 +++++++++++ src/libs/middlewares/id2str.js | 17 +++++- src/libs/routes_v1/newPnad.js | 14 ++--- 8 files changed, 245 insertions(+), 10 deletions(-) create mode 100644 src/libs/convert/capitalCode.js create mode 100644 src/libs/convert/ethnicGroupNewPnad.js create mode 100644 src/libs/convert/metroCode.js create mode 100644 src/libs/convert/regionCode.js diff --git a/src/libs/convert/attendedModality.js b/src/libs/convert/attendedModality.js index be06810e..fd6162a5 100644 --- a/src/libs/convert/attendedModality.js +++ b/src/libs/convert/attendedModality.js @@ -18,7 +18,7 @@ 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 modality(id) { +module.exports = function attendedModality(id) { switch (id) { case 1: return 'Creche'; diff --git a/src/libs/convert/attendsSchool.js b/src/libs/convert/attendsSchool.js index 836e9fbd..c5192999 100644 --- a/src/libs/convert/attendsSchool.js +++ b/src/libs/convert/attendsSchool.js @@ -18,11 +18,14 @@ You should have received a copy of the GNU General Public License along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. */ +// This file is used to convert the attendsSchool AND 'bolsa_familia' variable to a human-readable format. module.exports = function attendsSchool(id) { switch (id) { case 1: return 'Sim'; case 2: return 'Não'; + case 9: + return 'Sem informação'; } }; diff --git a/src/libs/convert/capitalCode.js b/src/libs/convert/capitalCode.js new file mode 100644 index 00000000..2e4774f5 --- /dev/null +++ b/src/libs/convert/capitalCode.js @@ -0,0 +1,81 @@ +/* +Copyright (C) 2024 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 capitalCode(id) { + switch (id) { + case 11: + return 'Porto Velho'; + case 12: + return 'Rio Branco'; + case 13: + return 'Manaus'; + case 14: + return 'Boa Vista'; + case 15: + return 'Belém'; + case 16: + return 'Macapá'; + case 17: + return 'Palmas'; + case 21: + return 'São LuÃs'; + case 22: + return 'Teresina'; + case 23: + return 'Fortaleza'; + case 24: + return 'Natal'; + case 25: + return 'João Pessoa'; + case 26: + return 'Recife'; + case 27: + return 'Maceió'; + case 28: + return 'Aracaju'; + case 29: + return 'Salvador'; + case 31: + return 'Belo Horizonte'; + case 32: + return 'Vitória'; + case 33: + return 'Rio de Janeiro'; + case 35: + return 'São Paulo'; + case 41: + return 'Curitiba'; + case 42: + return 'Florianópolis'; + case 43: + return 'Porto Alegre'; + case 50: + return 'Campo Grande'; + case 51: + return 'Cuiabá'; + case 52: + return 'Goiânia'; + case 53: + return 'BrasÃlia'; + default: + return 'Não é capital'; + } +}; + diff --git a/src/libs/convert/ethnicGroupNewPnad.js b/src/libs/convert/ethnicGroupNewPnad.js new file mode 100644 index 00000000..cfbd60e1 --- /dev/null +++ b/src/libs/convert/ethnicGroupNewPnad.js @@ -0,0 +1,36 @@ +/* +Copyright (C) 2024 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 ethnicGroupNewPnad(id) { + switch (id) { + case 1: + return 'Branca'; + case 2: + return 'Preta'; + case 3: + return 'Amarela'; + case 4: + return 'Parda'; + case 5: + return 'IndÃgena'; + case 9: + return 'Sem declaração'; + } +}; diff --git a/src/libs/convert/metroCode.js b/src/libs/convert/metroCode.js new file mode 100644 index 00000000..e7729bb4 --- /dev/null +++ b/src/libs/convert/metroCode.js @@ -0,0 +1,68 @@ +/* +Copyright (C) 2024 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 metroCode(id) { + switch (id) { + case 13: + return 'Região Metropolitana de Manaus'; + case 15: + return 'Região Metropolitana de Belém'; + case 16: + return 'Região Metropolitana de Macapá'; + case 21: + return 'Região Metropolitana de Grande São LuÃs'; + case 22: + return 'Região Administrativa Integrada de Desenvolvimento de Grande Teresina' + case 23: + return 'Região Metropolitana de Fortaleza'; + case 24: + return 'Região Metropolitana de Natal'; + case 25: + return 'Região Metropolitana de João Pessoa'; + case 26: + return 'Região Metropolitana de Recife'; + case 27: + return 'Região Metropolitana de Maceió'; + case 28: + return 'Região Metropolitana de Aracaju'; + case 29: + return 'Região Metropolitana de Salvador'; + case 31: + return 'Região Metropolitana de Belo Horizonte'; + case 32: + return 'Região Metropolitana de Grande Vitória'; + case 33: + return 'Região Metropolitana do Rio de Janeiro'; + case 35: + return 'Região Metropolitana de São Paulo'; + case 41: + return 'Região Metropolitana de Curitiba'; + case 42: + return 'Região Metropolitana de Florianópolis'; + case 43: + return 'Região Metropolitana de Porto Alegre'; + case 51: + return 'Região Metropolitana de Vale do Rio Cuiabá'; + case 52: + return 'Região Metropolitana de Goiânia'; + default: + return 'Não é região metropolitana ou região administrativa integrada'; + } +}; diff --git a/src/libs/convert/regionCode.js b/src/libs/convert/regionCode.js new file mode 100644 index 00000000..fd215503 --- /dev/null +++ b/src/libs/convert/regionCode.js @@ -0,0 +1,34 @@ +/* +Copyright (C) 2024 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 regionCode(id) { + switch (id) { + case 1: + return 'Norte'; + case 2: + return 'Nordeste'; + case 3: + return 'Sudeste'; + case 4: + return 'Sul' + case 5: + return 'Centro-Oeste'; + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index e47b0683..268df2a9 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -108,6 +108,10 @@ const instructionLevel = require(`${libs}/convert/instructionLevel`); const attendsSchool = require(`${libs}/convert/attendsSchool`); const modality = require(`${libs}/convert/modality`); const attendedModality = require(`${libs}/convert/attendedModality`); +const ethnicGroupNewPnad = require(`${libs}/convert/ethnicGroupNewPnad`); +const capitalCode = require(`${libs}/convert/capitalCode`); +const regionCode = require(`${libs}/convert/regionCode`); +const metroCode = require(`${libs}/convert/metroCode`); const ids = { gender_id: gender, @@ -207,7 +211,12 @@ const ids = { instruction_level_id: instructionLevel, attends_school_id: attendsSchool, modality_id: modality, - attended_modality_id: attendedModality + attended_modality_id: attendedModality, + bolsa_familia_id: attendsSchool, + new_pnad_ethnic_group_id: ethnicGroupNewPnad, + cap_code_id: capitalCode, + reg_code_id: regionCode, + metro_code_id: metroCode }; function transform(removeId=false) { @@ -330,5 +339,9 @@ module.exports = { instructionLevel, attendsSchool, modality, - attendedModality + attendedModality, + ethnicGroupNewPnad, + capitalCode, + regionCode, + metroCode }; diff --git a/src/libs/routes_v1/newPnad.js b/src/libs/routes_v1/newPnad.js index 449d9cc4..4f257830 100644 --- a/src/libs/routes_v1/newPnad.js +++ b/src/libs/routes_v1/newPnad.js @@ -219,17 +219,17 @@ rqf.addField({ name: 'bolsa_familia', table: 'pnad_novo', tableField: 'recebeu_rendimentos_de_programa_bolsa_familia', - resultField: 'bolsa_familia', + resultField: 'bolsa_familia_id', where: { relation: '=', type: 'integer', field: 'recebeu_rendimentos_de_programa_bolsa_familia' } }).addValue({ - name: 'race', + name: 'new_pnad_ethnic_group', table: 'pnad_novo', tableField: 'cor_raca', - resultField: 'race', + resultField: 'new_pnad_ethnic_group_id', where: { relation: '=', type: 'integer', @@ -249,7 +249,7 @@ rqf.addField({ name: 'gender', table: 'pnad_novo', tableField: 'sexo', - resultField: 'gender', + resultField: 'gender_id', where: { relation: '=', type: 'integer', @@ -259,7 +259,7 @@ rqf.addField({ name: 'cap_code', table: 'pnad_novo', tableField: 'cod_cap', - resultField: 'cap_code', + resultField: 'cap_code_id', where: { relation: '=', type: 'integer', @@ -269,7 +269,7 @@ rqf.addField({ name: 'reg_code', table: 'pnad_novo', tableField: 'cod_regiao', - resultField: 'reg_code', + resultField: 'reg_code_id', where: { relation: '=', type: 'integer', @@ -279,7 +279,7 @@ rqf.addField({ name: 'metro_code', table: 'pnad_novo', tableField: 'cod_rm_ride', - resultField: 'metro_code', + resultField: 'metro_code_id', where: { relation: '=', type: 'integer', -- GitLab