diff --git a/src/libs/convert/Illiteracy.js b/src/libs/convert/Illiteracy.js new file mode 100644 index 0000000000000000000000000000000000000000..4f4a8bb215b723f5943f3f6cf8e6929dff7ebfd1 --- /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 newPnadAdmDependency(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/middlewares/id2str.js b/src/libs/middlewares/id2str.js index b3e0c62297601c5a4decc2774632d71847490ba1..b5fe0974bb9df107b2d1879ac6a144c132c475a7 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -102,6 +102,7 @@ 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 ids = { gender_id: gender, @@ -195,7 +196,8 @@ const ids = { type_id: type, level_id: level, scholar_dependency_id: scholarDependency, - new_pnad_adm_dependency_id: newPnadAdmDependency + new_pnad_adm_dependency_id: newPnadAdmDependency, + illiteracy_id: Illiteracy }; function transform(removeId=false) { @@ -312,5 +314,6 @@ module.exports = { pee, shift, admDependencyPub, - newPnadAdmDependency + newPnadAdmDependency, + Illiteracy }; diff --git a/src/libs/routes_v1/newPnad.js b/src/libs/routes_v1/newPnad.js index 022e40bb43d28c92ca969b7e8575cfb9203fdf61..b57346a4335d284fe756de0313f6dc4d08954385 100644 --- a/src/libs/routes_v1/newPnad.js +++ b/src/libs/routes_v1/newPnad.js @@ -49,11 +49,15 @@ PnadNovoApp.get('/years', (req, res, next) => { }, query, response('years')); PnadNovoApp.get('/illiteracy', (req, res, next) => { - req.result = [ - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'}, - {id: 9, name: 'Não se aplica - 14 anos ou menos'} - ]; + 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')); @@ -148,7 +152,7 @@ rqf.addField({ name: 'illiteracy', table: 'pnad_novo', tableField: 'analfabetismo', - resultField: 'illiteracy', + resultField: 'illiteracy_id', where: { relation: '=', type: 'integer',