From fc0f2c234934c4b07763fbe1dc36a2a365410011 Mon Sep 17 00:00:00 2001 From: Fernando Erd <fcerd15@inf.ufpr.br> Date: Fri, 4 Sep 2020 09:44:46 -0300 Subject: [PATCH] Add finish enrollment by year --- src/libs/convert/finishUniversity.js | 32 +++++++++++++++++++++++++ src/libs/middlewares/id2str.js | 8 +++++-- src/libs/routes/universityEnrollment.js | 23 ++++++++++-------- 3 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 src/libs/convert/finishUniversity.js diff --git a/src/libs/convert/finishUniversity.js b/src/libs/convert/finishUniversity.js new file mode 100644 index 00000000..81064b90 --- /dev/null +++ b/src/libs/convert/finishUniversity.js @@ -0,0 +1,32 @@ +'use strict'; + +/* +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 finishUniversity(id) { + switch (id) { + case 0: + return 'Não concluinte'; + case 1: + return 'Concluinte'; + default: + return 'Não declarado'; + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index 96ddef75..8a4b6cc3 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -85,6 +85,7 @@ const govermentAgreement = require(`${libs}/convert/govermentAgreement`); const arrangement = require(`${libs}/convert/arrangement`); const nightTime = require(`${libs}/convert/nightTime`); const discipline = require(`${libs}/convert/discipline`); +const finishUniversity = require(`${libs}/convert/finishUniversity`); const ids = { gender_id: gender, @@ -161,7 +162,8 @@ const ids = { age_student_code_id: ageStudentCode, transport_id: transport, arrangement_id: arrangement, - arrangement_id: discipline + discipline: discipline, + finish_id: finishUniversity }; function transform(removeId=false) { @@ -264,5 +266,7 @@ module.exports = { transport, govermentAgreement, arrangement, - nightTime + nightTime, + discipline, + finishUniversity }; diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 1311fec8..2521d272 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -91,6 +91,17 @@ universityEnrollmentApp.get('/ocde_geral', (req, res, next) => { next(); }, response('ocde_geral')); + +universityEnrollmentApp.get('/finish', (req, res, next) => { + req.result = [ + {id: 0, name: "Não Concluinte"}, + {id: 1, name: "Concluinte"}, + ]; + next(); + + next(); +}, response('finish')); + universityEnrollmentApp.get('/ocde_specific', (req, res, next) => { req.result = []; const defaultCase = null; @@ -630,15 +641,7 @@ rqf.addField({ }); universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { - if ("finish" in req.dims) { - req.sql.from('localoferta_ens_superior_matricula') - .field('SUM(aluno_ens_superior.concluinte)', 'total') - .field("'Brasil'", 'name') - .field('localoferta_ens_superior_matricula.ano_censo', 'year') - .group('localoferta_ens_superior_matricula.ano_censo') - .order('localoferta_ens_superior_matricula.ano_censo') - delete req.dims.finish - }else if ("localoffer" in req.dims) { + if ("localoffer" in req.dims) { if ("university" in req.dims) { req.sql.from('localoferta_ens_superior_matricula') .field('curso_ens_superior.ano_censo', 'year') @@ -658,7 +661,7 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .order('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.cod_local_oferta'); } - } else if (("state" in req.dims) || ("city" in req.dims) || ("region" in req.dims) || ("mesoregion" in req.dims) || ("microregion" in req.dims) + } else if (("state" in req.dims) || ("city" in req.dims) || ("region" in req.dims) || ("mesoregion" in req.dims) || ("microregion" in req.dims) || ("state" in req.filter) || ("city" in req.filter) || ("region" in req.filter) || ("mesoregion" in req.filter) || ("microregion" in req.filter)) { req.sql.from('localoferta_ens_superior_matricula') .field('DISTINCT COUNT(*)', 'total') -- GitLab