diff --git a/src/libs/convert/enrollmentSituation.js b/src/libs/convert/enrollmentSituation.js new file mode 100644 index 0000000000000000000000000000000000000000..9b709ea2b8842e2f259ae518f753405746600910 --- /dev/null +++ b/src/libs/convert/enrollmentSituation.js @@ -0,0 +1,33 @@ +/* +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 enrollmentSituation(id) { + switch (id) { + case 1: + return 'Ingressante'; + case 2: + return 'Cursando'; + case 3: + return 'Concluintes'; + default: + return 'Não definido'; + } +}; + diff --git a/src/libs/convert/enterSituation.js b/src/libs/convert/enterSituation.js new file mode 100644 index 0000000000000000000000000000000000000000..1fe551d944e176d99fef590890acc836b05b4e14 --- /dev/null +++ b/src/libs/convert/enterSituation.js @@ -0,0 +1,35 @@ +/* +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 enterSituation(id) { + switch (id) { + case 1: + return 'Cursando'; + case 2: + return 'Concluinte'; + case 3: + return 'Evadido'; + case 4: + return 'Trancado'; + default: + return 'Não definido'; + } +}; + diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index fa6a20caebd1a2a1fddf8b524f476462c2217b84..668faa80dd7f0075f64ee85a8ab46334cd56b7e8 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -90,6 +90,8 @@ const initialTraining = require(`${libs}/convert/initialTraining`); const posTraining = require(`${libs}/convert/posTraining`); const licentiateDegree = require(`${libs}/convert/licentiateDegree`); const enrolledVacanciesFreshmen = require(`${libs}/convert/enrolledVacanciesFreshmen`); +const enterSituation = require(`${libs}/convert/enterSituation`); +const enrollmentSituation = require(`${libs}/convert/enrollmentSituation`); const ids = { gender_id: gender, @@ -171,7 +173,9 @@ const ids = { initial_training_id: initialTraining, pos_training_id: posTraining, licentiate_degree_id: licentiateDegree, - enrolled_vacancies_freshmen: enrolledVacanciesFreshmen + enrolled_vacancies_freshmen: enrolledVacanciesFreshmen, + enter_situation: enterSituation, + enrollment_situation: enrollmentSituation }; function transform(removeId=false) { @@ -280,5 +284,7 @@ module.exports = { initialTraining, posTraining, licentiateDegree, - enrolledVacanciesFreshmen + enrolledVacanciesFreshmen, + enterSituation, + enrollmentSituation }; diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index f12626f3ac3d072467128102435133628f3a7e58..a856f82d3abb66a93618efc81a1ba1f08d98370a 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -286,6 +286,30 @@ universityEnrollmentApp.get('/age_student_code', function (req, res, next) { next(); }, response('age_student_code')); + +universityEnrollmentApp.get('/student_enter_situation', function (req, res, next) { + req.result = []; + for (var i = 1; i <= 4; ++i) { + req.result.push({ + id: i, + name: id2str.enterSituation(i) + }); + }; + next(); +}, response('student_enter_situation')); + + +universityEnrollmentApp.get('/student_enrollment_situation', function (req, res, next) { + req.result = []; + for (var i = 1; i <= 3; ++i) { + req.result.push({ + id: i, + name: id2str.enrollmentSituation(i) + }); + }; + next(); +}, response('student_enrollment_situation')); + universityEnrollmentApp.get('/university', (req, res, next) => { req.sql.from('aluno_ens_superior') .field('DISTINCT aluno_ens_superior.nome_ies', 'nome') @@ -737,4 +761,50 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { next() }, response('universityEnrollment')); +universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => { + req.sql.from('localoferta_ens_superior_matricula') + .field('SUM(CASE WHEN localoferta_ens_superior_matricula.cod_aluno_situacao=2 AND localoferta_ens_superior_matricula.ingressante=1 THEN 1 ELSE 0 END)', 'cursando') + .field('SUM(CASE WHEN localoferta_ens_superior_matricula.cod_aluno_situacao=6 AND localoferta_ens_superior_matricula.ingressante=1 THEN 1 ELSE 0 END)', 'concluinte') + .field('SUM(CASE WHEN (localoferta_ens_superior_matricula.cod_aluno_situacao=4 OR localoferta_ens_superior_matricula.cod_aluno_situacao=5 OR localoferta_ens_superior_matricula.cod_aluno_situacao=7) AND localoferta_ens_superior_matricula.ingressante=1 THEN 1 ELSE 0 END)', 'evadido') + .field('SUM(CASE WHEN localoferta_ens_superior_matricula.cod_aluno_situacao=3 AND localoferta_ens_superior_matricula.ingressante=1 THEN 1 ELSE 0 END)', 'trancado') + .field('COUNT(*)', 'total') + .field("'Brasil'", 'name') + .field('localoferta_ens_superior_matricula.ano_censo', 'year') + .where('localoferta_ens_superior_matricula.cod_nivel_academico=1') + .where('localoferta_ens_superior_matricula.cod_grau_academico=2 OR localoferta_ens_superior_matricula.cod_grau_academico=4') + .group('localoferta_ens_superior_matricula.ano_censo') + .order('localoferta_ens_superior_matricula.ano_censo') + next() +}, rqf.build(), (req, res, next) => {console.log(req.sql.toString()); next()}, query, (req, res, next) => { + for (var res of req.result){ + res.cursando = Number(res.cursando); + res.concluinte = Number(res.concluinte); + res.evadido = Number(res.evadido); + res.trancado = Number(res.trancado); + } + next(); +}, id2str.transform(), response('enterSituation')); module.exports = universityEnrollmentApp; +universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, next) => { + req.sql.from('localoferta_ens_superior_matricula') + .field('SUM(CASE WHEN localoferta_ens_superior_matricula.cod_aluno_situacao=2 AND localoferta_ens_superior_matricula.ingressante=1 THEN 1 ELSE 0 END)', 'ingressante') + .field('SUM(CASE WHEN localoferta_ens_superior_matricula.cod_aluno_situacao=2 AND localoferta_ens_superior_matricula.ingressante=0 AND localoferta_ens_superior_matricula.concluinte=0 THEN 1 ELSE 0 END)', 'cursando') + .field('SUM(localoferta_ens_superior_matricula.concluinte)', 'concluintes') + .field('SUM(CASE WHEN (localoferta_ens_superior_matricula.concluinte=1) OR (localoferta_ens_superior_matricula.cod_aluno_situacao = 2 and localoferta_ens_superior_matricula.ingressante = 0) OR (localoferta_ens_superior_matricula.cod_aluno_situacao = 2 and localoferta_ens_superior_matricula.ingressante = 1) THEN 1 ELSE 0 END)', 'total') + .field('localoferta_ens_superior_matricula.ano_censo', 'year') + .field("'Brasil'", 'name') + .where('localoferta_ens_superior_matricula.cod_nivel_academico=1') + .where('localoferta_ens_superior_matricula.cod_grau_academico=2 OR localoferta_ens_superior_matricula.cod_grau_academico=4') + .group('localoferta_ens_superior_matricula.ano_censo') + .order('localoferta_ens_superior_matricula.ano_censo') + next() +}, rqf.build(), (req, res, next) => {console.log(req.sql.toString()); next()}, query, (req, res, next) => { + for (var res of req.result){ + res.ingressante = Number(res.ingressante); + res.cursando = Number(res.cursando); + res.concluintes = Number(res.concluintes); + res.total = Number(res.total); + } + next(); +}, id2str.transform(), response('enrollmentSituation')); +