diff --git a/src/libs/convert/attendedModality.js b/src/libs/convert/attendedModality.js new file mode 100644 index 0000000000000000000000000000000000000000..fd6162a5d5e690fd865c1614af0cb29ab40b5211 --- /dev/null +++ b/src/libs/convert/attendedModality.js @@ -0,0 +1,56 @@ +/* +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 attendedModality(id) { + switch (id) { + case 1: + return 'Creche'; + case 2: + return 'Pré-escola'; + case 3: + return 'Alfabetização de jovens e adultos'; + case 4: + return 'Ensino Fundamental - Anos iniciais' + case 5: + return 'Ensino Fundamental - Anos finais'; + case 6: + return 'EJA - Ensino Fundamental'; + case 7: + return 'Ensino Médio'; + case 8: + return 'Educação profissional - técnica integrada'; + case 9: + return 'Educação profissional - técnica concomitante e subsequente'; + case 10: + return 'Ensino Médio Regular e Profissional articulado'; + case 11: + return 'EJA - Ensino Médio'; + case 12: + return 'Superior'; + case 13: + return 'Especialização'; + case 14: + return 'Mestrado'; + case 15: + return 'Doutorado'; + case 99: + return 'Não frequenta instituição de ensino'; + } +}; diff --git a/src/libs/convert/attendsSchool.js b/src/libs/convert/attendsSchool.js new file mode 100644 index 0000000000000000000000000000000000000000..c5192999af083af6b66bc17f0c2b3e0a9ebf20c9 --- /dev/null +++ b/src/libs/convert/attendsSchool.js @@ -0,0 +1,31 @@ +/* +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/>. +*/ + +// 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 0000000000000000000000000000000000000000..fe7c0862591b81561c96d326d5f824467d9ffaba --- /dev/null +++ b/src/libs/convert/capitalCode.js @@ -0,0 +1,83 @@ +/* +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'; + case 99: + return 'Não é capital'; + default: + return 'Não informado'; + } +}; + diff --git a/src/libs/convert/ethnicGroupNewPnad.js b/src/libs/convert/ethnicGroupNewPnad.js new file mode 100644 index 0000000000000000000000000000000000000000..702a90fffd64cca924c4e5d186d25fdd6092a9b8 --- /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 'Não declarado'; + } +}; diff --git a/src/libs/convert/illiteracy.js b/src/libs/convert/illiteracy.js new file mode 100644 index 0000000000000000000000000000000000000000..069273977485f6680a83e6b269878653d82bc314 --- /dev/null +++ b/src/libs/convert/illiteracy.js @@ -0,0 +1,30 @@ +/* +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 illiteracy(id) { + switch (id) { + case 0: + return 'Não'; + case 1: + return 'Sim'; + case 9: + return 'Não se aplica - 14 anos ou menos'; + } +}; diff --git a/src/libs/convert/incomeRange.js b/src/libs/convert/incomeRange.js new file mode 100644 index 0000000000000000000000000000000000000000..fee5189b4a4100e42940108ce3f173e655ef13ee --- /dev/null +++ b/src/libs/convert/incomeRange.js @@ -0,0 +1,40 @@ +/* +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 incomeRange(id) { + switch (id) { + case 1: + return 'Até 1/4 salário mÃnimo'; + case 2: + return 'Mais de 1/4 até 1/2 salário mÃnimo'; + case 3: + return 'Mais de 1/2 até 1 salário mÃnimo'; + case 4: + return 'De 1 a 2 salários mÃnimos'; + case 5: + return 'Mais de 2 até 3 salários mÃnimos'; + case 6: + return 'Mais de 3 até 5 salários mÃnimos'; + case 7: + return 'Mais de 5 salários mÃnimos'; + case 9: + return 'Não informado ou ignorado'; + } +}; diff --git a/src/libs/convert/instructionLevel.js b/src/libs/convert/instructionLevel.js new file mode 100644 index 0000000000000000000000000000000000000000..78bbf88a9124af8efef6452873b4521b819bcc34 --- /dev/null +++ b/src/libs/convert/instructionLevel.js @@ -0,0 +1,40 @@ +/* +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 instructionLevel(id) { + switch (id) { + case 1: + return 'Sem instrução e menos de 1 ano de estudo'; + case 2: + return 'Fundamental incompleto ou equivalente'; + case 3: + return 'Fundamental completo ou equivalente'; + case 4: + return 'Médio incompleto ou equivalente'; + case 5: + return 'Médio completo ou equivalente'; + case 6: + return 'Superior incompleto ou equivalente'; + case 7: + return 'Superior completo ou equivalente'; + case 99: + return 'Não se aplica - 17 anos ou menos'; + } +}; diff --git a/src/libs/convert/metroCode.js b/src/libs/convert/metroCode.js new file mode 100644 index 0000000000000000000000000000000000000000..0442f2c757a31b81828e28574b55bb50783c873b --- /dev/null +++ b/src/libs/convert/metroCode.js @@ -0,0 +1,70 @@ +/* +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'; + case 99: + return 'Não é região metropolitana ou região administrativa integrada'; + default: + return 'Não informado'; + } +}; diff --git a/src/libs/convert/modality.js b/src/libs/convert/modality.js new file mode 100644 index 0000000000000000000000000000000000000000..d57d93381ce9e49dcf2ec555f6cd75fb26cbfe01 --- /dev/null +++ b/src/libs/convert/modality.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 modality(id) { + switch (id) { + case 1: + return 'Presencial'; + case 2: + return 'A distância'; + case 3: + return 'Não informado'; + case 9: + return 'Sem dados para 2022'; + case 99: + return 'Não frequenta instituição de ensino' + } +}; diff --git a/src/libs/convert/modalityShift.js b/src/libs/convert/modalityShift.js new file mode 100644 index 0000000000000000000000000000000000000000..7cde03d02bb8f4da76c7e4a998b582fd81dc63b5 --- /dev/null +++ b/src/libs/convert/modalityShift.js @@ -0,0 +1,42 @@ +/* +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 modalityShift(id) { + switch (id) { + case 1: + return 'Matutino'; + case 2: + return 'Vespertino'; + case 3: + return 'Noturno'; + case 4: + return 'Integral - matutino e vespertino'; + case 5: + return 'Outros'; + case 6: + return 'Não se aplica - pós graduação presencial'; + case 7: + return 'EaD ou semipresencial'; + case 9: + return 'Não informado'; + case 99: + return 'Não frequenta instituição de ensino'; + } +}; diff --git a/src/libs/convert/newPnadAdmDependency.js b/src/libs/convert/newPnadAdmDependency.js new file mode 100644 index 0000000000000000000000000000000000000000..a5cc9d19632363635a829eb92f70f5ccfe25787d --- /dev/null +++ b/src/libs/convert/newPnadAdmDependency.js @@ -0,0 +1,30 @@ +/* +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 newPnadAdmDependency(id) { + switch (id) { + case 1: + return 'Pública'; + case 2: + return 'Privada'; + case 99: + return 'Não frequenta instituição de ensino'; + } +}; diff --git a/src/libs/convert/regionCode.js b/src/libs/convert/regionCode.js new file mode 100644 index 0000000000000000000000000000000000000000..fd21550366426a1a3ef8d1def4c6520a870a9ec6 --- /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/convert/stateName.js b/src/libs/convert/stateName.js index 092969fa961aceaf262db094c383a7362267eee8..9254af006be3f66badfd578c98fc17a2c120c927 100644 --- a/src/libs/convert/stateName.js +++ b/src/libs/convert/stateName.js @@ -76,5 +76,7 @@ module.exports = function stateName(id) { return 'Distrito Federal'; case 99: return 'Exterior'; + default: + return 'Não declarada'; } }; diff --git a/src/libs/convert/yearsOfStudy.js b/src/libs/convert/yearsOfStudy.js new file mode 100644 index 0000000000000000000000000000000000000000..db474559b39841cbaf7d83af65122349a5ac42db --- /dev/null +++ b/src/libs/convert/yearsOfStudy.js @@ -0,0 +1,60 @@ +/* +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 yearsOfStudy(id) { + switch (id) { + case 0: + return 'Sem instrução e menos de 1 ano de estudo'; + case 1: + return '1 ano de estudo'; + case 2: + return '2 anos de estudo'; + case 3: + return '3 anos de estudo'; + case 4: + return '4 anos de estudo'; + case 5: + return '5 anos de estudo'; + case 6: + return '6 anos de estudo'; + case 7: + return '7 anos de estudo'; + case 8: + return '8 anos de estudo'; + case 9: + return '9 anos de estudo'; + case 10: + return '10 anos de estudo'; + case 11: + return '11 anos de estudo'; + case 12: + return '12 anos de estudo'; + case 13: + return '13 anos de estudo'; + case 14: + return '14 anos de estudo'; + case 15: + return '15 anos de estudo'; + case 16: + return '16 anos ou mais de estudo'; + case 99: + return 'Não se aplica - 17 anos ou menos'; + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index cb549d3d57326365f2289d6f7786123941cf2a87..02273a8bff361981bc0079312881afdf052e439c 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -101,6 +101,19 @@ const supplyDimension = require(`${libs}/convert/supplyDimension`); const type = require(`${libs}/convert/type`); const level = require(`${libs}/convert/level`); const scholarDependency = require(`${libs}/convert/scholarDependency`); +const newPnadAdmDependency = require(`${libs}/convert/newPnadAdmDependency`); +const illiteracy = require(`${libs}/convert/illiteracy`); +const yearsOfStudy = require(`${libs}/convert/yearsOfStudy`); +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 modalityShift = require(`${libs}/convert/modalityShift`); +const incomeRange = require(`${libs}/convert/incomeRange`); const ids = { gender_id: gender, @@ -193,7 +206,21 @@ const ids = { supply_dimension_id: supplyDimension, type_id: type, level_id: level, - scholar_dependency_id: scholarDependency + scholar_dependency_id: scholarDependency, + new_pnad_adm_dependency_id: newPnadAdmDependency, + illiteracy_id: illiteracy, + years_of_study_id: yearsOfStudy, + instruction_level_id: instructionLevel, + attends_school_id: attendsSchool, + modality_id: modality, + attended_modality_id: attendedModality, + bolsa_familia_id: attendsSchool, + new_pnad_ethnic_group_id: ethnicGroupNewPnad, + cap_code_id: capitalCode, + region_id: regionCode, + metro_code_id: metroCode, + modality_shift_id: modalityShift, + income_range_id: incomeRange }; function transform(removeId=false) { @@ -309,5 +336,18 @@ module.exports = { peePorCategoria, pee, shift, - admDependencyPub + admDependencyPub, + newPnadAdmDependency, + illiteracy, + yearsOfStudy, + instructionLevel, + attendsSchool, + modality, + attendedModality, + ethnicGroupNewPnad, + capitalCode, + regionCode, + metroCode, + modalityShift, + incomeRange }; diff --git a/src/libs/models/upload b/src/libs/models/upload new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/libs/routes_v1/activity.js b/src/libs/routes_v1/activity.js index 1c00ced76b5c2fddbed61d58d7b7966b0a172cec..cb35c2de1e741d37ec860ecb142f8d499f1ab7c5 100644 --- a/src/libs/routes_v1/activity.js +++ b/src/libs/routes_v1/activity.js @@ -117,9 +117,9 @@ activityApp.get('/:id', (req, res, next) => { let actJSON = act.toJSON(); //transform data yyyy-mm-dd to dd/mm/yyyy let date = actJSON.date.split('-'); - let date_headline = actJSON.date_headline.split('-'); + let date_start= actJSON.date_start.split('-'); actJSON.date = date[2] + '/' + date[1] + '/' + date[0]; - actJSON.date_headline = date_headline[2] + '/' + date_headline[1] + '/' + date_headline[0]; + actJSON.date_start = date_start[2] + '/' + date_start[1] + '/' + date_start[0]; req.result = actJSON; next(); } @@ -159,7 +159,8 @@ activityApp.post('/', passport.authenticate('bearer', { session: false }), autho text: req.body.texto, name_headline: req.body.nome, resume_headline: req.body.resumo, - date_headline: transformDateFormat(req.body.dataAtividade), + date_start: transformDateFormat(req.body.dataInicio), + date_end: transformDateFormat(req.body.dataEnd), local_headline: req.body.local, additional_headline: req.body.informacoes, is_draft: req.body.rascunho, @@ -207,7 +208,8 @@ activityApp.put('/:id', passport.authenticate('bearer', { session: false }), aut act.text = req.body.texto || act.text; act.name_headline = req.body.nome || act.name_headline; act.resume_headline = req.body.resumo || act.resume_headline; - act.date_headline = req.body.dataAtividade || act.date_headline; + act.date_start = req.body.dataStart || act.date_start; + act.date_end = req.body.dataEnd || act.date_end; act.local_headline = req.body.local || act.local_headline; act.additional_headline = req.body.informacoes || act.additional_headline; act.is_draft = req.body.rascunho || act.is_draft; diff --git a/src/libs/routes_v1/api.js b/src/libs/routes_v1/api.js index 75a8e663f013e2716c8f01fdd99225b2265fb51e..53f9e4df0552ed33464f0d34b29dffcd7c02494b 100644 --- a/src/libs/routes_v1/api.js +++ b/src/libs/routes_v1/api.js @@ -141,6 +141,10 @@ const publication = require(`${libs}/routes_v1/publication`); const activity = require(`${libs}/routes_v1/activity`); +const newPnad = require(`${libs}/routes_v1/newPnad`); + +const email = require(`${libs}/routes_v1/email`); + api.get('/', (req, res) => { res.json({ msg: 'SimCAQ API v1 is running' }); }); @@ -200,6 +204,7 @@ api.use('/disciplines', disciplines); api.use('/universityLocalOffer', universityLocalOffer); api.use('/message', message); api.use('/course_students', courseStudents); +api.use('/new_pnad', newPnad); //Publication api.use('/publication', publication); @@ -207,4 +212,7 @@ api.use('/publication', publication); //Activity api.use('/activity', activity); +//Email +api.use('/email', email); + module.exports = api; diff --git a/src/libs/routes_v1/email.js b/src/libs/routes_v1/email.js new file mode 100644 index 0000000000000000000000000000000000000000..7b1799a492ceebe711bed8b8c714ff1e78bda37f --- /dev/null +++ b/src/libs/routes_v1/email.js @@ -0,0 +1,24 @@ +const express = require('express'); + +const email = require(`../middlewares/email`); + +const log = require(`../log`)(module); + +const emailApp = express(); + +const libs = `${process.cwd()}/libs`; + +const User = require(`${libs}/models/user`); + +const passport = require('passport'); + + +emailApp.get('/', async (req, res, next) => { + var emails = await User.findAll({attributes:['name','email']}); + const emailsArray = emails.map(_email => _email.get()); + res.json(emailsArray); + +}) + + +module.exports = emailApp; diff --git a/src/libs/routes_v1/liquidEnrollmentRatio.js b/src/libs/routes_v1/liquidEnrollmentRatio.js index 63bd91685a8df488731a267d268a929a6252a8df..4e3b6f4bff2cff7371500e3795d5d6529071a951 100644 --- a/src/libs/routes_v1/liquidEnrollmentRatio.js +++ b/src/libs/routes_v1/liquidEnrollmentRatio.js @@ -348,6 +348,7 @@ liquidEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => { if ("education_level_short" in req.filter) { if (Array.isArray(req.filter.education_level_short)) { + console.log("ENTROU NO PRIMEIRO IF") var stringQuery = ''; for(let i = 0; i < req.filter.education_level_short.length - 1; i++) { stringQuery = stringQuery + ConvertEnrollment(req.filter.education_level_short[i]) + ' OR '; @@ -389,6 +390,7 @@ liquidEnrollmentRatioApp.get('/', rqf.parse(),(req, res, next) => { if ("education_level_short" in req.filter) { if (Array.isArray(req.filter.education_level_short)) { + console.log("ENTROU NO SEGUNDO IF") var stringQuery = ''; for(let i = 0; i < req.filter.education_level_short.length - 1; i++) { stringQuery = stringQuery + convertPnad(req.filter.education_level_short[i]) + ' OR '; diff --git a/src/libs/routes_v1/newPnad.js b/src/libs/routes_v1/newPnad.js new file mode 100644 index 0000000000000000000000000000000000000000..bab8cdf981e2411b839f1da33a2f24ca5f17a72c --- /dev/null +++ b/src/libs/routes_v1/newPnad.js @@ -0,0 +1,523 @@ +/* +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/>. +*/ + +const express = require('express'); + +const PnadNovoApp = express.Router(); + +const libs = `${process.cwd()}/libs`; + +const squel = require('squel'); + +const query = require(`${libs}/middlewares/query`).query; + +const response = require(`${libs}/middlewares/response`); + +const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); + +const id2str = require(`${libs}/middlewares/id2str`); + +const config = require(`${libs}/config`); + +const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware; + +let rqf = new ReqQueryFields(); + +PnadNovoApp.use(cache('15 day')); + +PnadNovoApp.get('/years', (req, res, next) => { + req.sql.from('pnad_novo') + .field('DISTINCT pnad_novo.ano_ref', 'year') + next(); +}, query, response('years')); + +PnadNovoApp.get('/illiteracy', (req, res, next) => { + req.result = [] + + for (let i = 0; i < 2; i++) { + req.result.push({ + id: i, name: id2str.illiteracy(i) + }); + + } + req.result.push({id: 9, name: id2str.illiteracy(9)}); + next(); +}, response('illiteracy')); + +PnadNovoApp.get('/years_of_study', (req, res, next) => { + req.result = [] + + for (let i = 0; i < 17; i++) { + req.result.push({ + id: i, name: id2str.yearsOfStudy(i) + }); + } + + req.result.push({id: 99, name: id2str.yearsOfStudy(99)}); + next(); +}, response('years_of_study')); + +PnadNovoApp.get('/instruction_level', (req, res, next) => { + req.result = [] + + for (let i = 1; i < 8; i++) { + req.result.push({ + id: i, name: id2str.instructionLevel(i) + }); + } + req.result.push({id: 99, name: id2str.instructionLevel(99)}); + next(); +}, response('instruction_level')); + +PnadNovoApp.get('/new_pnad_adm_dependency', (req, res, next) => { + req.result = [] + for (let i = 1; i < 3; i++) { + req.result.push({ + id: i, name: id2str.newPnadAdmDependency(i) + }); + } + req.result.push({id: 99, name: id2str.newPnadAdmDependency(99)}); + next(); +}, response('new_pnad_adm_dependency')); + +PnadNovoApp.get('/region', (req, res, next) => { + req.result = [] + for (let i = 1; i < 6; i++) { + req.result.push({ + id: i, name: id2str.regionCode(i) + }); + } + + next(); +}, response('region')); + +PnadNovoApp.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')); + +PnadNovoApp.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')); + +PnadNovoApp.get('/attended_modality', (req, res, next) => { + req.result = [] + for (let i = 1; i < 16; i++) { + req.result.push({ + id: i, name: id2str.attendedModality(i) + }); + } + req.result.push({id: 99, name: id2str.attendedModality(99)}); + next(); +}, response('attended_modality')); + +PnadNovoApp.get('/income_range', (req, res, next) => { + req.result = [] + for (let i = 1; i < 8; i++) { + req.result.push({ + id: i, name: id2str.incomeRange(i) + }); + } + req.result.push({id: 9, name: id2str.incomeRange(9)}); + next(); +}, response('income_range')); + +PnadNovoApp.get('/attends_school', (req, res, next) => { + req.result = [] + for (let i = 1; i < 3; i++) { + req.result.push({ + id: i, name: id2str.attendsSchool(i) + }); + } + next(); +}, response('attends_school')); + +PnadNovoApp.get('/gender', (req, res, next) => { + req.result = [] + for (let i = 1; i < 3; i++) { + req.result.push({ + id: i, name: id2str.gender(i) + }); + } + next(); +}, response('gender')); + +PnadNovoApp.get('/new_pnad_ethnic_group', (req, res, next) => { + req.result = [] + for (let i = 1; i < 6; i++) { + req.result.push({ + id: i, name: id2str.ethnicGroupNewPnad(i) + }); + } + req.result.push({id: 9, name: id2str.ethnicGroupNewPnad(9)}); + next(); +}, response('new_pnad_ethnic_group')); + +PnadNovoApp.get('/bolsa_familia', (req, res, next) => { + req.result = [] + for (let i = 1; i < 3; i++) { + req.result.push({ + id: i, name: id2str.attendsSchool(i) + }); + } + req.result.push({id: 9, name: id2str.attendsSchool(9)}); + next(); +}, response('bolsa_familia')); + +PnadNovoApp.get('/modality', (req, res, next) => { + req.result = [] + for (let i = 1; i < 4; i++) { + req.result.push({ + id: i, name: id2str.modality(i) + }); + } + req.result.push({id: 99, name: id2str.modality(99)}); + next(); +}, response('modality')); + +PnadNovoApp.get('/modality_shift', (req, res, next) => { + req.result = [] + for (let i = 1; i < 8; i++) { + req.result.push({ + id: i, name: id2str.modalityShift(i) + }); + } + req.result.push({id: 9, name: id2str.modalityShift(9)}); + req.result.push({id: 99, name: id2str.modalityShift(99)}); + next(); +}, response('modality_shift')); + +PnadNovoApp.get('/state', (req, res, next) => { + req.result = [] + for (let i = 11; i < 54; i++) { + if (id2str.stateName(i) !== 'Não declarada') { + req.result.push({ + id: i, name: id2str.stateName(i) + }); + } + } + req.result.push({id: 99, name: id2str.stateName(99)}); + + next(); +}, response('state')); + +PnadNovoApp.get('/age_range_all', (req, res, next) => { + req.result = [] + for (let i = 1; i < 12; i++) { + req.result.push({ + id: i, name: id2str.ageRangeAll(i) + }); + } + + next(); +}, response('age_range_all')); + + +rqf.addField({ + name: 'filter', + field: false, + where: true +}).addField({ + name: 'dims', + field: true, + where: false +}).addValue({ + name: 'id', + table: 'pnad_novo', + tableField: 'id', + where: { + relation: '=', + type: 'integer', + field: 'id' + } +}).addValue({ + name: 'state', + table: 'estado', + tableField: ['id', 'nome'], + resultField: ['state_id', 'state_nome'], + where: { + relation: '=', + type: 'integer', + field: 'id', + }, + join: { + primary: 'id', + foreign: 'cod_uf', + foreignTable: 'pnad_novo' + } +}).addValue({ + name: 'state_not', + table: 'estado', + tableField: ['nome', 'id'], + resultField: ['state_name', 'state_id'], + where: { + relation: '<>', + type: 'integer', + field: 'cod_uf', + table: 'pnad_novo' + }, + join: { + primary: 'id', + foreign: 'cod_uf', + foreignTable: 'pnad_novo' + } +}).addValue({ + name: 'years_of_study', + table: 'pnad_novo', + tableField: 'anos_de_estudo', + resultField: 'years_of_study_id', + where: { + relation: '=', + type: 'integer', + field: 'anos_de_estudo' + } +}).addValue({ + name: 'instruction_level', + table: 'pnad_novo', + tableField: 'nivel_de_instrucao', + resultField: 'instruction_level_id', + where: { + relation: '=', + type: 'integer', + field: 'nivel_de_instrucao' + } +}).addValue({ + name: 'new_pnad_adm_dependency', + table: 'pnad_novo', + tableField: 'dependencia_adm', + resultField: 'new_pnad_adm_dependency_id', + where: { + relation: '=', + type: 'integer', + field: 'dependencia_adm' + } +}).addValue({ + name: 'attends_school', + table: 'pnad_novo', + tableField: 'frequenta_escola', + resultField: 'attends_school_id', + where: { + relation: '=', + type: 'integer', + field: 'frequenta_escola' + } +}).addValue({ + name: 'modality', + table: 'pnad_novo', + tableField: 'modalidade', + resultField: 'modality_id', + where: { + relation: '=', + type: 'integer', + field: 'modalidade' + } +}).addValue({ + name: 'attended_modality', + table: 'pnad_novo', + tableField: 'nivel_etapa_modalidade_freq', + resultField: 'attended_modality_id', + where: { + relation: '=', + type: 'integer', + field: 'nivel_etapa_modalidade_freq' + } +}).addValue({ + name: 'illiteracy', + table: 'pnad_novo', + tableField: 'analfabetismo', + resultField: 'illiteracy_id', + where: { + relation: '=', + type: 'integer', + field: 'analfabetismo' + } +}).addValue({ + name: 'modality_shift', + table: 'pnad_novo', + tableField: 'turno_nivel_etapa', + resultField: 'modality_shift_id', + where: { + relation: '=', + type: 'integer', + field: 'turno_nivel_etapa' + } +}).addValue({ + name: 'bolsa_familia', + table: 'pnad_novo', + tableField: 'recebeu_rendimentos_de_programa_bolsa_familia', + resultField: 'bolsa_familia_id', + where: { + relation: '=', + type: 'integer', + field: 'recebeu_rendimentos_de_programa_bolsa_familia' + } +}).addValue({ + name: 'new_pnad_ethnic_group', + table: 'pnad_novo', + tableField: 'cor_raca', + resultField: 'new_pnad_ethnic_group_id', + where: { + relation: '=', + type: 'integer', + field: 'cor_raca' + } +}).addValue({ + name: 'age_range_all', + table: 'pnad_novo', + tableField: 'faixa_etaria', + resultField: 'age_range_all_id', + where: { + relation: '=', + type: 'integer', + field: 'faixa_etaria' + } +}).addValue({ + name: 'income_range', + table: 'pnad_novo', + tableField: 'faixa_rendimento_aux', + resultField: 'income_range_id', + where: { + relation: '=', + type: 'integer', + field: 'faixa_rendimento_aux' + } +}).addValue({ + name: 'gender', + table: 'pnad_novo', + tableField: 'sexo', + resultField: 'gender_id', + where: { + relation: '=', + type: 'integer', + field: 'sexo' + } +}).addValue({ + name: 'cap_code', + table: 'pnad_novo', + tableField: 'cod_cap', + resultField: 'cap_code_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_cap' + } +}).addValue({ + name: 'region', + table: 'pnad_novo', + tableField: 'cod_regiao', + resultField: 'region_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_regiao' + } +}).addValue({ + name: 'metro_code', + table: 'pnad_novo', + tableField: 'cod_rm_ride', + resultField: 'metro_code_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_rm_ride' + } +}).addValue({ + name: 'min_year', + table: 'pnad_novo', + tableField: 'ano_ref', + resultField: 'year', + where: { + relation: '>=', + type: 'integer', + field: 'ano_ref' + } +}).addValue({ + name: 'max_year', + table: 'pnad_novo', + tableField: '', + resultField: 'year', + where: { + relation: '<=', + type: 'integer', + field: 'ano_ref' + } +}).addField({ + name: 'search', + field: false, + where: true +}).addValueToField({ + name: 'name', + table: 'pnad_novo', + tableField: 'nome', + where: { + relation: 'LIKE', + type: 'string', + field: 'nome' + } +}, 'search').addValue({ + name: 'mesoregion', + table: 'pnad_novo', + tableField: 'mesorregiao_id', + where: { + relation: '=', + type: 'integer', + field: 'mesorregiao_id' + } +}).addValue({ + name: 'microregion', + table: 'pnad_novo', + tableField: 'microrregiao_id', + where: { + relation: '=', + type: 'integer', + field: 'microrregiao_id' + } +}); + +PnadNovoApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { + req.sql.from('pnad_novo') + .field('round(sum(pnad_novo.peso_domicilio_pessoas_com_cal), 0)', 'total') + .field('pnad_novo.ano_ref', 'year') + .group('pnad_novo.ano_ref') + .order('pnad_novo.ano_ref') + console.log(req.sql.toString()) + next(); +}, query, id2str.transform(false), response('pnad_novo')); + +module.exports = PnadNovoApp; diff --git a/src/libs/routes_v1/publication.js b/src/libs/routes_v1/publication.js index 63a7cbd5b5683aaae12696f96079c7ae1177f193..5092cff614417a9c57859fb0bb8bd5485c41ca3b 100644 --- a/src/libs/routes_v1/publication.js +++ b/src/libs/routes_v1/publication.js @@ -78,14 +78,13 @@ pubApp.get('/', async (req, res, next) => { }); pubApp.get('/homepage', async (req, res, next)=> { + const page = parseInt(req.query.page) || 1; // Current page number + const pageSize = parseInt(req.query.pageSize) || 5; // Number of items per page const totalCount = await Publication.count({ where: { is_headline: true } }); const offset = (page - 1) * pageSize; const publis = await Publication.findAll({ offset, limit: pageSize, - order: [ - ['created_at', ordenar], - ], where:{ is_headline:true } @@ -98,18 +97,18 @@ pubApp.get('/homepage', async (req, res, next)=> { }); }); -pubApp.get('/type/:tp', async (req, res, next) => { - const tp = req.params.tp || 'all'; - if(tp === 'all'){ +pubApp.get('/type', async (req, res, next) => { + const page = parseInt(req.query.page) || 1; // Current page number + const pageSize = parseInt(req.query.pageSize) || 5; // Number of items per page + const tipo = req.query.tipo || 'all'; + console.log(tipo); + if(tipo === 'all'){ const totalCount = await Publication.count(); const offset = (page - 1) * pageSize; const publis = await Publication.findAll({ offset, limit: pageSize, - order: [ - ['created_at', ordenar], - ], }); res.json({ @@ -120,16 +119,13 @@ pubApp.get('/type/:tp', async (req, res, next) => { }); } else{ - const totalCount = await Publication.count({ where: { filter: req.params.tp } }); + const totalCount = await Publication.count({ where: { filter: tipo } }); const offset = (page - 1) * pageSize; const publis = await Publication.findAll({ offset, limit: pageSize, - order: [ - ['created_at', ordenar], - ], where: { - filter: req.params.tp + filter: tipo } }); res.json({ @@ -186,7 +182,7 @@ pubApp.post('/', passport.authenticate('bearer', { session: false }), authorized link: data.link, upload: _file_id, is_draft: data.rascunho, - is_homepage: data.homepage, + is_headline: data.homepage, volume: data.volume, pages: data.pagina }).catch(function (err) { @@ -224,7 +220,7 @@ pubApp.post('/edit', passport.authenticate('bearer', { session: false }), author pb.year = data.ano || pb.year; pb.text = data.texto || pb.text; pb.link = data.link || pb.link; - pb.is_homepage = data.homepage || pb.is_homepage; + pb.is_headline = data.homepage || pb.is_headline; pb.is_draft = data.rascunho || pb.is_draft; pb.upload = _file_id || pb.upload; pb.volume = data.volume || pb.volume;