From 67f46fd6335c2a9f1282d1553ba7598c47022e77 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Wed, 24 Aug 2022 09:26:07 -0300 Subject: [PATCH] Update names in pee_por_categoria --- src/libs/convert/pee.js | 29 +++++++++++++++++++++++++++ src/libs/middlewares/id2str.js | 7 +++++-- src/libs/routes/enrollment.js | 36 +++++++++++++++++----------------- 3 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 src/libs/convert/pee.js diff --git a/src/libs/convert/pee.js b/src/libs/convert/pee.js new file mode 100644 index 00000000..f7f183f8 --- /dev/null +++ b/src/libs/convert/pee.js @@ -0,0 +1,29 @@ +/* +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 pee(id) { + switch(id){ + case true: + return 'Sim'; + case false: + return 'Não'; + } + }; + \ No newline at end of file diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index 08fb793c..bd5c83c0 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -94,6 +94,7 @@ const enterSituation = require(`${libs}/convert/enterSituation`); const enrollmentSituation = require(`${libs}/convert/enrollmentSituation`); const diffLocation = require(`${libs}/convert/diffLocation`); const peePorCategoria = require(`${libs}/convert/peePorCategoria`); +const pee = require(`${libs}/convert/booleanVariable`); const ids = { gender_id: gender, @@ -179,7 +180,8 @@ const ids = { enter_situation: enterSituation, enrollment_situation: enrollmentSituation, diff_location_id: diffLocation, - pee_por_categoria: peePorCategoria + pee_por_categoria: peePorCategoria, + pee_id: pee }; function transform(removeId=false) { @@ -292,5 +294,6 @@ module.exports = { enterSituation, enrollmentSituation, diffLocation, - peePorCategoria + peePorCategoria, + pee }; diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index b0e710a7..fa39a4f0 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -242,9 +242,8 @@ enrollmentApp.get('/special_class', (req, res, next) => { enrollmentApp.get('/pee', (req, res, next) => { req.result = [ - {id: null, name: 'Não Declarado'}, - {id: false, name: 'Não'}, - {id: true, name: 'Sim'} + {id: true, name: id2str.booleanVariable(true)}, + {id: false, name: id2str.booleanVariable(false)} ]; next(); }, response('pee')) @@ -762,7 +761,7 @@ rqf.addField({ name: 'pee', table: 'matricula', tableField: 'possui_necessidade_especial', - resultField: 'pee', + resultField: 'pee_id', where: { relation: '=', type: 'boolean', @@ -784,19 +783,19 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { if('pee_por_categoria' in req.dims){ delete req.dims.pee_por_categoria req.pee_por_categoria = true - req.sql.field('SUM(CASE WHEN cegueira = true THEN 1 ELSE 0 END)', 'total_cegueira') - .field('SUM(CASE WHEN baixa_visao = true THEN 1 ELSE 0 END)', 'total_baixa_visao') - .field('SUM(CASE WHEN surdez = true THEN 1 ELSE 0 END)', 'total_surdez') - .field('SUM(CASE WHEN deficiencia_auditiva = true THEN 1 ELSE 0 END)', 'total_deficiencia_auditiva') - .field('SUM(CASE WHEN surdo_cegueira = true THEN 1 ELSE 0 END)', 'total_surdo_cegueira') - .field('SUM(CASE WHEN deficiencia_fisica = true THEN 1 ELSE 0 END)', 'total_deficiencia_fisica') - .field('SUM(CASE WHEN deficiencia_intelectual = true THEN 1 ELSE 0 END)', 'total_deficiencia_intelectual') - .field('SUM(CASE WHEN deficiencia_multiplas = true THEN 1 ELSE 0 END)', 'total_deficiencia_multiplas') - .field('SUM(CASE WHEN autismo = true THEN 1 ELSE 0 END)', 'total_autismo') - .field('SUM(CASE WHEN sindrome_asperger = true THEN 1 ELSE 0 END)', 'total_sindrome_asperger') - .field('SUM(CASE WHEN sindrome_rett = true THEN 1 ELSE 0 END)', 'total_sindrome_rett') - .field('SUM(CASE WHEN transtorno_desintegrativo_da_infancia = true THEN 1 ELSE 0 END)', 'total_transtorno_desintegrativo_da_infancia') - .field('SUM(CASE WHEN superdotado = true THEN 1 ELSE 0 END)', 'total_superdotado') + req.sql.field('SUM(CASE WHEN cegueira = true THEN 1 ELSE 0 END)', 'Cegueira') + .field('SUM(CASE WHEN baixa_visao = true THEN 1 ELSE 0 END)', 'Baixa visão') + .field('SUM(CASE WHEN surdez = true THEN 1 ELSE 0 END)', 'Surdez') + .field('SUM(CASE WHEN deficiencia_auditiva = true THEN 1 ELSE 0 END)', 'Deficiência auditiva') + .field('SUM(CASE WHEN surdo_cegueira = true THEN 1 ELSE 0 END)', 'Surdocegueira') + .field('SUM(CASE WHEN deficiencia_fisica = true THEN 1 ELSE 0 END)', 'Deficiência fÃsica') + .field('SUM(CASE WHEN deficiencia_intelectual = true THEN 1 ELSE 0 END)', 'Deficiência intelectual') + .field('SUM(CASE WHEN deficiencia_multiplas = true THEN 1 ELSE 0 END)', 'Deficiências múltiplas') + .field('SUM(CASE WHEN autismo = true THEN 1 ELSE 0 END)', 'Autismo') + .field('SUM(CASE WHEN sindrome_asperger = true THEN 1 ELSE 0 END)', 'SÃndrome de Asperger') + .field('SUM(CASE WHEN sindrome_rett = true THEN 1 ELSE 0 END)', 'SÃndrome de Rett') + .field('SUM(CASE WHEN transtorno_desintegrativo_da_infancia = true THEN 1 ELSE 0 END)', 'Transtorno desintegrativo da infância') + .field('SUM(CASE WHEN superdotado = true THEN 1 ELSE 0 END)', 'Superdotado') .field('matricula.ano_censo', 'year') .from('matricula') .group('matricula.ano_censo') @@ -821,8 +820,9 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { for (var i in result_parcial){ if(i !== 'year'){ let obj = {}; - obj.pee_por_categoria_name = i; obj.total = result_parcial[i]; + i = i.replace(/"/g, ''); + obj.pee_por_categoria_name = i; obj.year = result_parcial.year; result_total.push(obj); } -- GitLab