From 9aab5ca064a399efe313336136cd89a9aafb9b49 Mon Sep 17 00:00:00 2001 From: Lewis <lgtg20@inf.ufpr.br> Date: Thu, 5 Sep 2024 19:25:46 -0300 Subject: [PATCH] Bug fix enrollmentAggregate and federativeEntity --- src/libs/convert/diffLocation.js | 2 ++ src/libs/convert/specialEducationEntity.js | 31 ++++++++++++++++++++++ src/libs/middlewares/aggregateData.js | 2 ++ src/libs/middlewares/id2str.js | 7 +++-- src/libs/routes_v1/enrollmentAggregate.js | 4 +-- src/libs/routes_v1/federativeEntity.js | 8 +++--- 6 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 src/libs/convert/specialEducationEntity.js diff --git a/src/libs/convert/diffLocation.js b/src/libs/convert/diffLocation.js index 16441ca7..aadc9cf6 100644 --- a/src/libs/convert/diffLocation.js +++ b/src/libs/convert/diffLocation.js @@ -30,5 +30,7 @@ module.exports = function location(id) { return 'Área remanescente de quilombos'; case 8: return 'Área onde se localizam povos e comunidades tradicionais'; + default: + return 'Não definido'; } }; diff --git a/src/libs/convert/specialEducationEntity.js b/src/libs/convert/specialEducationEntity.js new file mode 100644 index 00000000..b358c4ed --- /dev/null +++ b/src/libs/convert/specialEducationEntity.js @@ -0,0 +1,31 @@ +/* +Copyright (C) 2022 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 specialEducation(id) { + switch (id) { + case 1: + return 'Classe Comum'; + case 2: + return 'Classe Exclusiva'; + default: + return 'Não definido'; + } +}; + diff --git a/src/libs/middlewares/aggregateData.js b/src/libs/middlewares/aggregateData.js index 3dadee22..aaa1ede4 100644 --- a/src/libs/middlewares/aggregateData.js +++ b/src/libs/middlewares/aggregateData.js @@ -22,6 +22,7 @@ const convert = { modality_integral_time: 'educationLevelBasic', special_education: 'specialEducation', special_education_doc: 'specialEducationDoc', + special_education_entity: 'specialEducationEntity', education_level_mod_doc: 'educationLevelModDoc', education_level_mod_entity_seg: 'educationLevelModEntitySeg', education_level_mod_entity_agg: 'educationLevelModEntityAgg', @@ -48,6 +49,7 @@ function aggregateData(req, res, next) { 'modality_integral_time', 'special_education', 'special_education_doc', + 'special_education_entity', 'education_level_mod_entity_seg', 'education_level_mod_entity_agg', 'adm_dependency_entity_agg', diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index 08a1ebed..078df393 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -118,6 +118,7 @@ const incomeRange = require(`${libs}/convert/incomeRange`); const ageRangeAggregate = require(`${libs}/convert/ageRangeAggregate`); const specialEducation = require(`${libs}/convert/specialEducation`); const specialEducationDoc = require(`${libs}/convert/specialEducationDoc`); +const specialEducationEntity = require(`${libs}/convert/specialEducationEntity`); const educationLevelModDoc = require(`${libs}/convert/educationLevelModDoc`); const educationLevelModEntitySeg = require(`${libs}/convert/educationLevelModEntitySeg`); const educationLevelModEntityAgg = require(`${libs}/convert/educationLevelModEntityAgg`); @@ -238,7 +239,8 @@ const ids = { education_level_mod_entity_seg: educationLevelModEntitySeg, education_level_mod_entity_agg: educationLevelModEntityAgg, age_range_entity: ageRangeEntity, - post_graduation_entity: postGraduationEntity + post_graduation_entity: postGraduationEntity, + special_education_entity: specialEducationEntity }; function transform(removeId=false) { @@ -376,5 +378,6 @@ module.exports = { educationLevelModEntitySeg, educationLevelModEntityAgg, ageRangeEntity, - postGraduationEntity + postGraduationEntity, + specialEducationEntity }; diff --git a/src/libs/routes_v1/enrollmentAggregate.js b/src/libs/routes_v1/enrollmentAggregate.js index d266d240..08d55ddb 100644 --- a/src/libs/routes_v1/enrollmentAggregate.js +++ b/src/libs/routes_v1/enrollmentAggregate.js @@ -114,7 +114,7 @@ enrollmentAggregateApp.get('/location', (req, res, next) => { enrollmentAggregateApp.get('/diff_location', (req, res, next) => { req.result = [] - for (let i = 0; i <= 4; i++) { + for (let i = 0; i < 4; i++) { req.result.push({ id: i, name: id2str.diffLocation(i) }); @@ -587,7 +587,7 @@ enrollmentAggregateApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { .field('SUM(escola.qt_mat_bas)', 'total') .field('escola.ano_censo', 'year') .group('escola.ano_censo') - .order('escola.ano_censo'); + .order('escola.ano_censo') } next(); }, query, aggregateData, id2str.transform(false), response('enrollment_aggregate')); diff --git a/src/libs/routes_v1/federativeEntity.js b/src/libs/routes_v1/federativeEntity.js index 4a356247..0b0c2b5c 100644 --- a/src/libs/routes_v1/federativeEntity.js +++ b/src/libs/routes_v1/federativeEntity.js @@ -212,17 +212,17 @@ federativeEntityApp.get('/state', (req, res, next) => { next(); }, response('state')); -federativeEntityApp.get('/special_education', (req, res, next) => { +federativeEntityApp.get('/special_education_entity', (req, res, next) => { req.result = [] for (let i = 1; i <= 2; i++) { req.result.push({ - id: i, name: id2str.specialEducation(i) + id: i, name: id2str.specialEducationEntity(i) }); } next(); -}, response('special_education')); +}, response('special_education_entity')); rqf.addField({ @@ -467,7 +467,7 @@ federativeEntityApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { .order('docentes_sinopse.ano_censo') .where('docentes_sinopse.cod_reg = 0'); } - else if (req.query.dims && req.query.dims.includes('special_education')) + else if (req.query.dims && req.query.dims.includes('special_education_entity')) { req.sql.from('docentes_sinopse') .field('SUM(docentes_sinopse.num_doc_ed_especial_classe_comum)', 'total_doc_ed_especial_classe_comum') -- GitLab