From 9d0314c566a1e44e0a357dd43f008e44b30b03d5 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Wed, 21 Oct 2020 10:44:29 -0300 Subject: [PATCH 001/305] added universityLocalOffer --- src/libs/routes/courseCount.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/courseCount.js b/src/libs/routes/courseCount.js index fce35171..b86a3a6d 100644 --- a/src/libs/routes/courseCount.js +++ b/src/libs/routes/courseCount.js @@ -312,6 +312,16 @@ rqf.addField({ type: 'integer', field: 'cod_ies' } +}).addValue({ + name: 'universityLocalOffer', + table: 'curso_ens_superior', + tableField: ['cod_ies', 'nome_ies'], + resultField: ['university_id', 'university_name'], + where: { + relation: '=', + type: 'integer', + field: 'cod_ies' + } }).addValue({ name:'upper_adm_dependency', table: 'curso_ens_superior', @@ -488,7 +498,7 @@ rqf.addField({ courseCountApp.get('/', rqf.parse(), (req, res, next) => { if ("localoffer" in req.dims) { - if ("university" in req.dims) { + if ("university" in req.dims || "universityLocalOffer" in req.dims) { req.sql.from('curso_ens_superior') .field('curso_ens_superior.ano_censo', 'year') .field('COUNT(localoferta_ens_superior.cod_local_oferta)', 'total') @@ -521,7 +531,7 @@ courseCountApp.get('/', rqf.parse(), (req, res, next) => { .order('curso_ens_superior.ano_censo') .where('curso_ens_superior.tipo_atributo_ingresso <> 1 OR curso_ens_superior.tipo_atributo_ingresso is NULL') .where('curso_ens_superior.cod_nivel_academico = 1'); - } else if ("university" in req.dims) { + } else if ("university" in req.dims || "universityLocalOffer" in req.dims) { req.sql.from('curso_ens_superior') .field('COUNT(curso_ens_superior.cod_curso)', 'total') .field("'Brasil'", 'name') -- GitLab From 8e4d6e660f8c8aa98a45f4ab59190cb8c306d36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Picolo?= <jpp18@inf.ufpr.br> Date: Tue, 27 Oct 2020 09:19:55 -0300 Subject: [PATCH 002/305] Add filter for discipline route --- src/libs/routes/disciplines.js | 99 +++++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 25 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 2c5a9c96..3ac6a978 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -574,31 +574,80 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { next(); }, rqf.build(), query, id2str.transform(), (req, res, next) => { - let disciplinesNotSuitable = []; - let disciplinesSuitable = []; - - req.result.forEach((r) => { - let objNotSuitable = { - total: parseInt(r.total) - parseInt(r.total_suitable), - suitable: 0 - } - - let objSuitable = { - total: parseInt(r.total_suitable), - suitable: 1 - } - Object.keys(r).forEach(k => { - if (k !== 'total' && k !== 'total_suitable') { - objNotSuitable[k] = r[k]; - objSuitable[k] = r[k]; - } - }) - - disciplinesNotSuitable.push(objNotSuitable) - disciplinesSuitable.push(objSuitable) - }) - - req.result = disciplinesNotSuitable.concat(disciplinesSuitable); + let filters = Object.keys(req.filter) + + if(filters.includes("state")) { + const disciplinesDB = ['quimica', 'fisica', 'matematica', 'biologia', 'ciencias', 'lingua_portuguesa', 'lingua_inglesa', 'lingua_espanhola', + 'lingua_francesa', 'lingua_outra', 'lingua_indigena', 'artes', 'educacao_fisica', 'historia', 'geografia', 'filosofia', 'ensino_religioso', + 'estudos_sociais', 'sociologia'] + const disciplinesAPI = ["Química", "Física", "Matemática", "Biologia", "Ciências", "Língua Portuguesa", "Língua Estrangeira – Inglês", + "Língua Estrangeira - Espanhol","Língua Estrangeira - Francês", "Língua Estrangeira - Outras", "Língua Indígena", "Arte", "Educação Física", "História", + "Geografia", "Filosofia", "Ensino religioso", "Estudos Sociais", "Sociologia"] + + let jsonKeys = [] + let results = [] + req.result.forEach((r) => { + jsonKeys = Object.keys(r) + + let i + let size = jsonKeys.length - 2 // Last two infos are "name" and "year" + for(i = 0; i < size; i++) { + let total_name = jsonKeys[i] + let suitable_name = jsonKeys[i + 1] + + // Calculates percentage + let percentage = r[suitable_name] / r[total_name] + percentage = percentage * 100 + percentage = percentage.toFixed(1) // Rounds to 1 digit after comma, returns string + percentage = percentage.replace(".", ",") + "%" + + // Parses name + total_name = total_name.replace("total_", "") + let discipline_index = disciplinesDB.indexOf(total_name) + let discipline_name = disciplinesAPI[discipline_index] + + let obj = { + total: percentage, + name: r["name"], + year: r["year"], + discipline_id: discipline_index + 1, // Convert function starts at 1, not at 0 + discipline_name: discipline_name + } + results.push(obj) + + i++; // Ignore next, it's a suitable already used + } + }) + + req.result = results; + } + else { + let disciplinesNotSuitable = []; + let disciplinesSuitable = []; + + req.result.forEach((r) => { + let objNotSuitable = { + total: parseInt(r.total) - parseInt(r.total_suitable), + suitable: 0 + } + + let objSuitable = { + total: parseInt(r.total_suitable), + suitable: 1 + } + Object.keys(r).forEach(k => { + if (k !== 'total' && k !== 'total_suitable') { + objNotSuitable[k] = r[k]; + objSuitable[k] = r[k]; + } + }) + + disciplinesNotSuitable.push(objNotSuitable) + disciplinesSuitable.push(objSuitable) + }) + + req.result = disciplinesNotSuitable.concat(disciplinesSuitable); + } next(); }, response('disciplines')); -- GitLab From a6253bcd8632502ec0f9e640560b2da75ff0b666 Mon Sep 17 00:00:00 2001 From: Victor Picussa <vic_picussa2@hotmail.com> Date: Mon, 9 Nov 2020 16:23:08 -0300 Subject: [PATCH 003/305] [homologa]Removed universityLocalOffer filter from universityEnrollment --- src/libs/routes/universityEnrollment.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index d1670f7c..6e866491 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -373,16 +373,6 @@ rqf.addField({ type: 'integer', field: 'cod_ies' } -}).addValue({ - name: 'universityLocalOffer', - table: '@', - tableField: ['cod_ies', 'nome_ies'], - resultField: ['university_id', 'university_name'], - where: { - relation: '=', - type: 'integer', - field: 'cod_ies' - } }).addValue({ name:'upper_adm_dependency', table: '@', @@ -651,7 +641,7 @@ rqf.addField({ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { if ("localoffer" in req.dims) { - if ("university" in req.dims || "universityLocalOffer" in req.dims) { + if ("university" in req.dims) { req.sql.from('localoferta_ens_superior_matricula') .field('curso_ens_superior.ano_censo', 'year') .field('COUNT(localoferta_ens_superior.cod_local_oferta)', 'total') @@ -678,7 +668,7 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('localoferta_ens_superior_matricula.ano_censo', 'year') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') - } else if ("university" in req.dims || "universityLocalOffer" in req.dims) { + } else if ("university" in req.dims) { req.sql.from('aluno_ens_superior') .field('COUNT(*)', 'total') .field("'Brasil'", 'name') -- GitLab From e0ebfbe9ddb627f86ec0624038d1b94abf6b928e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Picolo?= <jpp18@inf.ufpr.br> Date: Tue, 10 Nov 2020 09:42:35 -0300 Subject: [PATCH 004/305] Adds licentiate degree route --- src/libs/convert/licentiateDegree.js | 30 ++++++++++++++++++++++++++++ src/libs/middlewares/id2str.js | 4 +++- src/libs/routes/teacher.js | 21 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/libs/convert/licentiateDegree.js diff --git a/src/libs/convert/licentiateDegree.js b/src/libs/convert/licentiateDegree.js new file mode 100644 index 00000000..cc103374 --- /dev/null +++ b/src/libs/convert/licentiateDegree.js @@ -0,0 +1,30 @@ +/* +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 licentiateDegree(id) { + switch (id) { + case 1: + return 'Sem ensino superior'; + case 2: + return 'Superior com bacharelado ou tecnólogo'; + case 3: + return 'Superior com licenciatura ou complementação pedagógica'; + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index cb9a18d6..a75d1531 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -88,6 +88,7 @@ const discipline = require(`${libs}/convert/discipline`); const finishUniversity = require(`${libs}/convert/finishUniversity`); const initialTraining = require(`${libs}/convert/initialTraining`); const posTraining = require(`${libs}/convert/posTraining`); +const licentiateDegree = require(`${libs}/convert/licentiateDegree`); const ids = { gender_id: gender, @@ -167,7 +168,8 @@ const ids = { discipline: discipline, finish_id: finishUniversity, initial_training_id: initialTraining, - pos_training_id: posTraining + pos_training_id: posTraining, + licentiate_degree_id: licentiateDegree }; function transform(removeId=false) { diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index b2a4dc4e..80a1a905 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -204,6 +204,17 @@ teacherApp.get('/pos_training', (req, res, next) => { next(); }, response('pos_training')); +teacherApp.get('/licentiate_degree', (req, res, next) => { + req.result = []; + for(let i = 1; i <= 3; ++i) { + req.result.push({ + id: i, + name: id2str.licentiateDegree(i) + }); + } + next(); +}, response('licentiate_degree')); + rqf.addField({ name: 'filter', field: false, @@ -474,6 +485,16 @@ rqf.addField({ type: 'integer', field: 'formacao_pos_docente' } +}).addValue({ + name: 'licentiate_degree', + table: 'docente', + tableField: 'formacao_licenciatura_docente', + resultField: 'licentiate_degree_id', + where: { + relation: '=', + type: 'integer', + field: 'formacao_licenciatura_docente' + } }); teacherApp.get('/', rqf.parse(), (req, res, next) => { -- GitLab From 8519375cd6f3e3dd96341dcc39ebfb720811057c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Picolo?= <jpp18@inf.ufpr.br> Date: Wed, 11 Nov 2020 11:12:19 -0300 Subject: [PATCH 005/305] Adds MAPFOR as a valid origin --- src/libs/models/user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/models/user.js b/src/libs/models/user.js index 0d54e417..be62f4a5 100644 --- a/src/libs/models/user.js +++ b/src/libs/models/user.js @@ -81,8 +81,8 @@ var UserSchema = new Schema({ }, origin: { type: String, - enum: ['LDE', 'SimCAQ'], - required: [true, 'O campo origem é obrigatória e aceita apenas os valores "LDE" ou "SimCAQ"'] + enum: ['LDE', 'SimCAQ', 'MAPFOR'], + required: [true, 'O campo origem é obrigatória e aceita apenas os valores "LDE", "SimCAQ" e "MAPFOR"'] }, verified: { type: Boolean, -- GitLab From a48b5c79225bbb4daa973db480d1e4f889be8fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Picolo?= <jpp18@inf.ufpr.br> Date: Mon, 23 Nov 2020 11:36:10 -0300 Subject: [PATCH 006/305] Adds new initial training convert --- src/libs/convert/initialTraining.js | 10 ++++++---- src/libs/routes/teacher.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libs/convert/initialTraining.js b/src/libs/convert/initialTraining.js index 3eff60f0..ef17c6e2 100644 --- a/src/libs/convert/initialTraining.js +++ b/src/libs/convert/initialTraining.js @@ -21,12 +21,14 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function initialTraining(id) { switch (id) { case 1: - return 'Sem formação mínima'; + return 'Sem formação mínima'; case 2: - return 'Ensino Médio na modalidade normal'; + return 'Ensino Médio na modalidade normal'; case 3: - return 'Superior bacharelado ou tecnólogo'; + return 'Superior bacharelado ou tecnólogo'; case 4: - return 'Superior com licenciatura ou complementação pedagógica'; + return 'Superior com licenciatura ou complementação pedagógica'; + case 5: + return 'Pós-gradução'; } }; diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 80a1a905..88ec7a1e 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -184,7 +184,7 @@ teacherApp.get('/ethnic_group', (req, res, next) => { teacherApp.get('/initial_training', (req, res, next) => { req.result = []; - for(let i = 1; i <=4; ++i) { + for(let i = 1; i <=5; ++i) { req.result.push({ id: i, name: id2str.initialTraining(i) -- GitLab From 6e512ffb7bdf74803444b439f2c4a0132edc9998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Picolo?= <jpp18@inf.ufpr.br> Date: Wed, 25 Nov 2020 11:30:53 -0300 Subject: [PATCH 007/305] Fix route --- src/libs/routes/financial.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/financial.js b/src/libs/routes/financial.js index bfe27205..dab9dfe8 100644 --- a/src/libs/routes/financial.js +++ b/src/libs/routes/financial.js @@ -181,6 +181,6 @@ financialApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { .group('indicadores_financeiros.esfera_adm') } next(); -}, query, addMissing(rqf), id2str.transform(), response('financial')); +}, query, id2str.transform(), response('financial')); module.exports = financialApp; -- GitLab From 7034c8866d877b54b712d6dd0a0971469f5a8d3b Mon Sep 17 00:00:00 2001 From: Fernando Erd <fcerd15@inf.ufpr.br> Date: Mon, 30 Nov 2020 09:21:40 -0300 Subject: [PATCH 008/305] Add universityLocalOffer --- src/libs/routes/universityEnrollment.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 6e866491..d1670f7c 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -373,6 +373,16 @@ rqf.addField({ type: 'integer', field: 'cod_ies' } +}).addValue({ + name: 'universityLocalOffer', + table: '@', + tableField: ['cod_ies', 'nome_ies'], + resultField: ['university_id', 'university_name'], + where: { + relation: '=', + type: 'integer', + field: 'cod_ies' + } }).addValue({ name:'upper_adm_dependency', table: '@', @@ -641,7 +651,7 @@ rqf.addField({ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { if ("localoffer" in req.dims) { - if ("university" in req.dims) { + if ("university" in req.dims || "universityLocalOffer" in req.dims) { req.sql.from('localoferta_ens_superior_matricula') .field('curso_ens_superior.ano_censo', 'year') .field('COUNT(localoferta_ens_superior.cod_local_oferta)', 'total') @@ -668,7 +678,7 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('localoferta_ens_superior_matricula.ano_censo', 'year') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') - } else if ("university" in req.dims) { + } else if ("university" in req.dims || "universityLocalOffer" in req.dims) { req.sql.from('aluno_ens_superior') .field('COUNT(*)', 'total') .field("'Brasil'", 'name') -- GitLab From 537118c72eac52a392f4a50f3964f9a2dd4e26ea Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Tue, 19 Jan 2021 11:27:42 -0300 Subject: [PATCH 009/305] Update disciplines.js --- src/libs/routes/disciplines.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 3ac6a978..6da993ff 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -576,7 +576,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { }, rqf.build(), query, id2str.transform(), (req, res, next) => { let filters = Object.keys(req.filter) - if(filters.includes("state")) { + {/*if(filters.includes("state")) { const disciplinesDB = ['quimica', 'fisica', 'matematica', 'biologia', 'ciencias', 'lingua_portuguesa', 'lingua_inglesa', 'lingua_espanhola', 'lingua_francesa', 'lingua_outra', 'lingua_indigena', 'artes', 'educacao_fisica', 'historia', 'geografia', 'filosofia', 'ensino_religioso', 'estudos_sociais', 'sociologia'] @@ -621,7 +621,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { req.result = results; } - else { + else { */} let disciplinesNotSuitable = []; let disciplinesSuitable = []; @@ -647,7 +647,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { }) req.result = disciplinesNotSuitable.concat(disciplinesSuitable); - } + next(); }, response('disciplines')); -- GitLab From 9376903eb3dc2c4cadfb8c6ee80a97bbb5fc9f31 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Tue, 19 Jan 2021 11:44:12 -0300 Subject: [PATCH 010/305] Update id2str.js --- src/libs/middlewares/id2str.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index a75d1531..b86232ca 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -276,5 +276,6 @@ module.exports = { discipline, finishUniversity, initialTraining, - posTraining + posTraining, + licentiateDegree }; -- GitLab From 7d4ec739167dfe027de649c68c78823e72fbd7fe Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Mon, 12 Apr 2021 13:04:24 -0300 Subject: [PATCH 011/305] teacher_tmp.js pulls data from table docente_test instead of docente --- src/libs/routes/teacher_temp.js | 521 ++++++++++++++++++++++++++++++++ 1 file changed, 521 insertions(+) create mode 100644 src/libs/routes/teacher_temp.js diff --git a/src/libs/routes/teacher_temp.js b/src/libs/routes/teacher_temp.js new file mode 100644 index 00000000..24c7f278 --- /dev/null +++ b/src/libs/routes/teacher_temp.js @@ -0,0 +1,521 @@ +/* +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/>. +*/ + +const express = require('express'); + +const teacherApp = express.Router(); + +const libs = `${process.cwd()}/libs`; + +const log = require(`${libs}/log`)(module); + +const squel = require('squel'); + +const query = require(`${libs}/middlewares/query`).query; + +const response = require(`${libs}/middlewares/response`); + +const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); + +const id2str = require(`${libs}/middlewares/id2str`); + +const config = require(`${libs}/config`); + +const addMissing = require(`${libs}/middlewares/addMissing`); + +const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware; + +let rqf = new ReqQueryFields(); + +teacherApp.use(cache('15 day')); + +// Returns a tuple of start and ending years of the complete enrollments dataset. +teacherApp.get('/year_range', (req, res, next) => { + req.sql.from('docente_test') + .field('MIN(docente.ano_censo)', 'start_year') + .field('MAX(docente.ano_censo)', 'end_year'); + next(); +}, query, response('range')); + +teacherApp.get('/years', (req, res, next) => { + req.sql.from('docente_test'). + field('DISTINCT docente.ano_censo', 'year'); + next(); +}, query, response('years')); + +teacherApp.get('/source', (req, res, next) => { + req.sql.from('fonte') + .field('fonte', 'source') + .where('tabela = \'docente\''); + next(); +}, query, response('source')); + +teacherApp.get('/adm_dependency_detailed', (req, res, next) => { + req.result = []; + for(let i = 1; i <= 8; ++i) { + req.result.push({ + id: i, + name: id2str.admDependencyPriv(i) + }); + }; + next(); +}, response('adm_dependency_detailed')); + +teacherApp.get('/adm_dependency', (req, res, next) => { + req.result = []; + for(let i = 1; i <= 4; ++i) { + req.result.push({ + id: i, + name: id2str.admDependency(i) + }); + }; + next(); +}, response('adm_dependency')); + +teacherApp.get('/education_level_mod', (req, res, next) => { + req.result = []; + for(let i = 1; i <= 12; ++i) { + req.result.push({ + id: i, + name: id2str.educationLevelMod(i) + }); + } + req.result.push({ + id: 99, + name: id2str.educationLevelMod(99) + }); + next(); +}, response('education_level_mod')); + +teacherApp.get('/education_level_short', (req, res, next) => { + req.result = [ + {id: null, name: 'Não classificada'}, + {id: 1, name: 'Creche'}, + {id: 2, name: 'Pré-Escola'}, + {id: 3, name: 'Ensino Fundamental - anos iniciais'}, + {id: 4, name: 'Ensino Fundamental - anos finais'}, + {id: 5, name: 'Ensino Médio'}, + {id: 6, name: 'EJA'}, + {id: 7, name: 'EE exclusiva'} + ]; + next(); +}, response('education_level_short')); + +teacherApp.get('/location', (req, res, next) => { + req.result = []; + for(let i = 1; i <= 2; ++i) { + req.result.push({ + id: i, + name: id2str.location(i) + }); + }; + next(); +}, response('location')); + +teacherApp.get('/rural_location', (req, res, next) => { + req.result = []; + for (let i = 1; i <= 8; i++) { + req.result.push({ + id: i, + name: id2str.ruralLocation(i) + }); + }; + next(); +}, response('rural_location')); + +teacherApp.get('/education_type', (req, res, next) => { + req.sql.from('docente_test') + .field('DISTINCT nivel_tipo_formacao', 'id') + .order('id'); + next(); +}, query, (req, res, next) => { + req.result.forEach((result) => { + result.name = id2str.educationType(result.id); + }); + next(); +}, response('education_type')); + +teacherApp.get('/gender', (req, res, next) => { + req.result = [ + {id: 1, name: 'Masculino'}, + {id: 2, name: 'Feminino'} + ]; + next(); +}, response('gender')); + + +teacherApp.get('/contract_type', (req, res, next) => { + req.result = [ + {id: 1, name: 'Concursado/Efetivo/Estável'}, + {id: 2, name: 'Contrato temporário'}, + {id: 3, name: 'Contrato terceirizado'}, + {id: 4, name: 'Contrato CLT'} + ]; + next(); +}, response('contract_type')); + +teacherApp.get('/ethnic_group', (req, res, next) => { + req.result = []; + for(let i = 0; i <=5; ++i) { + req.result.push({ + id: i, + name: id2str.ethnicGroup(i) + }); + } + next(); +}, response('ethnic_group')); + +teacherApp.get('/initial_training', (req, res, next) => { + req.result = []; + for(let i = 1; i <=5; ++i) { + req.result.push({ + id: i, + name: id2str.initialTraining(i) + }); + } + next(); +}, response('initial_training')); + +teacherApp.get('/pos_training', (req, res, next) => { + req.result = []; + for(let i = 1; i <= 4; ++i) { + req.result.push({ + id: i, + name: id2str.posTraining(i) + }); + } + next(); +}, response('pos_training')); + +teacherApp.get('/licentiate_degree', (req, res, next) => { + req.result = []; + for(let i = 1; i <= 3; ++i) { + req.result.push({ + id: i, + name: id2str.licentiateDegree(i) + }); + } + next(); +}, response('licentiate_degree')); + +rqf.addField({ + name: 'filter', + field: false, + where: true +}).addField({ + name: 'dims', + field: true, + where: false +}).addValue({ + name: 'adm_dependency', + table: 'docente_test', + tableField: 'dependencia_adm_id', + resultField: 'adm_dependency_id', + where: { + relation: '=', + type: 'integer', + field: 'dependencia_adm_id' + } +}).addValue({ + name: 'adm_dependency_detailed', + table: 'docente_test', + tableField: 'dependencia_adm_priv', + resultField: 'adm_dependency_detailed_id', + where: { + relation: '=', + type: 'integer', + field: 'dependencia_adm_priv' + } +}).addValue({ + name: 'contract_type', + table: 'docente_test', + tableField: 'tipo_contratacao', + resultField: 'contract_type_id', + where: { + relation: '=', + type: 'integer', + field: 'tipo_contratacao' + } +}).addValue({ + name: 'education_level_mod', + table: 'docente_test', + tableField: 'etapas_mod_ensino_segmento_id', + resultField: 'education_level_mod_id', + where: { + relation: '=', + type: 'integer', + field: 'etapas_mod_ensino_segmento_id' + } +}).addValue({ + name: 'education_level_short', + table: 'docente_test', + tableField: 'etapa_resumida', + resultField: 'education_level_short_id', + where: { + relation: '=', + type: 'integer', + field: 'etapa_resumida' + } +}).addValue({ + name: 'education_type', + table: 'docente_test', + tableField: 'nivel_tipo_formacao', + resultField: 'education_type_id', + where: { + relation: '=', + type: 'integer', + field: 'nivel_tipo_formacao' + } +}).addValue({ + name: 'region', + table: 'regiao', + tableField: ['nome', 'id'], + resultField: ['region_name', 'region_id'], + where: { + relation: '=', + type: 'integer', + field: 'id' + }, + join: { + primary: 'id', + foreign: 'escola_regiao_id', + foreignTable: 'docente_test' + } +}).addValue({ + name: 'mesoregion', + table: 'municipio', + tableField: ['nome_mesorregiao', 'mesorregiao_id'], + resultField: ['mesoregion_name', 'mesoregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'mesorregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'escola_municipio_id', + foreignTable: 'docente_test' + } +}).addValue({ + name: 'microregion', + table: 'municipio', + tableField: ['nome_microrregiao', 'microrregiao_id'], + resultField: ['microregion_name', 'microregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'microrregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'escola_municipio_id', + foreignTable: 'docente_test' + } +}).addValue({ + name: 'state', + table: 'estado', + tableField: ['nome', 'id'], + resultField: ['state_name', 'state_id'], + where: { + relation: '=', + type: 'integer', + field: 'id' + }, + join: { + primary: 'id', + foreign: 'escola_estado_id', + foreignTable: 'docente_test' + } +}).addValueToField({ + name: 'city', + table: 'municipio', + tableField: ['nome', 'id'], + resultField: ['city_name', 'city_id'], + where: { + relation: '=', + type: 'integer', + field: 'id' + }, + join: { + primary: 'id', + foreign: 'escola_municipio_id', + foreignTable: 'docente_test' + } +}, 'dims').addValueToField({ + name: 'city', + table: 'municipio', + tableField: 'nome', + resultField: 'city_name', + where: { + relation: '=', + type: 'integer', + field: 'id' + }, + join: { + primary: 'id', + foreign: 'escola_municipio_id', + foreignTable: 'docente_test' + } +}, 'filter').addValueToField({ + name: 'school', + table: 'escola', + tableField: ['nome_escola', 'id'], + resultField: ['school_name', 'school_id'], + where: { + relation: '=', + type: 'integer', + field: 'id' + }, + join: { + primary: ['id', 'ano_censo'], + foreign: ['escola_id', 'ano_censo'], + foreignTable: 'docente_test' + } +}, 'dims').addValueToField({ + name: 'school', + table: 'escola', + tableField: 'nome_escola', + resultField: 'school_name', + where: { + relation: '=', + type: 'integer', + field: 'id' + }, + join: { + primary: ['id', 'ano_censo'], + foreign: ['escola_id', 'ano_censo'], + foreignTable: 'docente_test' + } +}, 'filter').addValue({ + name: 'location', + table: 'docente_test', + tableField: 'localizacao_id', + resultField: 'location_id', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_id' + } +}).addValue({ + name: 'rural_location', + table: 'docente_test', + tableField: 'localidade_area_rural', + resultField: 'rural_location_id', + where: { + relation: '=', + type: 'integer', + field: 'localidade_area_rural' + } +}).addValue({ + name: 'min_year', + table: 'docente_test', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '>=', + type: 'integer', + field: 'ano_censo' + } +}).addValue({ + name: 'max_year', + table: 'docente_test', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '<=', + type: 'integer', + field: 'ano_censo' + } +}).addValue({ + name: 'gender', + table: 'docente_test', + tableField: 'sexo', + resultField: 'gender_id', + where: { + relation: '=', + type: 'integer', + field: 'sexo' + } +}).addValue({ + name: 'ethnic_group', + table: 'docente_test', + tableField: 'cor_raca', + resultField: 'ethnic_group_id', + where: { + relation: '=', + type: 'integer', + field: 'cor_raca' + } +}).addValue({ + name: 'initial_training', + table: 'docente_test', + tableField: 'formacao_inicial_docente', + resultField: 'initial_training_id', + where: { + relation: '=', + type: 'integer', + field: 'formacao_inicial_docente' + } +}).addValue({ + name: 'pos_training', + table: 'docente_test', + tableField: 'formacao_pos_docente', + resultField: 'pos_training_id', + where: { + relation: '=', + type: 'integer', + field: 'formacao_pos_docente' + } +}).addValue({ + name: 'licentiate_degree', + table: 'docente_test', + tableField: 'formacao_licenciatura_docente', + resultField: 'licentiate_degree_id', + where: { + relation: '=', + type: 'integer', + field: 'formacao_licenciatura_docente' + } +}); + +teacherApp.get('/', rqf.parse(), (req, res, next) => { + req.sql.field('COUNT(DISTINCT docente.id_docente)', 'total') + .field("'Brasil'", 'name') + .field('docente.ano_censo', 'year') + .from('docente_test') + .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') + .group('docente.ano_censo') + .order('docente.ano_censo') + .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ + OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) \ + AND (docente.ano_censo <> 2009 or docente.escola_estado_id <> 42)'); // não devemos trazer SC em 2009. + + // if("education_level_mod" in req.dims) { + // req.hadEducationLevelMod = true; + // req.sql.where('docente.etapas_mod_ensino_segmento_id < 11'); + // } + + next(); +}, rqf.build(), query, addMissing(rqf), id2str.transform(), response('teacher')); + +module.exports = teacherApp; -- GitLab From 9864346662196eb376ffe5e709d561e56a3f0acd Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Mon, 12 Apr 2021 13:22:57 -0300 Subject: [PATCH 012/305] move teacher_temp.js to teacher.js --- src/libs/routes/teacher.js | 54 ++-- src/libs/routes/teacher_temp.js | 521 -------------------------------- 2 files changed, 27 insertions(+), 548 deletions(-) delete mode 100644 src/libs/routes/teacher_temp.js diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 88ec7a1e..24c7f278 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -48,14 +48,14 @@ teacherApp.use(cache('15 day')); // Returns a tuple of start and ending years of the complete enrollments dataset. teacherApp.get('/year_range', (req, res, next) => { - req.sql.from('docente') + req.sql.from('docente_test') .field('MIN(docente.ano_censo)', 'start_year') .field('MAX(docente.ano_censo)', 'end_year'); next(); }, query, response('range')); teacherApp.get('/years', (req, res, next) => { - req.sql.from('docente'). + req.sql.from('docente_test'). field('DISTINCT docente.ano_censo', 'year'); next(); }, query, response('years')); @@ -141,7 +141,7 @@ teacherApp.get('/rural_location', (req, res, next) => { }, response('rural_location')); teacherApp.get('/education_type', (req, res, next) => { - req.sql.from('docente') + req.sql.from('docente_test') .field('DISTINCT nivel_tipo_formacao', 'id') .order('id'); next(); @@ -225,7 +225,7 @@ rqf.addField({ where: false }).addValue({ name: 'adm_dependency', - table: 'docente', + table: 'docente_test', tableField: 'dependencia_adm_id', resultField: 'adm_dependency_id', where: { @@ -235,7 +235,7 @@ rqf.addField({ } }).addValue({ name: 'adm_dependency_detailed', - table: 'docente', + table: 'docente_test', tableField: 'dependencia_adm_priv', resultField: 'adm_dependency_detailed_id', where: { @@ -245,7 +245,7 @@ rqf.addField({ } }).addValue({ name: 'contract_type', - table: 'docente', + table: 'docente_test', tableField: 'tipo_contratacao', resultField: 'contract_type_id', where: { @@ -255,7 +255,7 @@ rqf.addField({ } }).addValue({ name: 'education_level_mod', - table: 'docente', + table: 'docente_test', tableField: 'etapas_mod_ensino_segmento_id', resultField: 'education_level_mod_id', where: { @@ -265,7 +265,7 @@ rqf.addField({ } }).addValue({ name: 'education_level_short', - table: 'docente', + table: 'docente_test', tableField: 'etapa_resumida', resultField: 'education_level_short_id', where: { @@ -275,7 +275,7 @@ rqf.addField({ } }).addValue({ name: 'education_type', - table: 'docente', + table: 'docente_test', tableField: 'nivel_tipo_formacao', resultField: 'education_type_id', where: { @@ -296,7 +296,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_regiao_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }).addValue({ name: 'mesoregion', @@ -312,7 +312,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }).addValue({ name: 'microregion', @@ -328,7 +328,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }).addValue({ name: 'state', @@ -343,7 +343,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_estado_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }).addValueToField({ name: 'city', @@ -358,7 +358,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }, 'dims').addValueToField({ name: 'city', @@ -373,7 +373,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }, 'filter').addValueToField({ name: 'school', @@ -388,7 +388,7 @@ rqf.addField({ join: { primary: ['id', 'ano_censo'], foreign: ['escola_id', 'ano_censo'], - foreignTable: 'docente' + foreignTable: 'docente_test' } }, 'dims').addValueToField({ name: 'school', @@ -403,11 +403,11 @@ rqf.addField({ join: { primary: ['id', 'ano_censo'], foreign: ['escola_id', 'ano_censo'], - foreignTable: 'docente' + foreignTable: 'docente_test' } }, 'filter').addValue({ name: 'location', - table: 'docente', + table: 'docente_test', tableField: 'localizacao_id', resultField: 'location_id', where: { @@ -417,7 +417,7 @@ rqf.addField({ } }).addValue({ name: 'rural_location', - table: 'docente', + table: 'docente_test', tableField: 'localidade_area_rural', resultField: 'rural_location_id', where: { @@ -427,7 +427,7 @@ rqf.addField({ } }).addValue({ name: 'min_year', - table: 'docente', + table: 'docente_test', tableField: 'ano_censo', resultField: 'year', where: { @@ -437,7 +437,7 @@ rqf.addField({ } }).addValue({ name: 'max_year', - table: 'docente', + table: 'docente_test', tableField: 'ano_censo', resultField: 'year', where: { @@ -447,7 +447,7 @@ rqf.addField({ } }).addValue({ name: 'gender', - table: 'docente', + table: 'docente_test', tableField: 'sexo', resultField: 'gender_id', where: { @@ -457,7 +457,7 @@ rqf.addField({ } }).addValue({ name: 'ethnic_group', - table: 'docente', + table: 'docente_test', tableField: 'cor_raca', resultField: 'ethnic_group_id', where: { @@ -467,7 +467,7 @@ rqf.addField({ } }).addValue({ name: 'initial_training', - table: 'docente', + table: 'docente_test', tableField: 'formacao_inicial_docente', resultField: 'initial_training_id', where: { @@ -477,7 +477,7 @@ rqf.addField({ } }).addValue({ name: 'pos_training', - table: 'docente', + table: 'docente_test', tableField: 'formacao_pos_docente', resultField: 'pos_training_id', where: { @@ -487,7 +487,7 @@ rqf.addField({ } }).addValue({ name: 'licentiate_degree', - table: 'docente', + table: 'docente_test', tableField: 'formacao_licenciatura_docente', resultField: 'licentiate_degree_id', where: { @@ -501,7 +501,7 @@ teacherApp.get('/', rqf.parse(), (req, res, next) => { req.sql.field('COUNT(DISTINCT docente.id_docente)', 'total') .field("'Brasil'", 'name') .field('docente.ano_censo', 'year') - .from('docente') + .from('docente_test') .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente.ano_censo') .order('docente.ano_censo') diff --git a/src/libs/routes/teacher_temp.js b/src/libs/routes/teacher_temp.js deleted file mode 100644 index 24c7f278..00000000 --- a/src/libs/routes/teacher_temp.js +++ /dev/null @@ -1,521 +0,0 @@ -/* -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/>. -*/ - -const express = require('express'); - -const teacherApp = express.Router(); - -const libs = `${process.cwd()}/libs`; - -const log = require(`${libs}/log`)(module); - -const squel = require('squel'); - -const query = require(`${libs}/middlewares/query`).query; - -const response = require(`${libs}/middlewares/response`); - -const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); - -const id2str = require(`${libs}/middlewares/id2str`); - -const config = require(`${libs}/config`); - -const addMissing = require(`${libs}/middlewares/addMissing`); - -const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware; - -let rqf = new ReqQueryFields(); - -teacherApp.use(cache('15 day')); - -// Returns a tuple of start and ending years of the complete enrollments dataset. -teacherApp.get('/year_range', (req, res, next) => { - req.sql.from('docente_test') - .field('MIN(docente.ano_censo)', 'start_year') - .field('MAX(docente.ano_censo)', 'end_year'); - next(); -}, query, response('range')); - -teacherApp.get('/years', (req, res, next) => { - req.sql.from('docente_test'). - field('DISTINCT docente.ano_censo', 'year'); - next(); -}, query, response('years')); - -teacherApp.get('/source', (req, res, next) => { - req.sql.from('fonte') - .field('fonte', 'source') - .where('tabela = \'docente\''); - next(); -}, query, response('source')); - -teacherApp.get('/adm_dependency_detailed', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 8; ++i) { - req.result.push({ - id: i, - name: id2str.admDependencyPriv(i) - }); - }; - next(); -}, response('adm_dependency_detailed')); - -teacherApp.get('/adm_dependency', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 4; ++i) { - req.result.push({ - id: i, - name: id2str.admDependency(i) - }); - }; - next(); -}, response('adm_dependency')); - -teacherApp.get('/education_level_mod', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 12; ++i) { - req.result.push({ - id: i, - name: id2str.educationLevelMod(i) - }); - } - req.result.push({ - id: 99, - name: id2str.educationLevelMod(99) - }); - next(); -}, response('education_level_mod')); - -teacherApp.get('/education_level_short', (req, res, next) => { - req.result = [ - {id: null, name: 'Não classificada'}, - {id: 1, name: 'Creche'}, - {id: 2, name: 'Pré-Escola'}, - {id: 3, name: 'Ensino Fundamental - anos iniciais'}, - {id: 4, name: 'Ensino Fundamental - anos finais'}, - {id: 5, name: 'Ensino Médio'}, - {id: 6, name: 'EJA'}, - {id: 7, name: 'EE exclusiva'} - ]; - next(); -}, response('education_level_short')); - -teacherApp.get('/location', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 2; ++i) { - req.result.push({ - id: i, - name: id2str.location(i) - }); - }; - next(); -}, response('location')); - -teacherApp.get('/rural_location', (req, res, next) => { - req.result = []; - for (let i = 1; i <= 8; i++) { - req.result.push({ - id: i, - name: id2str.ruralLocation(i) - }); - }; - next(); -}, response('rural_location')); - -teacherApp.get('/education_type', (req, res, next) => { - req.sql.from('docente_test') - .field('DISTINCT nivel_tipo_formacao', 'id') - .order('id'); - next(); -}, query, (req, res, next) => { - req.result.forEach((result) => { - result.name = id2str.educationType(result.id); - }); - next(); -}, response('education_type')); - -teacherApp.get('/gender', (req, res, next) => { - req.result = [ - {id: 1, name: 'Masculino'}, - {id: 2, name: 'Feminino'} - ]; - next(); -}, response('gender')); - - -teacherApp.get('/contract_type', (req, res, next) => { - req.result = [ - {id: 1, name: 'Concursado/Efetivo/Estável'}, - {id: 2, name: 'Contrato temporário'}, - {id: 3, name: 'Contrato terceirizado'}, - {id: 4, name: 'Contrato CLT'} - ]; - next(); -}, response('contract_type')); - -teacherApp.get('/ethnic_group', (req, res, next) => { - req.result = []; - for(let i = 0; i <=5; ++i) { - req.result.push({ - id: i, - name: id2str.ethnicGroup(i) - }); - } - next(); -}, response('ethnic_group')); - -teacherApp.get('/initial_training', (req, res, next) => { - req.result = []; - for(let i = 1; i <=5; ++i) { - req.result.push({ - id: i, - name: id2str.initialTraining(i) - }); - } - next(); -}, response('initial_training')); - -teacherApp.get('/pos_training', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 4; ++i) { - req.result.push({ - id: i, - name: id2str.posTraining(i) - }); - } - next(); -}, response('pos_training')); - -teacherApp.get('/licentiate_degree', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 3; ++i) { - req.result.push({ - id: i, - name: id2str.licentiateDegree(i) - }); - } - next(); -}, response('licentiate_degree')); - -rqf.addField({ - name: 'filter', - field: false, - where: true -}).addField({ - name: 'dims', - field: true, - where: false -}).addValue({ - name: 'adm_dependency', - table: 'docente_test', - tableField: 'dependencia_adm_id', - resultField: 'adm_dependency_id', - where: { - relation: '=', - type: 'integer', - field: 'dependencia_adm_id' - } -}).addValue({ - name: 'adm_dependency_detailed', - table: 'docente_test', - tableField: 'dependencia_adm_priv', - resultField: 'adm_dependency_detailed_id', - where: { - relation: '=', - type: 'integer', - field: 'dependencia_adm_priv' - } -}).addValue({ - name: 'contract_type', - table: 'docente_test', - tableField: 'tipo_contratacao', - resultField: 'contract_type_id', - where: { - relation: '=', - type: 'integer', - field: 'tipo_contratacao' - } -}).addValue({ - name: 'education_level_mod', - table: 'docente_test', - tableField: 'etapas_mod_ensino_segmento_id', - resultField: 'education_level_mod_id', - where: { - relation: '=', - type: 'integer', - field: 'etapas_mod_ensino_segmento_id' - } -}).addValue({ - name: 'education_level_short', - table: 'docente_test', - tableField: 'etapa_resumida', - resultField: 'education_level_short_id', - where: { - relation: '=', - type: 'integer', - field: 'etapa_resumida' - } -}).addValue({ - name: 'education_type', - table: 'docente_test', - tableField: 'nivel_tipo_formacao', - resultField: 'education_type_id', - where: { - relation: '=', - type: 'integer', - field: 'nivel_tipo_formacao' - } -}).addValue({ - name: 'region', - table: 'regiao', - tableField: ['nome', 'id'], - resultField: ['region_name', 'region_id'], - where: { - relation: '=', - type: 'integer', - field: 'id' - }, - join: { - primary: 'id', - foreign: 'escola_regiao_id', - foreignTable: 'docente_test' - } -}).addValue({ - name: 'mesoregion', - table: 'municipio', - tableField: ['nome_mesorregiao', 'mesorregiao_id'], - resultField: ['mesoregion_name', 'mesoregion_id'], - where: { - relation: '=', - type: 'integer', - field: 'mesorregiao_id', - table: 'municipio' - }, - join: { - primary: 'id', - foreign: 'escola_municipio_id', - foreignTable: 'docente_test' - } -}).addValue({ - name: 'microregion', - table: 'municipio', - tableField: ['nome_microrregiao', 'microrregiao_id'], - resultField: ['microregion_name', 'microregion_id'], - where: { - relation: '=', - type: 'integer', - field: 'microrregiao_id', - table: 'municipio' - }, - join: { - primary: 'id', - foreign: 'escola_municipio_id', - foreignTable: 'docente_test' - } -}).addValue({ - name: 'state', - table: 'estado', - tableField: ['nome', 'id'], - resultField: ['state_name', 'state_id'], - where: { - relation: '=', - type: 'integer', - field: 'id' - }, - join: { - primary: 'id', - foreign: 'escola_estado_id', - foreignTable: 'docente_test' - } -}).addValueToField({ - name: 'city', - table: 'municipio', - tableField: ['nome', 'id'], - resultField: ['city_name', 'city_id'], - where: { - relation: '=', - type: 'integer', - field: 'id' - }, - join: { - primary: 'id', - foreign: 'escola_municipio_id', - foreignTable: 'docente_test' - } -}, 'dims').addValueToField({ - name: 'city', - table: 'municipio', - tableField: 'nome', - resultField: 'city_name', - where: { - relation: '=', - type: 'integer', - field: 'id' - }, - join: { - primary: 'id', - foreign: 'escola_municipio_id', - foreignTable: 'docente_test' - } -}, 'filter').addValueToField({ - name: 'school', - table: 'escola', - tableField: ['nome_escola', 'id'], - resultField: ['school_name', 'school_id'], - where: { - relation: '=', - type: 'integer', - field: 'id' - }, - join: { - primary: ['id', 'ano_censo'], - foreign: ['escola_id', 'ano_censo'], - foreignTable: 'docente_test' - } -}, 'dims').addValueToField({ - name: 'school', - table: 'escola', - tableField: 'nome_escola', - resultField: 'school_name', - where: { - relation: '=', - type: 'integer', - field: 'id' - }, - join: { - primary: ['id', 'ano_censo'], - foreign: ['escola_id', 'ano_censo'], - foreignTable: 'docente_test' - } -}, 'filter').addValue({ - name: 'location', - table: 'docente_test', - tableField: 'localizacao_id', - resultField: 'location_id', - where: { - relation: '=', - type: 'integer', - field: 'localizacao_id' - } -}).addValue({ - name: 'rural_location', - table: 'docente_test', - tableField: 'localidade_area_rural', - resultField: 'rural_location_id', - where: { - relation: '=', - type: 'integer', - field: 'localidade_area_rural' - } -}).addValue({ - name: 'min_year', - table: 'docente_test', - tableField: 'ano_censo', - resultField: 'year', - where: { - relation: '>=', - type: 'integer', - field: 'ano_censo' - } -}).addValue({ - name: 'max_year', - table: 'docente_test', - tableField: 'ano_censo', - resultField: 'year', - where: { - relation: '<=', - type: 'integer', - field: 'ano_censo' - } -}).addValue({ - name: 'gender', - table: 'docente_test', - tableField: 'sexo', - resultField: 'gender_id', - where: { - relation: '=', - type: 'integer', - field: 'sexo' - } -}).addValue({ - name: 'ethnic_group', - table: 'docente_test', - tableField: 'cor_raca', - resultField: 'ethnic_group_id', - where: { - relation: '=', - type: 'integer', - field: 'cor_raca' - } -}).addValue({ - name: 'initial_training', - table: 'docente_test', - tableField: 'formacao_inicial_docente', - resultField: 'initial_training_id', - where: { - relation: '=', - type: 'integer', - field: 'formacao_inicial_docente' - } -}).addValue({ - name: 'pos_training', - table: 'docente_test', - tableField: 'formacao_pos_docente', - resultField: 'pos_training_id', - where: { - relation: '=', - type: 'integer', - field: 'formacao_pos_docente' - } -}).addValue({ - name: 'licentiate_degree', - table: 'docente_test', - tableField: 'formacao_licenciatura_docente', - resultField: 'licentiate_degree_id', - where: { - relation: '=', - type: 'integer', - field: 'formacao_licenciatura_docente' - } -}); - -teacherApp.get('/', rqf.parse(), (req, res, next) => { - req.sql.field('COUNT(DISTINCT docente.id_docente)', 'total') - .field("'Brasil'", 'name') - .field('docente.ano_censo', 'year') - .from('docente_test') - .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') - .group('docente.ano_censo') - .order('docente.ano_censo') - .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ - OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) \ - AND (docente.ano_censo <> 2009 or docente.escola_estado_id <> 42)'); // não devemos trazer SC em 2009. - - // if("education_level_mod" in req.dims) { - // req.hadEducationLevelMod = true; - // req.sql.where('docente.etapas_mod_ensino_segmento_id < 11'); - // } - - next(); -}, rqf.build(), query, addMissing(rqf), id2str.transform(), response('teacher')); - -module.exports = teacherApp; -- GitLab From fc6be487be47fa60c3e73c2b395dc810a93e524d Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Mon, 12 Apr 2021 13:57:10 -0300 Subject: [PATCH 013/305] fix teacher route --- src/libs/routes/teacher.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 24c7f278..2dd296f6 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -49,21 +49,21 @@ teacherApp.use(cache('15 day')); // Returns a tuple of start and ending years of the complete enrollments dataset. teacherApp.get('/year_range', (req, res, next) => { req.sql.from('docente_test') - .field('MIN(docente.ano_censo)', 'start_year') - .field('MAX(docente.ano_censo)', 'end_year'); + .field('MIN(docente_test.ano_censo)', 'start_year') + .field('MAX(docente_test.ano_censo)', 'end_year'); next(); }, query, response('range')); teacherApp.get('/years', (req, res, next) => { req.sql.from('docente_test'). - field('DISTINCT docente.ano_censo', 'year'); + field('DISTINCT docente_test.ano_censo', 'year'); next(); }, query, response('years')); teacherApp.get('/source', (req, res, next) => { req.sql.from('fonte') .field('fonte', 'source') - .where('tabela = \'docente\''); + .where('tabela = \'docente_test\''); next(); }, query, response('source')); @@ -498,17 +498,17 @@ rqf.addField({ }); teacherApp.get('/', rqf.parse(), (req, res, next) => { - req.sql.field('COUNT(DISTINCT docente.id_docente)', 'total') + req.sql.field('COUNT(DISTINCT docente_test.id_docente)', 'total') .field("'Brasil'", 'name') - .field('docente.ano_censo', 'year') + .field('docente_test.ano_censo', 'year') .from('docente_test') - .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') - .group('docente.ano_censo') - .order('docente.ano_censo') - .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ - OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) \ - AND (docente.ano_censo <> 2009 or docente.escola_estado_id <> 42)'); // não devemos trazer SC em 2009. + .join('turma', null, 'docente_test.turma_id=turma.id AND docente_test.ano_censo=turma.ano_censo') + .group('docente_test.ano_censo') + .order('docente_test.ano_censo') + .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ + ((docente_test.tipo_turma_id >= 0 AND docente_test.tipo_turma_id <= 3 AND docente_test.tipo_turma_atendimento_id is NULL) \ + OR ((docente_test.tipo_turma_atendimento_id = 1 OR docente_test.tipo_turma_atendimento_id = 2) AND docente_test.tipo_turma_id is NULL)) \ + AND (docente_test.ano_censo <> 2009 or docente_test.escola_estado_id <> 42)'); // não devemos trazer SC em 2009. // if("education_level_mod" in req.dims) { // req.hadEducationLevelMod = true; -- GitLab From 5de03d263ef64980e1a724b795f1dd05b5b23a83 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Tue, 13 Apr 2021 11:44:12 -0300 Subject: [PATCH 014/305] update docente table name --- src/libs/routes/disciplines.js | 94 +++++++++++++++++----------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 6da993ff..23aff6d9 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -48,14 +48,14 @@ disciplinesApp.use(cache('15 day')); // Returns a tuple of start and ending years of the complete enrollments dataset. disciplinesApp.get('/year_range', (req, res, next) => { - req.sql.from('docente') - .field('MIN(docente.ano_censo)', 'start_year') - .field('MAX(docente.ano_censo)', 'end_year'); + req.sql.from('docente_test') + .field('MIN(docente_test.ano_censo)', 'start_year') + .field('MAX(docente_test.ano_censo)', 'end_year'); next(); }, query, response('range')); disciplinesApp.get('/years', (req, res, next) => { - req.sql.from('docente'). + req.sql.from('docente_test'). field('DISTINCT docente.ano_censo', 'year'); next(); }, query, response('years')); @@ -141,7 +141,7 @@ disciplinesApp.get('/rural_location', (req, res, next) => { }, response('rural_location')); disciplinesApp.get('/education_type', (req, res, next) => { - req.sql.from('docente') + req.sql.from('docente_test') .field('DISTINCT nivel_tipo_formacao', 'id') .order('id'); next(); @@ -203,7 +203,7 @@ rqf.addField({ where: false }).addValue({ name: 'adm_dependency', - table: 'docente', + table: 'docente_test', tableField: 'dependencia_adm_id', resultField: 'adm_dependency_id', where: { @@ -213,7 +213,7 @@ rqf.addField({ } }).addValue({ name: 'adm_dependency_detailed', - table: 'docente', + table: 'docente_test', tableField: 'dependencia_adm_priv', resultField: 'adm_dependency_detailed_id', where: { @@ -223,7 +223,7 @@ rqf.addField({ } }).addValue({ name: 'contract_type', - table: 'docente', + table: 'docente_test', tableField: 'tipo_contratacao', resultField: 'contract_type_id', where: { @@ -233,7 +233,7 @@ rqf.addField({ } }).addValue({ name: 'education_level_mod', - table: 'docente', + table: 'docente_test', tableField: 'etapas_mod_ensino_segmento_id', resultField: 'education_level_mod_id', where: { @@ -243,7 +243,7 @@ rqf.addField({ } }).addValue({ name: 'education_level_short', - table: 'docente', + table: 'docente_test', tableField: 'etapa_resumida', resultField: 'education_level_short_id', where: { @@ -253,7 +253,7 @@ rqf.addField({ } }).addValue({ name: 'education_type', - table: 'docente', + table: 'docente_test', tableField: 'nivel_tipo_formacao', resultField: 'education_type_id', where: { @@ -274,7 +274,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_regiao_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }).addValue({ name: 'mesoregion', @@ -290,7 +290,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }).addValue({ name: 'microregion', @@ -306,7 +306,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }).addValue({ name: 'state', @@ -321,7 +321,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_estado_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }).addValueToField({ name: 'city', @@ -336,7 +336,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }, 'dims').addValueToField({ name: 'city', @@ -351,7 +351,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente' + foreignTable: 'docente_test' } }, 'filter').addValueToField({ name: 'school', @@ -366,7 +366,7 @@ rqf.addField({ join: { primary: ['id', 'ano_censo'], foreign: ['escola_id', 'ano_censo'], - foreignTable: 'docente' + foreignTable: 'docente_test' } }, 'dims').addValueToField({ name: 'school', @@ -381,11 +381,11 @@ rqf.addField({ join: { primary: ['id', 'ano_censo'], foreign: ['escola_id', 'ano_censo'], - foreignTable: 'docente' + foreignTable: 'docente_test' } }, 'filter').addValue({ name: 'location', - table: 'docente', + table: 'docente_test', tableField: 'localizacao_id', resultField: 'location_id', where: { @@ -395,7 +395,7 @@ rqf.addField({ } }).addValue({ name: 'rural_location', - table: 'docente', + table: 'docente_test', tableField: 'localidade_area_rural', resultField: 'rural_location_id', where: { @@ -405,7 +405,7 @@ rqf.addField({ } }).addValue({ name: 'min_year', - table: 'docente', + table: 'docente_test', tableField: 'ano_censo', resultField: 'year', where: { @@ -415,7 +415,7 @@ rqf.addField({ } }).addValue({ name: 'max_year', - table: 'docente', + table: 'docente_test', tableField: 'ano_censo', resultField: 'year', where: { @@ -425,7 +425,7 @@ rqf.addField({ } }).addValue({ name: 'gender', - table: 'docente', + table: 'docente_test', tableField: 'sexo', resultField: 'gender_id', where: { @@ -435,7 +435,7 @@ rqf.addField({ } }).addValue({ name: 'ethnic_group', - table: 'docente', + table: 'docente_test', tableField: 'cor_raca', resultField: 'ethnic_group_id', where: { @@ -445,7 +445,7 @@ rqf.addField({ } }).addValue({ name: 'discipline', - table: 'docente', + table: 'docente_test', tableField: '', resultField: '', where: { @@ -518,13 +518,13 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .field('SUM(adequacao_sociologia)', 'total_suitable_sociologia') .field("'Brasil'", 'name') - .field('docente.ano_censo', 'year') - .from('docente') - .group('docente.ano_censo') - .order('docente.ano_censo') - .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ - OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ + .field('docente_test.ano_censo', 'year') + .from('docente_test') + .group('docente_test.ano_censo') + .order('docente_test.ano_censo') + .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ + ((docente_test.tipo_turma_id >= 0 AND docente_test.tipo_turma_id <= 3 AND docente_test.tipo_turma_atendimento_id is NULL) \ + OR ((docente_test.tipo_turma_atendimento_id = 1 OR docente_test.tipo_turma_atendimento_id = 2) AND docente_test.tipo_turma_id is NULL)) AND \ etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); } else if ('discipline' in req.filter) { @@ -547,28 +547,28 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { req.sql.field(totalQuery, 'total') .field(totalSuitableQuery, 'total_suitable') .field("'Brasil'", 'name') - .field('docente.ano_censo', 'year') - .from('docente') + .field('docente_test.ano_censo', 'year') + .from('docente_test') // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') - .group('docente.ano_censo') - .order('docente.ano_censo') - .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ - OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ + .group('docente_test.ano_censo') + .order('docente_test.ano_censo') + .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ + ((docente_test.tipo_turma_id >= 0 AND docente_test.tipo_turma_id <= 3 AND docente_test.tipo_turma_atendimento_id is NULL) \ + OR ((docente_test.tipo_turma_atendimento_id = 1 OR docente_test.tipo_turma_atendimento_id = 2) AND docente_test.tipo_turma_id is NULL)) AND \ etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); } else { req.sql.field('SUM(n_disc)', 'total') .field('SUM(n_disc_adequada)', 'total_suitable') .field("'Brasil'", 'name') - .field('docente.ano_censo', 'year') - .from('docente') + .field('docente_test.ano_censo', 'year') + .from('docente_test') // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') - .group('docente.ano_censo') - .order('docente.ano_censo') - .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ - OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ + .group('docente_test.ano_censo') + .order('docente_test.ano_censo') + .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ + ((docente_test.tipo_turma_id >= 0 AND docente_test.tipo_turma_id <= 3 AND docente_test.tipo_turma_atendimento_id is NULL) \ + OR ((docente_test.tipo_turma_atendimento_id = 1 OR docente_test.tipo_turma_atendimento_id = 2) AND docente_test.tipo_turma_id is NULL)) AND \ etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); } -- GitLab From 355520f71acaf6a3c190f70ecd3b71053a8a0654 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Wed, 14 Apr 2021 10:31:18 -0300 Subject: [PATCH 015/305] uncomment join lines in disciplines.js --- src/libs/routes/disciplines.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 23aff6d9..8096081b 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -549,7 +549,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .field("'Brasil'", 'name') .field('docente_test.ano_censo', 'year') .from('docente_test') - // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') + .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente_test.ano_censo') .order('docente_test.ano_censo') .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ @@ -563,7 +563,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .field("'Brasil'", 'name') .field('docente_test.ano_censo', 'year') .from('docente_test') - // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') + .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente_test.ano_censo') .order('docente_test.ano_censo') .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ -- GitLab From 13ddd94dcc6e7b647d054894620883786b22d72f Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Wed, 14 Apr 2021 10:36:52 -0300 Subject: [PATCH 016/305] comment join lines in disciplines.js --- src/libs/routes/disciplines.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 8096081b..23aff6d9 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -549,7 +549,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .field("'Brasil'", 'name') .field('docente_test.ano_censo', 'year') .from('docente_test') - .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') + // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente_test.ano_censo') .order('docente_test.ano_censo') .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ @@ -563,7 +563,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .field("'Brasil'", 'name') .field('docente_test.ano_censo', 'year') .from('docente_test') - .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') + // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente_test.ano_censo') .order('docente_test.ano_censo') .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ -- GitLab From 6bf72edd8ca2fe961c24d898e4623b71c235acbb Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Thu, 15 Apr 2021 11:12:16 -0300 Subject: [PATCH 017/305] change disciplines.js to show req info --- src/libs/routes/disciplines.js | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 23aff6d9..6997bb21 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -625,28 +625,28 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { let disciplinesNotSuitable = []; let disciplinesSuitable = []; - req.result.forEach((r) => { - let objNotSuitable = { - total: parseInt(r.total) - parseInt(r.total_suitable), - suitable: 0 - } - - let objSuitable = { - total: parseInt(r.total_suitable), - suitable: 1 - } - Object.keys(r).forEach(k => { - if (k !== 'total' && k !== 'total_suitable') { - objNotSuitable[k] = r[k]; - objSuitable[k] = r[k]; - } - }) - - disciplinesNotSuitable.push(objNotSuitable) - disciplinesSuitable.push(objSuitable) - }) - - req.result = disciplinesNotSuitable.concat(disciplinesSuitable); + // req.result.forEach((r) => { + // let objNotSuitable = { + // total: parseInt(r.total) - parseInt(r.total_suitable), + // suitable: 0 + // } + + // let objSuitable = { + // total: parseInt(r.total_suitable), + // suitable: 1 + // } + // Object.keys(r).forEach(k => { + // if (k !== 'total' && k !== 'total_suitable') { + // objNotSuitable[k] = r[k]; + // objSuitable[k] = r[k]; + // } + // }) + + // disciplinesNotSuitable.push(objNotSuitable) + // disciplinesSuitable.push(objSuitable) + // }) + + // req.result = disciplinesNotSuitable.concat(disciplinesSuitable); next(); -- GitLab From 483a79febf63a53fc24b89148647645cd012c1b2 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Thu, 15 Apr 2021 11:45:41 -0300 Subject: [PATCH 018/305] uncomment suitable/notSuitable section in disciplines.js --- src/libs/routes/disciplines.js | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 6997bb21..23aff6d9 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -625,28 +625,28 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { let disciplinesNotSuitable = []; let disciplinesSuitable = []; - // req.result.forEach((r) => { - // let objNotSuitable = { - // total: parseInt(r.total) - parseInt(r.total_suitable), - // suitable: 0 - // } - - // let objSuitable = { - // total: parseInt(r.total_suitable), - // suitable: 1 - // } - // Object.keys(r).forEach(k => { - // if (k !== 'total' && k !== 'total_suitable') { - // objNotSuitable[k] = r[k]; - // objSuitable[k] = r[k]; - // } - // }) - - // disciplinesNotSuitable.push(objNotSuitable) - // disciplinesSuitable.push(objSuitable) - // }) - - // req.result = disciplinesNotSuitable.concat(disciplinesSuitable); + req.result.forEach((r) => { + let objNotSuitable = { + total: parseInt(r.total) - parseInt(r.total_suitable), + suitable: 0 + } + + let objSuitable = { + total: parseInt(r.total_suitable), + suitable: 1 + } + Object.keys(r).forEach(k => { + if (k !== 'total' && k !== 'total_suitable') { + objNotSuitable[k] = r[k]; + objSuitable[k] = r[k]; + } + }) + + disciplinesNotSuitable.push(objNotSuitable) + disciplinesSuitable.push(objSuitable) + }) + + req.result = disciplinesNotSuitable.concat(disciplinesSuitable); next(); -- GitLab From e73a524d84b8fe7054ed6dbb5f60af5727106d84 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 16 Apr 2021 11:17:51 -0300 Subject: [PATCH 019/305] add n_disc/total field to sql request --- src/libs/routes/disciplines.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 23aff6d9..0383965e 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -460,7 +460,9 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { // delete req.filter.discipline; delete req.dims.discipline; - req.sql.field('SUM(quimica_not_null)', 'total_quimica') + req.sql.field('SUM(n_disc)', 'total') + + .field('SUM(quimica_not_null)', 'total_quimica') .field('SUM(adequacao_quimica)', 'total_suitable_quimica') .field('SUM(fisica_not_null)', 'total_fisica') @@ -647,8 +649,6 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { }) req.result = disciplinesNotSuitable.concat(disciplinesSuitable); - - next(); }, response('disciplines')); -- GitLab From d693bdca587a0e52d6499ada4fe66d0e601d4364 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 16 Apr 2021 12:08:22 -0300 Subject: [PATCH 020/305] add n_disc_adequada/total_suitable field to sql request --- src/libs/routes/disciplines.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 0383965e..09584a42 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -461,6 +461,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { delete req.dims.discipline; req.sql.field('SUM(n_disc)', 'total') + .field('SUM(n_disc_adequada)', 'total_suitable') .field('SUM(quimica_not_null)', 'total_quimica') .field('SUM(adequacao_quimica)', 'total_suitable_quimica') -- GitLab From 96afaefc6b18f8bead9856e902b30d5a20e72dec Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 16 Apr 2021 18:30:44 -0300 Subject: [PATCH 021/305] add teacher adequacy to list of ids --- src/libs/convert/teacherAdequacy.js | 28 ++++++++++++++++++++++++++++ src/libs/middlewares/id2str.js | 7 +++++-- src/libs/routes/disciplines.js | 11 +++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/libs/convert/teacherAdequacy.js diff --git a/src/libs/convert/teacherAdequacy.js b/src/libs/convert/teacherAdequacy.js new file mode 100644 index 00000000..7cd21cbb --- /dev/null +++ b/src/libs/convert/teacherAdequacy.js @@ -0,0 +1,28 @@ +/* +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 teacherAdequacy(id) { + switch (id) { + case 0: + return 'Formação não adequada'; + case 1: + return 'Formação adequada'; + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index b86232ca..af4995e9 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -89,6 +89,7 @@ const finishUniversity = require(`${libs}/convert/finishUniversity`); const initialTraining = require(`${libs}/convert/initialTraining`); const posTraining = require(`${libs}/convert/posTraining`); const licentiateDegree = require(`${libs}/convert/licentiateDegree`); +const teacherAdequacy = require(`${libs}/convert/teacherAdequacy`); const ids = { gender_id: gender, @@ -169,7 +170,8 @@ const ids = { finish_id: finishUniversity, initial_training_id: initialTraining, pos_training_id: posTraining, - licentiate_degree_id: licentiateDegree + licentiate_degree_id: licentiateDegree, + teacher_adequacy_id: teacherAdequacy }; function transform(removeId=false) { @@ -277,5 +279,6 @@ module.exports = { finishUniversity, initialTraining, posTraining, - licentiateDegree + licentiateDegree, + teacherAdequacy }; diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 09584a42..43b7dd6e 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -193,6 +193,17 @@ disciplinesApp.get('/discipline', (req, res, next) => { next(); }, response('discipline')) +disciplinesApp.get('/discipline', (req, res, next) => { + req.result = []; + for (let i = 0; i <= 1; i++) { + req.result.push({ + id: i, + name: id2str.teacherAdequacy(i) + }) + } + next(); +}, response('discipline')) + rqf.addField({ name: 'filter', field: false, -- GitLab From e3fc87a410ea3097990b17eadbb1b63b45275b04 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 16 Apr 2021 18:42:20 -0300 Subject: [PATCH 022/305] change teacher adequacy route to teacher_adequacy --- src/libs/routes/disciplines.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 43b7dd6e..f1ec9244 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -193,7 +193,7 @@ disciplinesApp.get('/discipline', (req, res, next) => { next(); }, response('discipline')) -disciplinesApp.get('/discipline', (req, res, next) => { +disciplinesApp.get('/teacher_adequacy', (req, res, next) => { req.result = []; for (let i = 0; i <= 1; i++) { req.result.push({ @@ -202,7 +202,7 @@ disciplinesApp.get('/discipline', (req, res, next) => { }) } next(); -}, response('discipline')) +}, response('teacher_adequacy')) rqf.addField({ name: 'filter', -- GitLab From 1c9a6f0efd5e76329e7215ce09890c34b73ab8f6 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 16 Apr 2021 18:49:27 -0300 Subject: [PATCH 023/305] add teacher_adequacy field to rqf --- src/libs/routes/disciplines.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index f1ec9244..04aadb15 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -464,6 +464,16 @@ rqf.addField({ type: 'integer', field: '' } +}).addValue({ + name: 'teacher_adequacy', + table: 'docente_test', + tableField: '', + resultField: '', + where: { + relation: '=', + type: 'integer', + field: '' + } }); disciplinesApp.get('/', rqf.parse(), (req, res, next) => { -- GitLab From 1b52c39a20afcebb5c6dc27d39e3c75bcd5dcf7e Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 16 Apr 2021 19:00:01 -0300 Subject: [PATCH 024/305] add resultField to teacher_adequacy --- src/libs/routes/disciplines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 04aadb15..24a4d0bf 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -468,7 +468,7 @@ rqf.addField({ name: 'teacher_adequacy', table: 'docente_test', tableField: '', - resultField: '', + resultField: 'teacher_adequacy_name', where: { relation: '=', type: 'integer', -- GitLab From de8e9175b6cd28586c88f7143b272c0eef53efd5 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 16 Apr 2021 19:07:03 -0300 Subject: [PATCH 025/305] concatenate suitable/not-suitable disciplines with req.result --- src/libs/routes/disciplines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 24a4d0bf..179fe4db 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -670,7 +670,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { disciplinesSuitable.push(objSuitable) }) - req.result = disciplinesNotSuitable.concat(disciplinesSuitable); + req.result = req.result.concat(disciplinesNotSuitable).concat(disciplinesSuitable); next(); }, response('disciplines')); -- GitLab From 3ea1cf05e9bed64730d9b45fabbaf3b960a6b7e5 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 16 Apr 2021 19:11:17 -0300 Subject: [PATCH 026/305] comment suitable disciplines section --- src/libs/routes/disciplines.js | 50 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 179fe4db..10e03941 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -646,31 +646,31 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { req.result = results; } else { */} - let disciplinesNotSuitable = []; - let disciplinesSuitable = []; - - req.result.forEach((r) => { - let objNotSuitable = { - total: parseInt(r.total) - parseInt(r.total_suitable), - suitable: 0 - } - - let objSuitable = { - total: parseInt(r.total_suitable), - suitable: 1 - } - Object.keys(r).forEach(k => { - if (k !== 'total' && k !== 'total_suitable') { - objNotSuitable[k] = r[k]; - objSuitable[k] = r[k]; - } - }) - - disciplinesNotSuitable.push(objNotSuitable) - disciplinesSuitable.push(objSuitable) - }) - - req.result = req.result.concat(disciplinesNotSuitable).concat(disciplinesSuitable); + // let disciplinesNotSuitable = []; + // let disciplinesSuitable = []; + + // req.result.forEach((r) => { + // let objNotSuitable = { + // total: parseInt(r.total) - parseInt(r.total_suitable), + // suitable: 0 + // } + + // let objSuitable = { + // total: parseInt(r.total_suitable), + // suitable: 1 + // } + // Object.keys(r).forEach(k => { + // if (k !== 'total' && k !== 'total_suitable') { + // objNotSuitable[k] = r[k]; + // objSuitable[k] = r[k]; + // } + // }) + + // disciplinesNotSuitable.push(objNotSuitable) + // disciplinesSuitable.push(objSuitable) + // }) + + // req.result = disciplinesNotSuitable.concat(disciplinesSuitable); next(); }, response('disciplines')); -- GitLab From ae7ff0d79ecbc9a7305065fcb4705c2d75a2db28 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 16 Apr 2021 19:15:04 -0300 Subject: [PATCH 027/305] comment teacher_adequacy sections --- src/libs/routes/disciplines.js | 42 ++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 10e03941..4e1eb72b 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -193,16 +193,16 @@ disciplinesApp.get('/discipline', (req, res, next) => { next(); }, response('discipline')) -disciplinesApp.get('/teacher_adequacy', (req, res, next) => { - req.result = []; - for (let i = 0; i <= 1; i++) { - req.result.push({ - id: i, - name: id2str.teacherAdequacy(i) - }) - } - next(); -}, response('teacher_adequacy')) +// disciplinesApp.get('/teacher_adequacy', (req, res, next) => { +// req.result = []; +// for (let i = 0; i <= 1; i++) { +// req.result.push({ +// id: i, +// name: id2str.teacherAdequacy(i) +// }) +// } +// next(); +// }, response('teacher_adequacy')) rqf.addField({ name: 'filter', @@ -464,18 +464,20 @@ rqf.addField({ type: 'integer', field: '' } -}).addValue({ - name: 'teacher_adequacy', - table: 'docente_test', - tableField: '', - resultField: 'teacher_adequacy_name', - where: { - relation: '=', - type: 'integer', - field: '' - } }); +// .addValue({ +// name: 'teacher_adequacy', +// table: 'docente_test', +// tableField: '', +// resultField: 'teacher_adequacy_name', +// where: { +// relation: '=', +// type: 'integer', +// field: '' +// } +// }); + disciplinesApp.get('/', rqf.parse(), (req, res, next) => { if ('discipline' in req.dims) { // delete req.filter.discipline; -- GitLab From e8c7a9f9493f1c3d513b908e8b6336639ad7fbfe Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 16 Apr 2021 19:57:07 -0300 Subject: [PATCH 028/305] remove teacherAdequacy --- src/libs/convert/teacherAdequacy.js | 28 ----------- src/libs/middlewares/id2str.js | 7 +-- src/libs/routes/disciplines.js | 73 ++++++++++------------------- 3 files changed, 27 insertions(+), 81 deletions(-) delete mode 100644 src/libs/convert/teacherAdequacy.js diff --git a/src/libs/convert/teacherAdequacy.js b/src/libs/convert/teacherAdequacy.js deleted file mode 100644 index 7cd21cbb..00000000 --- a/src/libs/convert/teacherAdequacy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* -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 teacherAdequacy(id) { - switch (id) { - case 0: - return 'Formação não adequada'; - case 1: - return 'Formação adequada'; - } -}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index af4995e9..b86232ca 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -89,7 +89,6 @@ const finishUniversity = require(`${libs}/convert/finishUniversity`); const initialTraining = require(`${libs}/convert/initialTraining`); const posTraining = require(`${libs}/convert/posTraining`); const licentiateDegree = require(`${libs}/convert/licentiateDegree`); -const teacherAdequacy = require(`${libs}/convert/teacherAdequacy`); const ids = { gender_id: gender, @@ -170,8 +169,7 @@ const ids = { finish_id: finishUniversity, initial_training_id: initialTraining, pos_training_id: posTraining, - licentiate_degree_id: licentiateDegree, - teacher_adequacy_id: teacherAdequacy + licentiate_degree_id: licentiateDegree }; function transform(removeId=false) { @@ -279,6 +277,5 @@ module.exports = { finishUniversity, initialTraining, posTraining, - licentiateDegree, - teacherAdequacy + licentiateDegree }; diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 4e1eb72b..09584a42 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -193,17 +193,6 @@ disciplinesApp.get('/discipline', (req, res, next) => { next(); }, response('discipline')) -// disciplinesApp.get('/teacher_adequacy', (req, res, next) => { -// req.result = []; -// for (let i = 0; i <= 1; i++) { -// req.result.push({ -// id: i, -// name: id2str.teacherAdequacy(i) -// }) -// } -// next(); -// }, response('teacher_adequacy')) - rqf.addField({ name: 'filter', field: false, @@ -466,18 +455,6 @@ rqf.addField({ } }); -// .addValue({ -// name: 'teacher_adequacy', -// table: 'docente_test', -// tableField: '', -// resultField: 'teacher_adequacy_name', -// where: { -// relation: '=', -// type: 'integer', -// field: '' -// } -// }); - disciplinesApp.get('/', rqf.parse(), (req, res, next) => { if ('discipline' in req.dims) { // delete req.filter.discipline; @@ -648,31 +625,31 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { req.result = results; } else { */} - // let disciplinesNotSuitable = []; - // let disciplinesSuitable = []; - - // req.result.forEach((r) => { - // let objNotSuitable = { - // total: parseInt(r.total) - parseInt(r.total_suitable), - // suitable: 0 - // } - - // let objSuitable = { - // total: parseInt(r.total_suitable), - // suitable: 1 - // } - // Object.keys(r).forEach(k => { - // if (k !== 'total' && k !== 'total_suitable') { - // objNotSuitable[k] = r[k]; - // objSuitable[k] = r[k]; - // } - // }) - - // disciplinesNotSuitable.push(objNotSuitable) - // disciplinesSuitable.push(objSuitable) - // }) - - // req.result = disciplinesNotSuitable.concat(disciplinesSuitable); + let disciplinesNotSuitable = []; + let disciplinesSuitable = []; + + req.result.forEach((r) => { + let objNotSuitable = { + total: parseInt(r.total) - parseInt(r.total_suitable), + suitable: 0 + } + + let objSuitable = { + total: parseInt(r.total_suitable), + suitable: 1 + } + Object.keys(r).forEach(k => { + if (k !== 'total' && k !== 'total_suitable') { + objNotSuitable[k] = r[k]; + objSuitable[k] = r[k]; + } + }) + + disciplinesNotSuitable.push(objNotSuitable) + disciplinesSuitable.push(objSuitable) + }) + + req.result = disciplinesNotSuitable.concat(disciplinesSuitable); next(); }, response('disciplines')); -- GitLab From dd15119b7c44308632d148ecad3897d93840a70b Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 19 Apr 2021 12:47:05 -0300 Subject: [PATCH 029/305] comment rqf build section --- src/libs/routes/disciplines.js | 50 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 09584a42..ebdba4c7 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -625,31 +625,31 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { req.result = results; } else { */} - let disciplinesNotSuitable = []; - let disciplinesSuitable = []; - - req.result.forEach((r) => { - let objNotSuitable = { - total: parseInt(r.total) - parseInt(r.total_suitable), - suitable: 0 - } - - let objSuitable = { - total: parseInt(r.total_suitable), - suitable: 1 - } - Object.keys(r).forEach(k => { - if (k !== 'total' && k !== 'total_suitable') { - objNotSuitable[k] = r[k]; - objSuitable[k] = r[k]; - } - }) - - disciplinesNotSuitable.push(objNotSuitable) - disciplinesSuitable.push(objSuitable) - }) - - req.result = disciplinesNotSuitable.concat(disciplinesSuitable); + // let disciplinesNotSuitable = []; + // let disciplinesSuitable = []; + + // req.result.forEach((r) => { + // let objNotSuitable = { + // total: parseInt(r.total) - parseInt(r.total_suitable), + // suitable: 0 + // } + + // let objSuitable = { + // total: parseInt(r.total_suitable), + // suitable: 1 + // } + // Object.keys(r).forEach(k => { + // if (k !== 'total' && k !== 'total_suitable') { + // objNotSuitable[k] = r[k]; + // objSuitable[k] = r[k]; + // } + // }) + + // disciplinesNotSuitable.push(objNotSuitable) + // disciplinesSuitable.push(objSuitable) + // }) + + // req.result = disciplinesNotSuitable.concat(disciplinesSuitable); next(); }, response('disciplines')); -- GitLab From 86d00ce3628c056b2a8843c43837c38e0aedf791 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 19 Apr 2021 12:53:47 -0300 Subject: [PATCH 030/305] uncomment rqf build section --- src/libs/routes/disciplines.js | 50 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index ebdba4c7..09584a42 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -625,31 +625,31 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { req.result = results; } else { */} - // let disciplinesNotSuitable = []; - // let disciplinesSuitable = []; - - // req.result.forEach((r) => { - // let objNotSuitable = { - // total: parseInt(r.total) - parseInt(r.total_suitable), - // suitable: 0 - // } - - // let objSuitable = { - // total: parseInt(r.total_suitable), - // suitable: 1 - // } - // Object.keys(r).forEach(k => { - // if (k !== 'total' && k !== 'total_suitable') { - // objNotSuitable[k] = r[k]; - // objSuitable[k] = r[k]; - // } - // }) - - // disciplinesNotSuitable.push(objNotSuitable) - // disciplinesSuitable.push(objSuitable) - // }) - - // req.result = disciplinesNotSuitable.concat(disciplinesSuitable); + let disciplinesNotSuitable = []; + let disciplinesSuitable = []; + + req.result.forEach((r) => { + let objNotSuitable = { + total: parseInt(r.total) - parseInt(r.total_suitable), + suitable: 0 + } + + let objSuitable = { + total: parseInt(r.total_suitable), + suitable: 1 + } + Object.keys(r).forEach(k => { + if (k !== 'total' && k !== 'total_suitable') { + objNotSuitable[k] = r[k]; + objSuitable[k] = r[k]; + } + }) + + disciplinesNotSuitable.push(objNotSuitable) + disciplinesSuitable.push(objSuitable) + }) + + req.result = disciplinesNotSuitable.concat(disciplinesSuitable); next(); }, response('disciplines')); -- GitLab From b5291742e9a2b7f11fc5780d2d44f6d469017d57 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Thu, 22 Apr 2021 09:51:11 -0300 Subject: [PATCH 031/305] uncomment state filter section --- src/libs/routes/disciplines.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 09584a42..aba478ec 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -579,7 +579,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { }, rqf.build(), query, id2str.transform(), (req, res, next) => { let filters = Object.keys(req.filter) - {/*if(filters.includes("state")) { + if(filters.includes("state")) { const disciplinesDB = ['quimica', 'fisica', 'matematica', 'biologia', 'ciencias', 'lingua_portuguesa', 'lingua_inglesa', 'lingua_espanhola', 'lingua_francesa', 'lingua_outra', 'lingua_indigena', 'artes', 'educacao_fisica', 'historia', 'geografia', 'filosofia', 'ensino_religioso', 'estudos_sociais', 'sociologia'] @@ -624,7 +624,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { req.result = results; } - else { */} + else { let disciplinesNotSuitable = []; let disciplinesSuitable = []; -- GitLab From 847784f8606323775cbecb95231d0fb694c13feb Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Thu, 22 Apr 2021 10:27:33 -0300 Subject: [PATCH 032/305] fix brackets --- src/libs/routes/disciplines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index aba478ec..173b93d1 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -651,7 +651,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { req.result = disciplinesNotSuitable.concat(disciplinesSuitable); next(); -}, response('disciplines')); +}}, response('disciplines')); module.exports = disciplinesApp; -- GitLab From fe470a42c1cf71312d63338cfd1631d9f4363fcb Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 23 Apr 2021 11:36:12 -0300 Subject: [PATCH 033/305] comment state filter section --- src/libs/routes/disciplines.js | 84 +++++++++++++++++----------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 173b93d1..e42cdc63 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -579,52 +579,52 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { }, rqf.build(), query, id2str.transform(), (req, res, next) => { let filters = Object.keys(req.filter) - if(filters.includes("state")) { - const disciplinesDB = ['quimica', 'fisica', 'matematica', 'biologia', 'ciencias', 'lingua_portuguesa', 'lingua_inglesa', 'lingua_espanhola', - 'lingua_francesa', 'lingua_outra', 'lingua_indigena', 'artes', 'educacao_fisica', 'historia', 'geografia', 'filosofia', 'ensino_religioso', - 'estudos_sociais', 'sociologia'] - const disciplinesAPI = ["Química", "Física", "Matemática", "Biologia", "Ciências", "Língua Portuguesa", "Língua Estrangeira – Inglês", - "Língua Estrangeira - Espanhol","Língua Estrangeira - Francês", "Língua Estrangeira - Outras", "Língua Indígena", "Arte", "Educação Física", "História", - "Geografia", "Filosofia", "Ensino religioso", "Estudos Sociais", "Sociologia"] + // if(filters.includes("state")) { + // const disciplinesDB = ['quimica', 'fisica', 'matematica', 'biologia', 'ciencias', 'lingua_portuguesa', 'lingua_inglesa', 'lingua_espanhola', + // 'lingua_francesa', 'lingua_outra', 'lingua_indigena', 'artes', 'educacao_fisica', 'historia', 'geografia', 'filosofia', 'ensino_religioso', + // 'estudos_sociais', 'sociologia'] + // const disciplinesAPI = ["Química", "Física", "Matemática", "Biologia", "Ciências", "Língua Portuguesa", "Língua Estrangeira – Inglês", + // "Língua Estrangeira - Espanhol","Língua Estrangeira - Francês", "Língua Estrangeira - Outras", "Língua Indígena", "Arte", "Educação Física", "História", + // "Geografia", "Filosofia", "Ensino religioso", "Estudos Sociais", "Sociologia"] - let jsonKeys = [] - let results = [] - req.result.forEach((r) => { - jsonKeys = Object.keys(r) + // let jsonKeys = [] + // let results = [] + // req.result.forEach((r) => { + // jsonKeys = Object.keys(r) - let i - let size = jsonKeys.length - 2 // Last two infos are "name" and "year" - for(i = 0; i < size; i++) { - let total_name = jsonKeys[i] - let suitable_name = jsonKeys[i + 1] + // let i + // let size = jsonKeys.length - 2 // Last two infos are "name" and "year" + // for(i = 0; i < size; i++) { + // let total_name = jsonKeys[i] + // let suitable_name = jsonKeys[i + 1] - // Calculates percentage - let percentage = r[suitable_name] / r[total_name] - percentage = percentage * 100 - percentage = percentage.toFixed(1) // Rounds to 1 digit after comma, returns string - percentage = percentage.replace(".", ",") + "%" - - // Parses name - total_name = total_name.replace("total_", "") - let discipline_index = disciplinesDB.indexOf(total_name) - let discipline_name = disciplinesAPI[discipline_index] - - let obj = { - total: percentage, - name: r["name"], - year: r["year"], - discipline_id: discipline_index + 1, // Convert function starts at 1, not at 0 - discipline_name: discipline_name - } - results.push(obj) + // // Calculates percentage + // let percentage = r[suitable_name] / r[total_name] + // percentage = percentage * 100 + // percentage = percentage.toFixed(1) // Rounds to 1 digit after comma, returns string + // percentage = percentage.replace(".", ",") + "%" + + // // Parses name + // total_name = total_name.replace("total_", "") + // let discipline_index = disciplinesDB.indexOf(total_name) + // let discipline_name = disciplinesAPI[discipline_index] + + // let obj = { + // total: percentage, + // name: r["name"], + // year: r["year"], + // discipline_id: discipline_index + 1, // Convert function starts at 1, not at 0 + // discipline_name: discipline_name + // } + // results.push(obj) - i++; // Ignore next, it's a suitable already used - } - }) + // i++; // Ignore next, it's a suitable already used + // } + // }) - req.result = results; - } - else { + // req.result = results; + // } + // else { let disciplinesNotSuitable = []; let disciplinesSuitable = []; @@ -651,7 +651,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { req.result = disciplinesNotSuitable.concat(disciplinesSuitable); next(); -}}, response('disciplines')); +}, response('disciplines')); module.exports = disciplinesApp; -- GitLab From 0b0cff6e34a29ce780ccdbd83fe0ea1ebf244284 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 26 Apr 2021 09:32:30 -0300 Subject: [PATCH 034/305] comment discipline field value --- src/libs/routes/disciplines.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index e42cdc63..2188decb 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -443,18 +443,20 @@ rqf.addField({ type: 'integer', field: 'cor_raca' } -}).addValue({ - name: 'discipline', - table: 'docente_test', - tableField: '', - resultField: '', - where: { - relation: '=', - type: 'integer', - field: '' - } }); +// .addValue({ +// name: 'discipline', +// table: 'docente_test', +// tableField: '', +// resultField: '', +// where: { +// relation: '=', +// type: 'integer', +// field: '' +// } +// }); + disciplinesApp.get('/', rqf.parse(), (req, res, next) => { if ('discipline' in req.dims) { // delete req.filter.discipline; -- GitLab From 0aef6776e3e72ad3c4133d62e17bfdde6b85781b Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 26 Apr 2021 10:40:14 -0300 Subject: [PATCH 035/305] uncomment discipline field value --- src/libs/routes/disciplines.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 2188decb..e42cdc63 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -443,20 +443,18 @@ rqf.addField({ type: 'integer', field: 'cor_raca' } +}).addValue({ + name: 'discipline', + table: 'docente_test', + tableField: '', + resultField: '', + where: { + relation: '=', + type: 'integer', + field: '' + } }); -// .addValue({ -// name: 'discipline', -// table: 'docente_test', -// tableField: '', -// resultField: '', -// where: { -// relation: '=', -// type: 'integer', -// field: '' -// } -// }); - disciplinesApp.get('/', rqf.parse(), (req, res, next) => { if ('discipline' in req.dims) { // delete req.filter.discipline; -- GitLab From 1c93367e4e7948d19bab78355cabeb0e1e400d73 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 26 Apr 2021 14:54:10 -0300 Subject: [PATCH 036/305] add discipline_name to route request result --- src/libs/routes/disciplines.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index e42cdc63..33d26c8f 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -631,12 +631,14 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { req.result.forEach((r) => { let objNotSuitable = { total: parseInt(r.total) - parseInt(r.total_suitable), - suitable: 0 + suitable: 0, + discipline_name: 'Formação não adequada' } let objSuitable = { total: parseInt(r.total_suitable), - suitable: 1 + suitable: 1, + discipline_name: 'Formação adequada' } Object.keys(r).forEach(k => { if (k !== 'total' && k !== 'total_suitable') { -- GitLab From 1a6007466d94fabd9df96fdb9df467e40a782e7c Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 14 Jun 2021 11:44:59 -0300 Subject: [PATCH 037/305] add table to sql select --- src/libs/routes/cub.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/routes/cub.js b/src/libs/routes/cub.js index 3707e7f0..8adaa532 100644 --- a/src/libs/routes/cub.js +++ b/src/libs/routes/cub.js @@ -136,6 +136,7 @@ cubApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { if (req.filter.size || req.filter.dims) { if ('state' in req.filter || 'state' in req.dims) { req.sql.from('cub') + .from('estado') .field('cub.estado_id', 'cod_uf') .field('estado.sigla', 'sigla_uf') .field('cub.tipo_preco', 'tipo_preco') -- GitLab From 8a7e8bceae79a4f62418cd0f8d789d6156ed0d6a Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 14 Jun 2021 13:46:42 -0300 Subject: [PATCH 038/305] remove duplicate join from select --- src/libs/routes/cub.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/routes/cub.js b/src/libs/routes/cub.js index 3707e7f0..944e784d 100644 --- a/src/libs/routes/cub.js +++ b/src/libs/routes/cub.js @@ -81,11 +81,11 @@ rqf.addField({ field: 'estado_id', table: 'cub' }, - join: { - primary: 'id', - foreign: 'estado_id', - foreignTable: 'cub' - } + // join: { + // primary: 'id', + // foreign: 'estado_id', + // foreignTable: 'cub' + // } }).addValue({ name: 'min_year', table: 'cub', -- GitLab From d0137197923a3a50af383163dc807bf9065f7b08 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 21 Jun 2021 10:19:23 -0300 Subject: [PATCH 039/305] add educationalBudget file --- src/libs/routes/educationalBudget.js | 325 +++++++++++++++++++++++++++ 1 file changed, 325 insertions(+) create mode 100644 src/libs/routes/educationalBudget.js diff --git a/src/libs/routes/educationalBudget.js b/src/libs/routes/educationalBudget.js new file mode 100644 index 00000000..30f6afc1 --- /dev/null +++ b/src/libs/routes/educationalBudget.js @@ -0,0 +1,325 @@ +/* +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/>. +*/ + + +const libs = `${process.cwd()}/libs`; + +const conn = require(`${libs}/db/monet`); + +const express = require('express'); + +const educationalBudget = express.Router(); + +const squel = require('squel'); + +const query = require(`${libs}/middlewares/query`).query; + +const response = require(`${libs}/middlewares/response`); + +const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); + +const id2str = require(`${libs}/middlewares/id2str`); + +const addMissing = require(`${libs}/middlewares/addMissing`); + +const config = require(`${libs}/config`); + +const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware; + +let rqf = new ReqQueryFields(); + +let rqfId = new ReqQueryFields(); + +const db = require(`${libs}/db/query_exec`); + +const log = require(`${libs}/log`)(module); + +rqfId.addField({ + name: 'filter', + field: false, + where: true +}).addField({ + name: 'dims', + field: true, + where: false +}).addValue({ + name: 'federative_entity', + table: 'orcamento_educacional', + tableField: 'entidade_federativa', + resultField: 'entidade_federativa_id', + where: { + relation: '=', + type: 'integer', + field: 'entidade_federativa' + } +}); + +//Insert route in orcamento_educacional table +educationalBudget.post('/insert', (req, res, next) => { + let id = req.body.id || null; + let entidade_federativa = req.body.entidade_federativa || null; + let csv = req.body.csv || null; + + //csv example + //"RO|7777777|jiarana|8043|41768845|43141895|66081767|8216|24312922|158,2%" + + req.id = id; + req.entidade_federativa = entidade_federativa; + req.csv = csv.toString(); + req.date = new Date(); + + //split o csv para adicionar separadamente nas colunas + csv = csv.split("|"); + req.uf = csv[0]; + req.municipio_id = csv[1]; + req.nome = csv[2]; + req.matriculas = csv[3]; + req.receitas_vinculadas = csv[4]; + req.despesas_realizadas = csv[5]; + req.despesas_correntes = csv[6]; + req.valor_aluno = csv[7]; + req.completacao = csv[8]; + req.completacao_porcentagem = csv[9]; + + let sqlQueryParams = []; + + //remove id duplicate + let deleteQuery = squel.delete() + .from("orcamento_educacional") + .where('id = ' + req.id) + .toString() + + //Exec delete sql + log.debug(`Executing SQL query '${deleteQuery}' with params '${[sqlQueryParams]}'`); + return new Promise((resolve, reject) => { + // Prepare statement + conn.prepare(deleteQuery, true).then((dbQuery) => { + // Execute query + dbQuery.exec(sqlQueryParams).then((dbResult) => { + // release resources allocated for the prepared statement + dbQuery.release(); + resolve(dbResult.data); + req.result = "Insertion Success" + next(); + }).catch((queryError) => { + log.error(`SQL query execution error: ${queryError.message}`); + req.result = "SQL query execution error:" + queryError.message; + log.error(`SQL query: ${deleteQuery} with params: ${sqlQueryParams}`); + // release resources allocated for the prepared statement + dbQuery.release(); + next(); + }); + }).catch((prepError) => { + log.error(`SQL prepared statement error: ${prepError.message}`); + req.result = "SQL query execution error:" + queryError.message; + log.error(`SQL query: ${deleteQuery} with params: ${sqlQueryParams}`); + next(); + }); + }); + +}, (req, res, next) => { + //build query + let insertQuery = squel.insert() + .into("orcamento_educacional") + .set("id", req.id) + .set("entidade_federativa", req.entidade_federativa) + .set("csv", req.csv) + .set("data", req.date.toString()) + .set("uf", req.uf) + .set("municipio_id", req.municipio_id) + .set("nome", req.nome) + .set("receitas_vinculadas", req.receitas_vinculadas) + .set("despesas_realizadas", req.despesas_realizadas) + .set("despesas_correntes", req.despesas_correntes) + .set("valor_aluno", req.valor_aluno) + .set("completacao", req.completacao) + .set("completacao_porcentagem", req.completacao_porcentagem) + .toString() + + let sqlQueryParams = []; + + //Exec insert sql + log.debug(`Executing SQL query '${insertQuery}' with params '${[sqlQueryParams]}'`); + return new Promise((resolve, reject) => { + // Prepare statement + conn.prepare(insertQuery, true).then((dbQuery) => { + // Execute query + dbQuery.exec(sqlQueryParams).then((dbResult) => { + // release resources allocated for the prepared statement + dbQuery.release(); + resolve(dbResult.data); + req.result = "Insertion Success" + next(); + }).catch((queryError) => { + log.error(`SQL query execution error: ${queryError.message}`); + req.result = "SQL query execution error:" + queryError.message; + log.error(`SQL query: ${insertQuery} with params: ${sqlQueryParams}`); + // release resources allocated for the prepared statement + dbQuery.release(); + next(); + }); + }).catch((prepError) => { + log.error(`SQL prepared statement error: ${prepError.message}`); + req.result = "SQL query execution error:" + queryError.message; + log.error(`SQL query: ${insertQuery} with params: ${sqlQueryParams}`); + next(); + }); + }); + + next(); +}, response('educationalBudget')); + +//Delete orcamento_educacional table +educationalBudget.get('/delete', (req, res, next) => { + + //build query + let insertQuery = squel.delete() + .from("orcamento_educacional") + .toString() + + let sqlQueryParams = []; + + //Exec sql in monet + log.debug(`Executing SQL query '${insertQuery}' with params '${[sqlQueryParams]}'`); + return new Promise((resolve, reject) => { + // Prepare statement + conn.prepare(insertQuery, true).then((dbQuery) => { + // Execute query + dbQuery.exec(sqlQueryParams).then((dbResult) => { + // release resources allocated for the prepared statement + dbQuery.release(); + resolve(dbResult.data); + req.result = "Delete Table Success" + next(); + }).catch((queryError) => { + log.error(`SQL query execution error: ${queryError.message}`); + req.result = "SQL query execution error:" + queryError.message; + log.error(`SQL query: ${insertQuery} with params: ${sqlQueryParams}`); + // release resources allocated for the prepared statement + dbQuery.release(); + next(); + }); + }).catch((prepError) => { + log.error(`SQL prepared statement error: ${prepError.message}`); + req.result = "SQL query execution error:" + queryError.message; + log.error(`SQL query: ${insertQuery} with params: ${sqlQueryParams}`); + next(); + }); + }); + + next(); +}, response('educationalBudget')); + +//Return all id's in table +educationalBudget.get('/id', rqfId.parse(), rqfId.build(), (req, res, next) => { + req.sql.from('orcamento_educacional') + .field('orcamento_educacional.municipio_id') + next(); +}, query, response('educationalBudget')); + +//Return count id grouop by entidade_federativa +educationalBudget.get('/finish', rqf.parse(), (req, res, next) => { + req.sql.field('COUNT(*)', 'total') + .field('orcamento_educacional.entidade_federativa', 'entidade_federativa') + .from('orcamento_educacional') + .group('orcamento_educacional.entidade_federativa') + .order('orcamento_educacional.entidade_federativa') + next(); +}, query, response('educationalBudget')); + +//return all data +educationalBudget.get('/', rqf.parse(), (req, res, next) => { + req.sql.from('orcamento_educacional') + .field('orcamento_educacional.id') + .field('orcamento_educacional.entidade_federativa', 'entidade_federativa') + .field('orcamento_educacional.data', 'data_insercao') + .field('orcamento_educacional.uf', 'uf') + .field('orcamento_educacional.municipio_id', 'municipio_id') + .field('orcamento_educacional.nome', 'nome') + .field('orcamento_educacional.receitas_vinculadas', 'receitas_vinculadas') + .field('orcamento_educacional.despesas_realizadas', 'despesas_realizadas') + .field('orcamento_educacional.despesas_correntes', 'despesas_correntes') + .field('orcamento_educacional.valor_aluno', 'valor_aluno') + .field('orcamento_educacional.completacao', 'completacao') + .field('orcamento_educacional.completacao_porcentagem', 'completacao_porcentagem') + .field('orcamento_educacional.csv', 'csv') + next(); +}, query, response('educationalBudget')); + +//Insert route in orcamento_educacional table +educationalBudget.post('/insert_pqr', (req, res, next) => { + let id = JSON.parse(req.body.id) || null; + let pqr = JSON.parse(req.body.pqr) || null; + + req.id = id; + req.pqr = pqr; + req.date = new Date(); + + //build query + let insertQuery = squel.insert() + .into("orcamento_educacional_pqr") + .set("id", req.id.toString()) + .set("pqr", req.pqr.toString()) + .set("data", req.date.toString()) + .toString() + + let sqlQueryParams = []; + + //Exec sql + log.debug(`Executing SQL query '${insertQuery}' with params '${[sqlQueryParams]}'`); + return new Promise((resolve, reject) => { + // Prepare statement + conn.prepare(insertQuery, true).then((dbQuery) => { + // Execute query + dbQuery.exec(sqlQueryParams).then((dbResult) => { + // release resources allocated for the prepared statement + dbQuery.release(); + resolve(dbResult.data); + req.result = "Insertion Success" + next(); + }).catch((queryError) => { + log.error(`SQL query execution error: ${queryError.message}`); + req.result = "SQL query execution error:" + queryError.message; + log.error(`SQL query: ${insertQuery} with params: ${sqlQueryParams}`); + // release resources allocated for the prepared statement + dbQuery.release(); + next(); + }); + }).catch((prepError) => { + log.error(`SQL prepared statement error: ${prepError.message}`); + req.result = "SQL query execution error:" + queryError.message; + log.error(`SQL query: ${insertQuery} with params: ${sqlQueryParams}`); + next(); + }); + }); + + next(); +}, response('educationalBudget')); + +educationalBudget.get('/get_pqr', (req, res, next) => { + req.sql.from('orcamento_educacional_pqr') + .field('orcamento_educacional_pqr.id', 'id') + .field('orcamento_educacional_pqr.pqr', 'pqr') + .field('orcamento_educacional_pqr.data', 'data') + next(); +}, query, response('educationalBudget')); + +module.exports = educationalBudget; + -- GitLab From df817030163a60c16c2f038b8b3577eee46f9504 Mon Sep 17 00:00:00 2001 From: SimCAQ-Homologa <root@simcaqhomologa.c3sl.ufpr.br> Date: Wed, 7 Jul 2021 11:17:08 -0300 Subject: [PATCH 040/305] add dockerfile --- Dockerfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..52552c7c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM node:dubnium-stretch + +ENV HTTP_PROXY=http://httpproxy.c3sl.ufpr.br:3128/ + +ENV HTTPS_PROXY=http://httpproxy.c3sl.ufpr.br:3128/ + +RUN npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint istanbul --force + +RUN npm un -g gulp + +RUN npm i -g gulp@3.9.0 + +RUN mkdir API + +COPY . ./API + +WORKDIR ./API + +RUN npm install + +RUN gulp build + +EXPOSE 3000 + +CMD gulp -- GitLab From 75a052adc853782a34d3fca649c66066735caabb Mon Sep 17 00:00:00 2001 From: SimCAQ-Homologa <root@simcaqhomologa.c3sl.ufpr.br> Date: Mon, 26 Jul 2021 10:42:14 -0300 Subject: [PATCH 041/305] update config for docker --- Dockerfile | 2 +- gulpfile.babel.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 52552c7c..49d758a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,4 +22,4 @@ RUN gulp build EXPOSE 3000 -CMD gulp +CMD NODE_ENV=production gulp diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 11e9416f..32500420 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -111,7 +111,7 @@ gulp.task('run', () => { tasks: ['watch'], ignore: ["test/test.js", "gulpfile.babel.js"], ext: 'js html json', - env: { 'NODE_ENV': 'development' } + env: { 'NODE_ENV': process.env.NODE_ENV } }); }); -- GitLab From 163a3d0debe4eeae45c0601e8744b4ffa1e42e1a Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Thu, 26 Aug 2021 11:33:33 -0300 Subject: [PATCH 042/305] revert docente_test back to docente in routes --- src/libs/routes/disciplines.js | 94 +++++++++++++++++----------------- src/libs/routes/teacher.js | 80 ++++++++++++++--------------- 2 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 33d26c8f..9a6658e6 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -48,14 +48,14 @@ disciplinesApp.use(cache('15 day')); // Returns a tuple of start and ending years of the complete enrollments dataset. disciplinesApp.get('/year_range', (req, res, next) => { - req.sql.from('docente_test') - .field('MIN(docente_test.ano_censo)', 'start_year') - .field('MAX(docente_test.ano_censo)', 'end_year'); + req.sql.from('docente') + .field('MIN(docente.ano_censo)', 'start_year') + .field('MAX(docente.ano_censo)', 'end_year'); next(); }, query, response('range')); disciplinesApp.get('/years', (req, res, next) => { - req.sql.from('docente_test'). + req.sql.from('docente'). field('DISTINCT docente.ano_censo', 'year'); next(); }, query, response('years')); @@ -141,7 +141,7 @@ disciplinesApp.get('/rural_location', (req, res, next) => { }, response('rural_location')); disciplinesApp.get('/education_type', (req, res, next) => { - req.sql.from('docente_test') + req.sql.from('docente') .field('DISTINCT nivel_tipo_formacao', 'id') .order('id'); next(); @@ -203,7 +203,7 @@ rqf.addField({ where: false }).addValue({ name: 'adm_dependency', - table: 'docente_test', + table: 'docente', tableField: 'dependencia_adm_id', resultField: 'adm_dependency_id', where: { @@ -213,7 +213,7 @@ rqf.addField({ } }).addValue({ name: 'adm_dependency_detailed', - table: 'docente_test', + table: 'docente', tableField: 'dependencia_adm_priv', resultField: 'adm_dependency_detailed_id', where: { @@ -223,7 +223,7 @@ rqf.addField({ } }).addValue({ name: 'contract_type', - table: 'docente_test', + table: 'docente', tableField: 'tipo_contratacao', resultField: 'contract_type_id', where: { @@ -233,7 +233,7 @@ rqf.addField({ } }).addValue({ name: 'education_level_mod', - table: 'docente_test', + table: 'docente', tableField: 'etapas_mod_ensino_segmento_id', resultField: 'education_level_mod_id', where: { @@ -243,7 +243,7 @@ rqf.addField({ } }).addValue({ name: 'education_level_short', - table: 'docente_test', + table: 'docente', tableField: 'etapa_resumida', resultField: 'education_level_short_id', where: { @@ -253,7 +253,7 @@ rqf.addField({ } }).addValue({ name: 'education_type', - table: 'docente_test', + table: 'docente', tableField: 'nivel_tipo_formacao', resultField: 'education_type_id', where: { @@ -274,7 +274,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_regiao_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }).addValue({ name: 'mesoregion', @@ -290,7 +290,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }).addValue({ name: 'microregion', @@ -306,7 +306,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }).addValue({ name: 'state', @@ -321,7 +321,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_estado_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }).addValueToField({ name: 'city', @@ -336,7 +336,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }, 'dims').addValueToField({ name: 'city', @@ -351,7 +351,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }, 'filter').addValueToField({ name: 'school', @@ -366,7 +366,7 @@ rqf.addField({ join: { primary: ['id', 'ano_censo'], foreign: ['escola_id', 'ano_censo'], - foreignTable: 'docente_test' + foreignTable: 'docente' } }, 'dims').addValueToField({ name: 'school', @@ -381,11 +381,11 @@ rqf.addField({ join: { primary: ['id', 'ano_censo'], foreign: ['escola_id', 'ano_censo'], - foreignTable: 'docente_test' + foreignTable: 'docente' } }, 'filter').addValue({ name: 'location', - table: 'docente_test', + table: 'docente', tableField: 'localizacao_id', resultField: 'location_id', where: { @@ -395,7 +395,7 @@ rqf.addField({ } }).addValue({ name: 'rural_location', - table: 'docente_test', + table: 'docente', tableField: 'localidade_area_rural', resultField: 'rural_location_id', where: { @@ -405,7 +405,7 @@ rqf.addField({ } }).addValue({ name: 'min_year', - table: 'docente_test', + table: 'docente', tableField: 'ano_censo', resultField: 'year', where: { @@ -415,7 +415,7 @@ rqf.addField({ } }).addValue({ name: 'max_year', - table: 'docente_test', + table: 'docente', tableField: 'ano_censo', resultField: 'year', where: { @@ -425,7 +425,7 @@ rqf.addField({ } }).addValue({ name: 'gender', - table: 'docente_test', + table: 'docente', tableField: 'sexo', resultField: 'gender_id', where: { @@ -435,7 +435,7 @@ rqf.addField({ } }).addValue({ name: 'ethnic_group', - table: 'docente_test', + table: 'docente', tableField: 'cor_raca', resultField: 'ethnic_group_id', where: { @@ -445,7 +445,7 @@ rqf.addField({ } }).addValue({ name: 'discipline', - table: 'docente_test', + table: 'docente', tableField: '', resultField: '', where: { @@ -521,13 +521,13 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .field('SUM(adequacao_sociologia)', 'total_suitable_sociologia') .field("'Brasil'", 'name') - .field('docente_test.ano_censo', 'year') - .from('docente_test') - .group('docente_test.ano_censo') - .order('docente_test.ano_censo') - .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ - ((docente_test.tipo_turma_id >= 0 AND docente_test.tipo_turma_id <= 3 AND docente_test.tipo_turma_atendimento_id is NULL) \ - OR ((docente_test.tipo_turma_atendimento_id = 1 OR docente_test.tipo_turma_atendimento_id = 2) AND docente_test.tipo_turma_id is NULL)) AND \ + .field('docente.ano_censo', 'year') + .from('docente') + .group('docente.ano_censo') + .order('docente.ano_censo') + .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ + OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); } else if ('discipline' in req.filter) { @@ -550,28 +550,28 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { req.sql.field(totalQuery, 'total') .field(totalSuitableQuery, 'total_suitable') .field("'Brasil'", 'name') - .field('docente_test.ano_censo', 'year') - .from('docente_test') + .field('docente.ano_censo', 'year') + .from('docente') // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') - .group('docente_test.ano_censo') - .order('docente_test.ano_censo') - .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ - ((docente_test.tipo_turma_id >= 0 AND docente_test.tipo_turma_id <= 3 AND docente_test.tipo_turma_atendimento_id is NULL) \ - OR ((docente_test.tipo_turma_atendimento_id = 1 OR docente_test.tipo_turma_atendimento_id = 2) AND docente_test.tipo_turma_id is NULL)) AND \ + .group('docente.ano_censo') + .order('docente.ano_censo') + .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ + OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); } else { req.sql.field('SUM(n_disc)', 'total') .field('SUM(n_disc_adequada)', 'total_suitable') .field("'Brasil'", 'name') - .field('docente_test.ano_censo', 'year') - .from('docente_test') + .field('docente.ano_censo', 'year') + .from('docente') // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') - .group('docente_test.ano_censo') - .order('docente_test.ano_censo') - .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ - ((docente_test.tipo_turma_id >= 0 AND docente_test.tipo_turma_id <= 3 AND docente_test.tipo_turma_atendimento_id is NULL) \ - OR ((docente_test.tipo_turma_atendimento_id = 1 OR docente_test.tipo_turma_atendimento_id = 2) AND docente_test.tipo_turma_id is NULL)) AND \ + .group('docente.ano_censo') + .order('docente.ano_censo') + .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ + OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); } diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 2dd296f6..88ec7a1e 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -48,22 +48,22 @@ teacherApp.use(cache('15 day')); // Returns a tuple of start and ending years of the complete enrollments dataset. teacherApp.get('/year_range', (req, res, next) => { - req.sql.from('docente_test') - .field('MIN(docente_test.ano_censo)', 'start_year') - .field('MAX(docente_test.ano_censo)', 'end_year'); + req.sql.from('docente') + .field('MIN(docente.ano_censo)', 'start_year') + .field('MAX(docente.ano_censo)', 'end_year'); next(); }, query, response('range')); teacherApp.get('/years', (req, res, next) => { - req.sql.from('docente_test'). - field('DISTINCT docente_test.ano_censo', 'year'); + req.sql.from('docente'). + field('DISTINCT docente.ano_censo', 'year'); next(); }, query, response('years')); teacherApp.get('/source', (req, res, next) => { req.sql.from('fonte') .field('fonte', 'source') - .where('tabela = \'docente_test\''); + .where('tabela = \'docente\''); next(); }, query, response('source')); @@ -141,7 +141,7 @@ teacherApp.get('/rural_location', (req, res, next) => { }, response('rural_location')); teacherApp.get('/education_type', (req, res, next) => { - req.sql.from('docente_test') + req.sql.from('docente') .field('DISTINCT nivel_tipo_formacao', 'id') .order('id'); next(); @@ -225,7 +225,7 @@ rqf.addField({ where: false }).addValue({ name: 'adm_dependency', - table: 'docente_test', + table: 'docente', tableField: 'dependencia_adm_id', resultField: 'adm_dependency_id', where: { @@ -235,7 +235,7 @@ rqf.addField({ } }).addValue({ name: 'adm_dependency_detailed', - table: 'docente_test', + table: 'docente', tableField: 'dependencia_adm_priv', resultField: 'adm_dependency_detailed_id', where: { @@ -245,7 +245,7 @@ rqf.addField({ } }).addValue({ name: 'contract_type', - table: 'docente_test', + table: 'docente', tableField: 'tipo_contratacao', resultField: 'contract_type_id', where: { @@ -255,7 +255,7 @@ rqf.addField({ } }).addValue({ name: 'education_level_mod', - table: 'docente_test', + table: 'docente', tableField: 'etapas_mod_ensino_segmento_id', resultField: 'education_level_mod_id', where: { @@ -265,7 +265,7 @@ rqf.addField({ } }).addValue({ name: 'education_level_short', - table: 'docente_test', + table: 'docente', tableField: 'etapa_resumida', resultField: 'education_level_short_id', where: { @@ -275,7 +275,7 @@ rqf.addField({ } }).addValue({ name: 'education_type', - table: 'docente_test', + table: 'docente', tableField: 'nivel_tipo_formacao', resultField: 'education_type_id', where: { @@ -296,7 +296,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_regiao_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }).addValue({ name: 'mesoregion', @@ -312,7 +312,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }).addValue({ name: 'microregion', @@ -328,7 +328,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }).addValue({ name: 'state', @@ -343,7 +343,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_estado_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }).addValueToField({ name: 'city', @@ -358,7 +358,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }, 'dims').addValueToField({ name: 'city', @@ -373,7 +373,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'escola_municipio_id', - foreignTable: 'docente_test' + foreignTable: 'docente' } }, 'filter').addValueToField({ name: 'school', @@ -388,7 +388,7 @@ rqf.addField({ join: { primary: ['id', 'ano_censo'], foreign: ['escola_id', 'ano_censo'], - foreignTable: 'docente_test' + foreignTable: 'docente' } }, 'dims').addValueToField({ name: 'school', @@ -403,11 +403,11 @@ rqf.addField({ join: { primary: ['id', 'ano_censo'], foreign: ['escola_id', 'ano_censo'], - foreignTable: 'docente_test' + foreignTable: 'docente' } }, 'filter').addValue({ name: 'location', - table: 'docente_test', + table: 'docente', tableField: 'localizacao_id', resultField: 'location_id', where: { @@ -417,7 +417,7 @@ rqf.addField({ } }).addValue({ name: 'rural_location', - table: 'docente_test', + table: 'docente', tableField: 'localidade_area_rural', resultField: 'rural_location_id', where: { @@ -427,7 +427,7 @@ rqf.addField({ } }).addValue({ name: 'min_year', - table: 'docente_test', + table: 'docente', tableField: 'ano_censo', resultField: 'year', where: { @@ -437,7 +437,7 @@ rqf.addField({ } }).addValue({ name: 'max_year', - table: 'docente_test', + table: 'docente', tableField: 'ano_censo', resultField: 'year', where: { @@ -447,7 +447,7 @@ rqf.addField({ } }).addValue({ name: 'gender', - table: 'docente_test', + table: 'docente', tableField: 'sexo', resultField: 'gender_id', where: { @@ -457,7 +457,7 @@ rqf.addField({ } }).addValue({ name: 'ethnic_group', - table: 'docente_test', + table: 'docente', tableField: 'cor_raca', resultField: 'ethnic_group_id', where: { @@ -467,7 +467,7 @@ rqf.addField({ } }).addValue({ name: 'initial_training', - table: 'docente_test', + table: 'docente', tableField: 'formacao_inicial_docente', resultField: 'initial_training_id', where: { @@ -477,7 +477,7 @@ rqf.addField({ } }).addValue({ name: 'pos_training', - table: 'docente_test', + table: 'docente', tableField: 'formacao_pos_docente', resultField: 'pos_training_id', where: { @@ -487,7 +487,7 @@ rqf.addField({ } }).addValue({ name: 'licentiate_degree', - table: 'docente_test', + table: 'docente', tableField: 'formacao_licenciatura_docente', resultField: 'licentiate_degree_id', where: { @@ -498,17 +498,17 @@ rqf.addField({ }); teacherApp.get('/', rqf.parse(), (req, res, next) => { - req.sql.field('COUNT(DISTINCT docente_test.id_docente)', 'total') + req.sql.field('COUNT(DISTINCT docente.id_docente)', 'total') .field("'Brasil'", 'name') - .field('docente_test.ano_censo', 'year') - .from('docente_test') - .join('turma', null, 'docente_test.turma_id=turma.id AND docente_test.ano_censo=turma.ano_censo') - .group('docente_test.ano_censo') - .order('docente_test.ano_censo') - .where('(docente_test.tipo_docente = 1 OR docente_test.tipo_docente = 5) AND \ - ((docente_test.tipo_turma_id >= 0 AND docente_test.tipo_turma_id <= 3 AND docente_test.tipo_turma_atendimento_id is NULL) \ - OR ((docente_test.tipo_turma_atendimento_id = 1 OR docente_test.tipo_turma_atendimento_id = 2) AND docente_test.tipo_turma_id is NULL)) \ - AND (docente_test.ano_censo <> 2009 or docente_test.escola_estado_id <> 42)'); // não devemos trazer SC em 2009. + .field('docente.ano_censo', 'year') + .from('docente') + .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') + .group('docente.ano_censo') + .order('docente.ano_censo') + .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ + OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) \ + AND (docente.ano_censo <> 2009 or docente.escola_estado_id <> 42)'); // não devemos trazer SC em 2009. // if("education_level_mod" in req.dims) { // req.hadEducationLevelMod = true; -- GitLab From 37d06b93d6db2b280ffa362874a5d1547c3c2b27 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Thu, 26 Aug 2021 11:36:13 -0300 Subject: [PATCH 043/305] update config example file --- config.json.example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.json.example b/config.json.example index e3d30920..962fc736 100644 --- a/config.json.example +++ b/config.json.example @@ -7,7 +7,7 @@ "monetdb": { "host": "simcaqdb3.c3sl.ufpr.br", "port": 50000, - "dbname": "simcaq_dev4", + "dbname": "simcaq", "user": "monetdb", "password":"monetdb", "nrConnections": "4" @@ -52,7 +52,7 @@ "monetdb": { "host": "simcaqdb3.c3sl.ufpr.br", "port": 50000, - "dbname": "simcaq_dev4", + "dbname": "simcaq", "user": "monetdb", "password":"monetdb", "nrConnections": "4" @@ -98,7 +98,7 @@ "monetdb": { "host": "simcaqdb3.c3sl.ufpr.br", "port": 50000, - "dbname": "simcaq_dev4", + "dbname": "simcaq", "user": "monetdb", "password":"monetdb", "nrConnections": "4" -- GitLab From 0003c90ea110db4f8615906ea75c44045641007e Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Thu, 26 Aug 2021 11:37:53 -0300 Subject: [PATCH 044/305] update config example file --- config.json.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json.example b/config.json.example index 962fc736..2c3a982e 100644 --- a/config.json.example +++ b/config.json.example @@ -46,7 +46,7 @@ }, "test": { - "port": 4000, + "port": 3000, "ip": "127.0.0.1", "debug" : true, "monetdb": { @@ -92,7 +92,7 @@ }, "production": { - "port": 6000, + "port": 3000, "ip": "127.0.0.1", "debug" : false, "monetdb": { -- GitLab From 733278420a3fbf9b4eaa786a68c176d2ddc4d39f Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Wed, 15 Sep 2021 11:57:09 -0300 Subject: [PATCH 045/305] add adm_dependency filter --- src/libs/routes/enrollmentProjection.js | 46 +++++++++++++++---------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/libs/routes/enrollmentProjection.js b/src/libs/routes/enrollmentProjection.js index 5018440b..4dd92e5d 100644 --- a/src/libs/routes/enrollmentProjection.js +++ b/src/libs/routes/enrollmentProjection.js @@ -59,7 +59,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'estado_id', - foreignTable: 'projecao_matricula' + foreignTable: 'projecao_matricula_por_dependencia' } }, 'dims').addValueToField({ name: 'state', @@ -74,7 +74,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'estado_id', - foreignTable: 'projecao_matricula' + foreignTable: 'projecao_matricula_por_dependencia' } }, 'filter').addValueToField({ name: 'city', @@ -89,7 +89,7 @@ rqf.addField({ join: { primary: 'id', foreign: 'municipio_id', - foreignTable: 'projecao_matricula' + foreignTable: 'projecao_matricula_por_dependencia' } }, 'dims').addValueToField({ name: 'city', @@ -104,11 +104,11 @@ rqf.addField({ join: { primary: 'id', foreign: 'municipio_id', - foreignTable: 'projecao_matricula' + foreignTable: 'projecao_matricula_por_dependencia' } }, 'filter').addValue({ name: 'min_year', - table: 'projecao_matricula', + table: 'projecao_matricula_por_dependencia', tableField: 'ano_censo', resultField: 'year', where: { @@ -118,7 +118,7 @@ rqf.addField({ } }).addValue({ name: 'max_year', - table: 'projecao_matricula', + table: 'projecao_matricula_por_dependencia', tableField: 'ano_censo', resultField: 'year', where: { @@ -126,22 +126,32 @@ rqf.addField({ type: 'integer', field: 'ano_censo' } +}).addValue({ + name: 'adm_dependency', + table: 'projecao_matricula_por_dependencia', + tableField: 'dependencia_adm_id', + resultField: 'adm_dependency_id', + where: { + relation: '=', + type: 'integer', + field: 'dependencia_adm_id' + } }); enrollmentProjectionApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { req.sql.field("'Brasil'", 'name') - .field('SUM(projecao_matricula.urbano_dia_total)', 'urban_day_total') - .field('SUM(projecao_matricula.urbano_noite_total)', 'urban_night_total') - .field('SUM(projecao_matricula.rural_dia_total)', 'rural_day_total') - .field('SUM(projecao_matricula.rural_noite_total)', 'rural_night_total') - .field('projecao_matricula.etapa_ensino_escola_ano_id', 'education_level_school_year_id') - .field('projecao_matricula.ano_censo', 'year') - .from('projecao_matricula') - .where('projecao_matricula.etapa_ensino_escola_ano_id <> 7 AND projecao_matricula.etapa_ensino_escola_ano_id < 71') - .group('projecao_matricula.etapa_ensino_escola_ano_id') - .group('projecao_matricula.ano_censo') - .order('projecao_matricula.ano_censo') - .order('projecao_matricula.etapa_ensino_escola_ano_id'); + .field('SUM(projecao_matricula_por_dependencia.urbano_dia_total)', 'urban_day_total') + .field('SUM(projecao_matricula_por_dependencia.urbano_noite_total)', 'urban_night_total') + .field('SUM(projecao_matricula_por_dependencia.rural_dia_total)', 'rural_day_total') + .field('SUM(projecao_matricula_por_dependencia.rural_noite_total)', 'rural_night_total') + .field('projecao_matricula_por_dependencia.etapa_ensino_escola_ano_id', 'education_level_school_year_id') + .field('projecao_matricula_por_dependencia.ano_censo', 'year') + .from('projecao_matricula_por_dependencia') + .where('projecao_matricula_por_dependencia.etapa_ensino_escola_ano_id <> 7 AND projecao_matricula_por_dependencia.etapa_ensino_escola_ano_id < 71') + .group('projecao_matricula_por_dependencia.etapa_ensino_escola_ano_id') + .group('projecao_matricula_por_dependencia.ano_censo') + .order('projecao_matricula_por_dependencia.ano_censo') + .order('projecao_matricula_por_dependencia.etapa_ensino_escola_ano_id'); next(); }, query, id2str.transform(), (req, res, next) => { -- GitLab From 54135f44153a7e04faef9e8ecafd6a1126bdc133 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Thu, 14 Oct 2021 12:30:48 -0300 Subject: [PATCH 046/305] diagnosis by city instead of country --- src/libs/routes/classroomCount.js | 105 +++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index e337e57b..48a35525 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -218,7 +218,27 @@ rqf.addField({ type: 'integer', field: 'dependencia_adm_id' } -}, 'filter'); +}, 'filter') .addValue({ + name: 'integral_time', + table: 'matricula', + tableField: 'tempo_integral', + resultField: 'integral_time_id', + where: { + relation: '=', + type: 'integer', + field: 'tempo_integral' + } +}).addValue({ + name: 'education_level_short', + table: 'matricula', + tableField: 'etapa_resumida', + resultField: 'education_level_short_id', + where: { + relation: '=', + type: 'integer', + field: 'etapa_resumida' + } +}); classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let classSize = JSON.parse(req.body.class_size) || null; @@ -394,6 +414,75 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { delete req.filter; req.resetSql(); next(); +}, rqf.parse(), (req, res, next) => { + req.dims.state = true; + req.dims.city = true; + req.dims.education_level_short = true; + req.dims.integral_time = true; + req.sql.field('COUNT(*)', 'total') + .field('matricula.ano_censo', 'year') + .from('matricula') + .group('matricula.ano_censo') + .order('matricula.ano_censo') + .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); + next(); +}, rqf.build(), query, id2str.transform(), (req, res, next) => { + + var integral_time_result = req.result + req.integral_time = {} + for (let i = 0; i < integral_time_result.length; ++i){ + // Se cidade não foi criada, cria + let integral_time = integral_time_result[i]; + let cityHash = '' + integral_time.year + integral_time.city_id + //let currentCity = null; + let currentCity = req.integral_time[cityHash] + + // Cria cidade caso não exista + if (currentCity === undefined){ + let obj = { + year: integral_time.year, + city_id: integral_time.city_id, + city_name: integral_time.city_name, + integral_time: {} + } + req.integral_time[cityHash] = obj + currentCity = obj; + } + + // Pega objeto com dados do nível atual + let level = integral_time.education_level_short_id + let levelObj = currentCity.integral_time[level] + if (levelObj === undefined){ + levelObj = { + id: level, + integralTime: 0, + total: 0, + } + } + + // Soma no total em integralTime, caso seja 1 + levelObj.total += integral_time.total + if (integral_time.integral_time_id === 1){ + levelObj.integralTime += integral_time.total + } + + currentCity.integral_time[level] = levelObj + + } + for (let i in req.integral_time){ + let city = req.integral_time[i] + // Adiciona diagnóstico aos objetos + for (let key in city.integral_time){ + let cur = city.integral_time[key] + cur["diagnosis"] = cur.total ? (cur.integralTime/cur.total)*100.0 : 0; + city.integral_time[key] = cur + } + } + + delete req.dims; + delete req.filter; + req.resetSql(); + next() }, rqf.parse(), rqf.build(), (req, res, next) => { // req.classroom = req.result; // req.idm = req.result; @@ -431,6 +520,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let ti = 0; // index for teacher table + // estado, cidade, local, prédio while (i < req.classroom.length) { let classroom = req.classroom[i]; // Cria hash única para cada espacialidade, dado um ano @@ -549,7 +639,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { educationLevel.classes_school_year = []; } - // Para manter a ordem da etapa de ensino + // Para manter a ordem da etapa de ensino (insertion sort) if (location.education_level.length == 0) { location.education_level.push(educationLevel); } else { @@ -630,8 +720,17 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } let enrollmentIdm = req.idm[ei]; + let cur_year = enrollment.year + let cur_city = enrollment.city_id + let hash = '' + cur_year + cur_city + let cur_education_level_short = educationLevel.education_level_short_id + + let cur_diagnosis = 0 + if (req.integral_time[hash].integral_time[cur_education_level_short]){ + cur_diagnosis = req.integral_time[hash].integral_time[cur_education_level_short].diagnosis + } - let currentIntegralOfferGoal = enrollmentEducationLevel.integralTimeOfferGoal; + let currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, cur_diagnosis); let currentNumberStudentClass = (enrollment.location_id == 1) ? enrollmentEducationLevel.numberStudentClass.urban : enrollmentEducationLevel.numberStudentClass.country; // Soma os totais de matrícula da etapa de ensino -- GitLab From 8ba82bf2efc69e364b2c50e87d831766c67ff780 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Thu, 14 Oct 2021 12:36:29 -0300 Subject: [PATCH 047/305] hotfix_cub --- src/libs/routes/cub.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/routes/cub.js b/src/libs/routes/cub.js index 889361d2..944e784d 100644 --- a/src/libs/routes/cub.js +++ b/src/libs/routes/cub.js @@ -136,7 +136,6 @@ cubApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { if (req.filter.size || req.filter.dims) { if ('state' in req.filter || 'state' in req.dims) { req.sql.from('cub') - .from('estado') .field('cub.estado_id', 'cod_uf') .field('estado.sigla', 'sigla_uf') .field('cub.tipo_preco', 'tipo_preco') -- GitLab From 66891cba98c2389be510c8a5778c98df399d3b83 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Thu, 14 Oct 2021 12:30:48 -0300 Subject: [PATCH 048/305] diagnosis by city instead of country --- src/libs/routes/classroomCount.js | 105 +++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index e337e57b..48a35525 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -218,7 +218,27 @@ rqf.addField({ type: 'integer', field: 'dependencia_adm_id' } -}, 'filter'); +}, 'filter') .addValue({ + name: 'integral_time', + table: 'matricula', + tableField: 'tempo_integral', + resultField: 'integral_time_id', + where: { + relation: '=', + type: 'integer', + field: 'tempo_integral' + } +}).addValue({ + name: 'education_level_short', + table: 'matricula', + tableField: 'etapa_resumida', + resultField: 'education_level_short_id', + where: { + relation: '=', + type: 'integer', + field: 'etapa_resumida' + } +}); classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let classSize = JSON.parse(req.body.class_size) || null; @@ -394,6 +414,75 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { delete req.filter; req.resetSql(); next(); +}, rqf.parse(), (req, res, next) => { + req.dims.state = true; + req.dims.city = true; + req.dims.education_level_short = true; + req.dims.integral_time = true; + req.sql.field('COUNT(*)', 'total') + .field('matricula.ano_censo', 'year') + .from('matricula') + .group('matricula.ano_censo') + .order('matricula.ano_censo') + .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); + next(); +}, rqf.build(), query, id2str.transform(), (req, res, next) => { + + var integral_time_result = req.result + req.integral_time = {} + for (let i = 0; i < integral_time_result.length; ++i){ + // Se cidade não foi criada, cria + let integral_time = integral_time_result[i]; + let cityHash = '' + integral_time.year + integral_time.city_id + //let currentCity = null; + let currentCity = req.integral_time[cityHash] + + // Cria cidade caso não exista + if (currentCity === undefined){ + let obj = { + year: integral_time.year, + city_id: integral_time.city_id, + city_name: integral_time.city_name, + integral_time: {} + } + req.integral_time[cityHash] = obj + currentCity = obj; + } + + // Pega objeto com dados do nível atual + let level = integral_time.education_level_short_id + let levelObj = currentCity.integral_time[level] + if (levelObj === undefined){ + levelObj = { + id: level, + integralTime: 0, + total: 0, + } + } + + // Soma no total em integralTime, caso seja 1 + levelObj.total += integral_time.total + if (integral_time.integral_time_id === 1){ + levelObj.integralTime += integral_time.total + } + + currentCity.integral_time[level] = levelObj + + } + for (let i in req.integral_time){ + let city = req.integral_time[i] + // Adiciona diagnóstico aos objetos + for (let key in city.integral_time){ + let cur = city.integral_time[key] + cur["diagnosis"] = cur.total ? (cur.integralTime/cur.total)*100.0 : 0; + city.integral_time[key] = cur + } + } + + delete req.dims; + delete req.filter; + req.resetSql(); + next() }, rqf.parse(), rqf.build(), (req, res, next) => { // req.classroom = req.result; // req.idm = req.result; @@ -431,6 +520,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let ti = 0; // index for teacher table + // estado, cidade, local, prédio while (i < req.classroom.length) { let classroom = req.classroom[i]; // Cria hash única para cada espacialidade, dado um ano @@ -549,7 +639,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { educationLevel.classes_school_year = []; } - // Para manter a ordem da etapa de ensino + // Para manter a ordem da etapa de ensino (insertion sort) if (location.education_level.length == 0) { location.education_level.push(educationLevel); } else { @@ -630,8 +720,17 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } let enrollmentIdm = req.idm[ei]; + let cur_year = enrollment.year + let cur_city = enrollment.city_id + let hash = '' + cur_year + cur_city + let cur_education_level_short = educationLevel.education_level_short_id + + let cur_diagnosis = 0 + if (req.integral_time[hash].integral_time[cur_education_level_short]){ + cur_diagnosis = req.integral_time[hash].integral_time[cur_education_level_short].diagnosis + } - let currentIntegralOfferGoal = enrollmentEducationLevel.integralTimeOfferGoal; + let currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, cur_diagnosis); let currentNumberStudentClass = (enrollment.location_id == 1) ? enrollmentEducationLevel.numberStudentClass.urban : enrollmentEducationLevel.numberStudentClass.country; // Soma os totais de matrícula da etapa de ensino -- GitLab From 5500cfa09179cfb7189e4cc1a59c657854865fc8 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Tue, 19 Oct 2021 09:55:18 -0300 Subject: [PATCH 049/305] create last_state_values subroute --- src/libs/routes/cub.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/libs/routes/cub.js b/src/libs/routes/cub.js index 944e784d..319d65b7 100644 --- a/src/libs/routes/cub.js +++ b/src/libs/routes/cub.js @@ -132,6 +132,29 @@ rqf.addField({ } }); +cubApp.get('/last_state_values', rqf.parse(), rqf.build(), (req, res, next) => { + + var table_b = squel.select().from('cub') + .field('estado_id') + .field('MAX(ano_censo*100 + mes_censo)', 'ano_censo') + .group('estado_id') + + req.sql.from('cub', 'a') + .field('a.ano_censo', 'ano') + .field('a.mes_censo', 'mes') + .field('a.estado_id', 'cod_uf') + .field('estado.sigla', 'sigla_uf') + .field('a.tipo_preco', 'tipo_preco') + .field('a.preco', 'preco') + .join( + table_b, + 'b', + 'a.estado_id = b.estado_id AND a.ano_censo = (b.ano_censo/100)' + ) + .join('estado', null, 'a.estado_id = estado.id') + next(); +}, query, id2str.transform(), response('last_state_values')) + cubApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { if (req.filter.size || req.filter.dims) { if ('state' in req.filter || 'state' in req.dims) { -- GitLab From 747717482729f62c405e7ce591cb643b6703fd62 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Thu, 21 Oct 2021 11:04:34 -0300 Subject: [PATCH 050/305] remove logs --- src/libs/routes/employees.js | 1 - src/libs/routes/school.js | 1 - src/libs/routes/transport.js | 2 -- src/libs/routes/user.js | 5 ----- 4 files changed, 9 deletions(-) diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js index dba25468..89b5ebd0 100644 --- a/src/libs/routes/employees.js +++ b/src/libs/routes/employees.js @@ -460,7 +460,6 @@ function formatFunction(queryOriginal,reqDims) { delete reqDims.size; delete reqDims.function; let dims = Object.keys(reqDims); //se for = 0, apenas lidamos com a dimensao function. Se for = 1, lidamos com function mais a dimensao q esta nesse array. - console.log(dims) let name = { qtde_admin: "Administrativos", qtde_servicos_gerais: "Serviços Gerais", diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index b72df7c7..e8527400 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -612,7 +612,6 @@ schoolApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { }, query, response('school')); schoolApp.get('/count', cache('15 day'), rqfCount.parse(), (req, res, next) => { - console.log(req.filter); let arrang = ["arranjo_creche", "arranjo_pre", "arranjo_fundamental_ai", "arranjo_fundamental_af", "arranjo_multietapa", "arranjo_ensino_medio", "ensino_eja", "educacao_profissional", "ensino_especial"]; req.sql.from('escola') diff --git a/src/libs/routes/transport.js b/src/libs/routes/transport.js index afe7049a..74c1b095 100644 --- a/src/libs/routes/transport.js +++ b/src/libs/routes/transport.js @@ -322,7 +322,6 @@ transportApp.get('/', rqf.parse(), (req, res, next) => { next(); }, rqf.build(), query, id2str.transform(), (req, res, next) => { req.total = req.result; - console.log('here'); req.resetSql(); next(); }, rqf.parse(), (req, res, next) => { @@ -335,7 +334,6 @@ transportApp.get('/', rqf.parse(), (req, res, next) => { next(); }, rqf.build(), query, id2str.transform(), (req, res, next) => { req.public_total = req.result; - console.log('here'); req.resetSql(); next(); diff --git a/src/libs/routes/user.js b/src/libs/routes/user.js index d7ef04e5..7ff088ee 100644 --- a/src/libs/routes/user.js +++ b/src/libs/routes/user.js @@ -195,8 +195,6 @@ userApp.post('/', (req, res, next) => { }); userApp.put('/:id', passport.authenticate('bearer', { session: false }), (req, res, next) => { - console.log(req.params.id); - console.log(req.user._id); User.findById(req.params.id, (err, user) => { if (err) { log.error(err); @@ -210,8 +208,6 @@ userApp.put('/:id', passport.authenticate('bearer', { session: false }), (req, r }}); } - console.log(req.body); - user.email = req.body.email || user.email; user.name = req.body.name || user.name; user.nickname = req.body.nickname || user.nickname || user.name; @@ -230,7 +226,6 @@ userApp.put('/:id', passport.authenticate('bearer', { session: false }), (req, r user.citesegment = req.body.citesegment || user.citesegment; user.citerole = req.body.citerole || user.citerole; - // console.log(user.checkPassword(req.body.password)); if ((req.body.password) && (req.body.newpassword)) { if (req.body.password != req.body.newpassword) { if (user.checkPassword(req.body.password)) { -- GitLab From 7cb18687b103d77ca02ad1d725602240b67494ad Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Thu, 21 Oct 2021 12:38:45 -0300 Subject: [PATCH 051/305] update last_state_values: average --- src/libs/routes/cub.js | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/libs/routes/cub.js b/src/libs/routes/cub.js index 319d65b7..f80c8779 100644 --- a/src/libs/routes/cub.js +++ b/src/libs/routes/cub.js @@ -134,24 +134,39 @@ rqf.addField({ cubApp.get('/last_state_values', rqf.parse(), rqf.build(), (req, res, next) => { - var table_b = squel.select().from('cub') + var sub_table = squel.select().from('cub') .field('estado_id') .field('MAX(ano_censo*100 + mes_censo)', 'ano_censo') .group('estado_id') - req.sql.from('cub', 'a') - .field('a.ano_censo', 'ano') - .field('a.mes_censo', 'mes') - .field('a.estado_id', 'cod_uf') + var states = squel.select().from('cub') + .field('cub.ano_censo', 'ano') + .field('cub.mes_censo', 'mes') + .field('cub.estado_id', 'cod_uf') .field('estado.sigla', 'sigla_uf') - .field('a.tipo_preco', 'tipo_preco') - .field('a.preco', 'preco') + .field('cub.tipo_preco', 'tipo_preco') + .field('cub.preco', 'preco') .join( - table_b, - 'b', - 'a.estado_id = b.estado_id AND a.ano_censo = (b.ano_censo/100)' + sub_table, + 'sub', + 'cub.estado_id = sub.estado_id AND cub.ano_censo = (sub.ano_censo/100)' ) - .join('estado', null, 'a.estado_id = estado.id') + .join('estado', null, 'cub.estado_id = estado.id') + + var average = squel.select().from(states, "states") + .field('AVG(states.preco)', 'preco') + .field("'BR'", 'sigla_uf') + .field('states.tipo_preco') + .group('states.tipo_preco') + + if (req.filter.size || req.dims.size){ + if ('state' in req.filter || 'state' in req.dims){ + req.sql = states + } + } + else{ + req.sql = average + } next(); }, query, id2str.transform(), response('last_state_values')) -- GitLab From 3565b094dc4573b4fc1226fe337d7aee91685f71 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Tue, 26 Oct 2021 13:07:21 -0300 Subject: [PATCH 052/305] fix filter problem --- src/libs/routes/cub.js | 57 +++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/src/libs/routes/cub.js b/src/libs/routes/cub.js index f80c8779..cfc2848a 100644 --- a/src/libs/routes/cub.js +++ b/src/libs/routes/cub.js @@ -134,38 +134,49 @@ rqf.addField({ cubApp.get('/last_state_values', rqf.parse(), rqf.build(), (req, res, next) => { - var sub_table = squel.select().from('cub') + var price_by_id = squel.select().from('cub') .field('estado_id') .field('MAX(ano_censo*100 + mes_censo)', 'ano_censo') .group('estado_id') - var states = squel.select().from('cub') - .field('cub.ano_censo', 'ano') - .field('cub.mes_censo', 'mes') - .field('cub.estado_id', 'cod_uf') - .field('estado.sigla', 'sigla_uf') - .field('cub.tipo_preco', 'tipo_preco') - .field('cub.preco', 'preco') - .join( - sub_table, - 'sub', - 'cub.estado_id = sub.estado_id AND cub.ano_censo = (sub.ano_censo/100)' - ) - .join('estado', null, 'cub.estado_id = estado.id') - - var average = squel.select().from(states, "states") - .field('AVG(states.preco)', 'preco') - .field("'BR'", 'sigla_uf') - .field('states.tipo_preco') - .group('states.tipo_preco') - if (req.filter.size || req.dims.size){ if ('state' in req.filter || 'state' in req.dims){ - req.sql = states + //req.sql = states + req.sql.from('cub') + .field('cub.ano_censo', 'ano') + .field('cub.mes_censo', 'mes') + .field('cub.tipo_preco', 'tipo_preco') + .field('cub.preco', 'preco') + .join( + price_by_id, + 'sub', + 'cub.estado_id = sub.estado_id AND cub.ano_censo = (sub.ano_censo/100)' + ) + .join('estado', null, 'cub.estado_id = estado.id') + .group('cub.ano_censo') + .group('cub.mes_censo') + .group('cub.tipo_preco') + .group('cub.preco') + } + else{ + req.sql.from("cub") } } else{ - req.sql = average + //req.sql = average + req.sql.from( + squel.select().from('cub') + .field('cub.tipo_preco', 'tipo_preco') + .field('cub.preco', 'preco') + .join(price_by_id, 'sub', + 'cub.estado_id = sub.estado_id AND cub.ano_censo = (sub.ano_censo/100)' + ) + .join('estado', null, 'cub.estado_id = estado.id') + , "states") + .field('AVG(states.preco)', 'preco') + .field("'BR'", 'sigla_uf') + .field('states.tipo_preco') + .group('states.tipo_preco') } next(); }, query, id2str.transform(), response('last_state_values')) -- GitLab From 365f43752668b3d46ded95e6eeae610f1e916639 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Thu, 11 Nov 2021 12:07:55 -0300 Subject: [PATCH 053/305] disallow table to join itself --- src/libs/middlewares/reqQueryFields.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libs/middlewares/reqQueryFields.js b/src/libs/middlewares/reqQueryFields.js index 61f98963..57bcff33 100644 --- a/src/libs/middlewares/reqQueryFields.js +++ b/src/libs/middlewares/reqQueryFields.js @@ -217,18 +217,20 @@ class ReqQueryFields { if(value.join.foreignTable === '@') foreignTable = thisTable+'.'; // Fazemos o join let onClause = ''; - if(Array.isArray(value.join.primary)) { - // Se é um array, montamos a cláusula ON com mais de uma coluna - value.join.primary.forEach((column, index, arr) => { - onClause += foreignTable+value.join.foreign[index]+'='+value.table+'.'+column; - if(index < arr.length-1) { - onClause+=' AND '; - } - }); - } else { - onClause = foreignTable+value.join.foreign+'='+value.table+'.'+value.join.primary; + if (foreignTable !== value.table+'.') { // Não é feito join de uma tabela com ela mesma + if(Array.isArray(value.join.primary)) { + // Se é um array, montamos a cláusula ON com mais de uma coluna + value.join.primary.forEach((column, index, arr) => { + onClause += foreignTable+value.join.foreign[index]+'='+value.table+'.'+column; + if(index < arr.length-1) { + onClause+=' AND '; + } + }); + } else { + onClause = foreignTable+value.join.foreign+'='+value.table+'.'+value.join.primary; + } + sql.join(value.table, null, onClause); } - sql.join(value.table, null, onClause); // Marcamos o join como feito para não ter problemas hasJoined[value.table] = true; } -- GitLab From 6d4ade686c7ebc1ea50ea6833796dcdde96d4007 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Thu, 11 Nov 2021 12:15:16 -0300 Subject: [PATCH 054/305] adapt data fetch to school dim --- src/libs/routes/classroomCount.js | 115 +++++++++++++----------------- 1 file changed, 50 insertions(+), 65 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 48a35525..43ce528d 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -113,6 +113,21 @@ rqf.addField({ foreign: 'estado_id', foreignTable: '@' } +}, 'dims').addValueToField({ + name: 'school', + table: 'escola', + tableField: ['nome_escola', 'id'], + resultField: ['school_name', 'school_id'], + where: { + relation: '=', + type: 'integer', + field: 'id', + }, + join: { + primary: 'id', + foreign: 'escola_id', + foreignTable: '@' + } }, 'dims').addValue({ name: 'region', table: 'regiao', @@ -281,6 +296,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let integralTime = req.integralTime.find((el) => {return el.id === educationLevelId}); let numberStudentClass = (typeof classSize !== 'undefined') ? classSize.numberStudentClass : null; + // Usa o offerGoal que é passado como parâmetro (Brasil inteiro). Atenção para isso. let integralTimeOfferGoal = (typeof integralTime !== 'undefined') ? integralTime.offerGoal : null; let teacherByClass = (typeof classSize !== 'undefined') ? classSize.teacherByClass : null; @@ -323,43 +339,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { req.resetSql(); next(); }, rqf.parse(), (req, res, next) => { - if ("state" in req.filter) { - req.dims.state = true; - req.dims.city = true; - req.dims.school_year = true; - req.dims.location = true; - req.sql.field('sum(indice_distribuicao_matriculas.indice)', 'total') - .field("'Brasil'", 'name') - .field('indice_distribuicao_matriculas.ano_censo', 'year') - .from('indice_distribuicao_matriculas') - .where('indice_distribuicao_matriculas.nivel_simulacao = 2') - .where('indice_distribuicao_matriculas.serie_ano_id < 15') - .group('indice_distribuicao_matriculas.ano_censo') - .order('indice_distribuicao_matriculas.ano_censo') - } - else { - req.dims.state = true; - req.dims.city = true; - req.dims.school_year = true; - req.dims.location = true; - req.sql.field('sum(indice_distribuicao_matriculas.indice)', 'idm') - .field("'Brasil'", 'name') - .field('indice_distribuicao_matriculas.ano_censo', 'year') - .from('indice_distribuicao_matriculas') - .where('indice_distribuicao_matriculas.nivel_simulacao = 1') - .where('indice_distribuicao_matriculas.serie_ano_id < 15') - .group('indice_distribuicao_matriculas.ano_censo') - .order('indice_distribuicao_matriculas.ano_censo') - } - - next(); -}, rqf.build(), query, id2str.transform(), (req, res, next) => { - req.idm = req.result; - delete req.dims; - delete req.filter; - req.resetSql(); - next(); -},rqf.parse(), (req, res, next) => { if (req.body.teacher_journey !== undefined) { req.teacherJourney = JSON.parse(req.body.teacher_journey) || null; @@ -426,32 +405,37 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { .order('matricula.ano_censo') .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); next(); -}, rqf.build(), query, id2str.transform(), (req, res, next) => { - +}, rqf.build() ,query, id2str.transform(), (req, res, next) => { + // constrói objeto de tempo integral e calcula diagnósticos var integral_time_result = req.result req.integral_time = {} for (let i = 0; i < integral_time_result.length; ++i){ // Se cidade não foi criada, cria let integral_time = integral_time_result[i]; - let cityHash = '' + integral_time.year + integral_time.city_id - //let currentCity = null; - let currentCity = req.integral_time[cityHash] + let code = '' + integral_time.year + integral_time.city_id + if (req.dims.school) code = code + integral_time.school_id - // Cria cidade caso não exista - if (currentCity === undefined){ + let currentCodeObj = req.integral_time[code] + + // Cria município ou escola caso não exista + if (currentCodeObj === undefined){ let obj = { year: integral_time.year, city_id: integral_time.city_id, city_name: integral_time.city_name, integral_time: {} } - req.integral_time[cityHash] = obj - currentCity = obj; + if (req.dims.school){ + obj.school_id = integral_time.school_id + obj.school_name = integral_time.school_name + } + req.integral_time[code] = obj + currentCodeObj = obj; } // Pega objeto com dados do nível atual - let level = integral_time.education_level_short_id - let levelObj = currentCity.integral_time[level] + var level = integral_time.education_level_short_id + var levelObj = currentCodeObj.integral_time[level] if (levelObj === undefined){ levelObj = { id: level, @@ -463,19 +447,19 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { // Soma no total em integralTime, caso seja 1 levelObj.total += integral_time.total if (integral_time.integral_time_id === 1){ - levelObj.integralTime += integral_time.total + levelObj.integralTime += integral_time.total } - currentCity.integral_time[level] = levelObj + currentCodeObj.integral_time[level] = levelObj } for (let i in req.integral_time){ - let city = req.integral_time[i] + let curObj = req.integral_time[i] // Adiciona diagnóstico aos objetos - for (let key in city.integral_time){ - let cur = city.integral_time[key] - cur["diagnosis"] = cur.total ? (cur.integralTime/cur.total)*100.0 : 0; - city.integral_time[key] = cur + for (let key in curObj.integral_time){ + let cur = curObj.integral_time[key] + cur["diagnosis"] = cur.total ? (cur.integralTime/cur.total)*100.0 : 0.0; + curObj.integral_time[key] = cur } } @@ -484,10 +468,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { req.resetSql(); next() }, rqf.parse(), rqf.build(), (req, res, next) => { - // req.classroom = req.result; - // req.idm = req.result; - - // req.result = [{classroom: req.classroom, enrollment: req.enrollment}]; return next(); let enrollmentProjectionNight = []; let enrollmentProjectionDay = []; @@ -506,7 +486,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } let result = []; - // Cria estrutura de resposta requisitada: + // Cria estrutura de resposta requisitada (itera por anos de projeção): for(let yearCount = 0; yearCount < qntYears; yearCount++) { let i = 0; let j = 0; @@ -520,11 +500,12 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let ti = 0; // index for teacher table - // estado, cidade, local, prédio while (i < req.classroom.length) { let classroom = req.classroom[i]; // Cria hash única para cada espacialidade, dado um ano - let hash = '' + yearCount + classroom.state_id + classroom.city_id; + let hash = '' + yearCount + classroom.state_id + classroom.city_id; + if (req.dims.school) + hash = hash + classroom.school_id // Estrutura do objeto do resultado final let obj = { year: classroom.year + yearCount, @@ -533,6 +514,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { state_name: classroom.state_name, city_id: classroom.city_id, city_name: classroom.city_name, + // school_id, school_name locations: [] }; @@ -545,8 +527,9 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { education_level: [] }; + // Ajusta estrutura de localização do último [município/escola] e inicializa variáveis para o atual let currentClassroomObj = null; - if( !hashSet.has(hash) ) { + if( !hashSet.has(hash) ) { // Nunca passou por esse município/escola if (result[result.length - 1] !== undefined) { // Após mudar de cidade, passamos pela cidade anterior e juntamos o valor to_be_built de localizações com o mesmo id let last_locations = result[result.length - 1].locations for (let i = 0; i < last_locations.length - 1; i++) { @@ -618,8 +601,9 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { if(enrollmentEducationLevel.numberStudentClass == null) continue; + // Adiciona nível de educação para município/escola let educationLevel = null; - if(!educationLevelSet.has(enrollmentEducationLevel.id)) { + if(!educationLevelSet.has(enrollmentEducationLevel.id)) { // cria e insere ordenadamente novo education level educationLevelSet.add(enrollmentEducationLevel.id); educationLevel = { @@ -654,7 +638,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { k++; location.education_level.splice(k, 0, educationLevel); } - } else { + } else { // pega o objeto de education level já existente let k = 0; let el = location.education_level[k]; while(k < location.education_level.length) { @@ -707,6 +691,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } // Faz match da tabela de idm com a de enrollment + // Quer dizer achar no req.idm onde está o índice com a localidade e nível de educação do objeto atual. if (educationLevel.education_level_short_id !== 1) { while (req.idm[ei].school_year_id < educationLevel.education_level_short_id) ei++; while (req.idm[ei].school_year_id > educationLevel.education_level_short_id) ei--; -- GitLab From b22a6ab104593dafcf5f5a4e4aec8c47dcfd4d67 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 19 Nov 2021 13:08:05 -0300 Subject: [PATCH 055/305] Implementa dim de escolas --- src/libs/routes/classroomCount.js | 124 +++++++++++++++++------------- 1 file changed, 70 insertions(+), 54 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 43ce528d..e3d380fa 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -124,8 +124,8 @@ rqf.addField({ field: 'id', }, join: { - primary: 'id', - foreign: 'escola_id', + primary: ['id', 'ano_censo'], + foreign: ['escola_id', 'ano_censo'], foreignTable: '@' } }, 'dims').addValue({ @@ -328,7 +328,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { .group('escola.ano_censo') .order('escola.ano_censo') .where('escola.situacao_de_funcionamento = 1') - .where('escola.dependencia_adm_id < 4') + .where('escola.dependencia_adm_id < 4') .where('escola.ensino_regular = 1 OR escola.ensino_eja = 1 OR escola.educacao_profissional = 1'); next(); @@ -417,7 +417,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentCodeObj = req.integral_time[code] - // Cria município ou escola caso não exista + // Cria município/escola caso não exista if (currentCodeObj === undefined){ let obj = { year: integral_time.year, @@ -469,6 +469,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { next() }, rqf.parse(), rqf.build(), (req, res, next) => { + // Talvez dê para remover todos os req.projections. let enrollmentProjectionNight = []; let enrollmentProjectionDay = []; if (req.projections) { @@ -482,7 +483,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } let qntYears = 1; if (req.projections) { - qntYears = enrollmentProjectionDay[0].stagesEnrollments[0].seriesEnrollments[0].enrollments.length; + qntYears = enrollmentProjectionDay[0].stagesEnrollments[0].seriesEnrollments[0].enrollments.length; } let result = []; @@ -514,9 +515,12 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { state_name: classroom.state_name, city_id: classroom.city_id, city_name: classroom.city_name, - // school_id, school_name - locations: [] }; + if (req.dims.school){ + obj.school_id = classroom.school_id, + obj.school_name = classroom.school_name + } + obj.locations = [] // Inserimos a localidade no array de locations da sala let location = { @@ -576,14 +580,22 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ++j; continue; } - - if(classroom.city_id !== enrollment.city_id) { // Se as cidades não são iguais, já passamos do range - enrollmentMatch = false; - while (req.idm[ei].city_id !== enrollment.city_id) { - ei++; - } - continue; - } + + if (req.dims.school){ + if(classroom.school_id !== enrollment.school_id) { // Se as escolas não são iguais, já passamos do range + enrollmentMatch = false; + continue; + } + } + else{ + if(classroom.city_id !== enrollment.city_id) { // Se as cidades não são iguais, já passamos do range + enrollmentMatch = false; + continue; + } + } +// while (req.idm[ei].city_id !== enrollment.city_id) { +// ei++; +// } if(enrollment.year != classroom.year || enrollment.location_id != classroom.location_id) { // Se ano ou localização são diferentes, passa para o próximo ++j; @@ -591,7 +603,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } - // Temos uma matrícula com cidade, ano e localidades certos + // Temos uma matrícula com cidade/escola, ano e localidades certos // "Consome" a matrícula (remove do vetor de matrículas) enrollments.splice(j, 1); @@ -655,6 +667,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentSchoolYear = null; if(enrollmentEducationLevel.id == 1){ let schoolYearHash = '' + enrollment.year + enrollment.city_id + enrollment.location_id + enrollment.school_year_id; + if (req.dims.shool) schoolYearHash = schoolYearHash + enrollment.shcool_id + if(schoolYearSet.has(schoolYearHash)) { // Busca a série escolar let k = 0; let el = educationLevel.classes_school_year[k]; @@ -692,22 +706,27 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { // Faz match da tabela de idm com a de enrollment // Quer dizer achar no req.idm onde está o índice com a localidade e nível de educação do objeto atual. - if (educationLevel.education_level_short_id !== 1) { - while (req.idm[ei].school_year_id < educationLevel.education_level_short_id) ei++; - while (req.idm[ei].school_year_id > educationLevel.education_level_short_id) ei--; - - if (req.idm[ei].location_id < location.location_id) { - ei++; - } - else if(req.idm[ei].location_id > location.location_id) { - ei--; - } - } - let enrollmentIdm = req.idm[ei]; + // if (educationLevel.education_level_short_id !== 1) { + // while (req.idm[ei].school_year_id < educationLevel.education_level_short_id) ei++; + // while (req.idm[ei].school_year_id > educationLevel.education_level_short_id) ei--; + + // if (req.idm[ei].location_id < location.location_id) { + // ei++; + // } + // else if(req.idm[ei].location_id > location.location_id) { + // ei--; + // } + // } + // let enrollmentIdm = req.idm[ei]; let cur_year = enrollment.year let cur_city = enrollment.city_id let hash = '' + cur_year + cur_city + if (req.dims.school){ + let cur_school = enrollment.school_id + hash += cur_school + } + let cur_education_level_short = educationLevel.education_level_short_id let cur_diagnosis = 0 @@ -750,39 +769,39 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { verifySchoolYear[location.location_id-1][educationLevel.education_level_short_id] = 1; // Projeção de matricula multiplicada pelo indice de distribuição de matriculas da localização. - if (req.projections && (currentEnrollmentOfferDay.enrollments !== undefined) ) { - educationLevel.enrollment.total_enrollment_day += parseFloat(((currentEnrollmentOfferDay.enrollments[yearCount].quantity - currentEnrollmentOfferDay.currentOffer)*enrollmentIdm.idm).toFixed(2)); - if (educationLevel.enrollment.total_enrollment_day < 0) educationLevel.enrollment.total_enrollment_day = 0; - educationLevel.enrollment.total_enrollment_night += (educationLevel.education_level_short_id > 2) ? parseFloat(((currentEnrollmentOfferNight.enrollments[yearCount].quantity - currentEnrollmentOfferNight.currentOffer)*enrollmentIdm.idm).toFixed(2)) : 0; - if (educationLevel.enrollment.total_enrollment_night < 0) educationLevel.enrollment.total_enrollment_night = 0; - } + // if (req.projections && (currentEnrollmentOfferDay.enrollments !== undefined) ) { + // educationLevel.enrollment.total_enrollment_day += parseFloat(((currentEnrollmentOfferDay.enrollments[yearCount].quantity - currentEnrollmentOfferDay.currentOffer)*enrollmentIdm.idm).toFixed(2)); + // if (educationLevel.enrollment.total_enrollment_day < 0) educationLevel.enrollment.total_enrollment_day = 0; + // educationLevel.enrollment.total_enrollment_night += (educationLevel.education_level_short_id > 2) ? parseFloat(((currentEnrollmentOfferNight.enrollments[yearCount].quantity - currentEnrollmentOfferNight.currentOffer)*enrollmentIdm.idm).toFixed(2)) : 0; + // if (educationLevel.enrollment.total_enrollment_night < 0) educationLevel.enrollment.total_enrollment_night = 0; + // } } // Faz os mesmos cálculos para a série escolar if(currentSchoolYear) { // Faz match da enrollment com o idm, no caso de não usar o mod - while (req.idm[ei].school_year_id < enrollment.school_year_id) ei++; - while (req.idm[ei].school_year_id > enrollment.school_year_id) ei--; + // while (req.idm[ei].school_year_id < enrollment.school_year_id) ei++; + // while (req.idm[ei].school_year_id > enrollment.school_year_id) ei--; - if (req.idm[ei].location_id < location.location_id) { - ei++; - } - else if(req.idm[ei].location_id > location.location_id) { - ei--; - } - enrollmentIdm = req.idm[ei]; + // if (req.idm[ei].location_id < location.location_id) { + // ei++; + // } + // else if(req.idm[ei].location_id > location.location_id) { + // ei--; + // } + // enrollmentIdm = req.idm[ei]; // Totais de matrícula currentSchoolYear.total_enrollment_day += enrollment.total_day; - if (req.projections && !verifySchoolYear[location.location_id-1][currentSchoolYear.school_year_id]) { // Garantimos que será somado apenas uma vez por localização. - verifySchoolYear[location.location_id-1][currentSchoolYear.school_year_id] = 1; + // if (req.projections && !verifySchoolYear[location.location_id-1][currentSchoolYear.school_year_id]) { // Garantimos que será somado apenas uma vez por localização. + // verifySchoolYear[location.location_id-1][currentSchoolYear.school_year_id] = 1; - let currentEnrollmentSchoolYear = currentEnrollmentOfferDay.seriesEnrollments[Math.trunc(currentSchoolYear.school_year_id/10) - 1]; - currentSchoolYear.total_enrollment_day += (currentEnrollmentSchoolYear !== undefined) ? parseFloat(((currentEnrollmentSchoolYear.enrollments[yearCount].quantity - currentEnrollmentSchoolYear.currentOffer)*enrollmentIdm.idm).toFixed(2)) : 0; - if (currentSchoolYear.total_enrollment_day < 0) currentSchoolYear.total_enrollment_day = 0; - } + // let currentEnrollmentSchoolYear = currentEnrollmentOfferDay.seriesEnrollments[Math.trunc(currentSchoolYear.school_year_id/10) - 1]; + // currentSchoolYear.total_enrollment_day += (currentEnrollmentSchoolYear !== undefined) ? parseFloat(((currentEnrollmentSchoolYear.enrollments[yearCount].quantity - currentEnrollmentSchoolYear.currentOffer)*enrollmentIdm.idm).toFixed(2)) : 0; + // if (currentSchoolYear.total_enrollment_day < 0) currentSchoolYear.total_enrollment_day = 0; + // } // Número de turmas parcial currentSchoolYear.full_period_classes = parseFloat(((currentSchoolYear.total_enrollment_day * (currentIntegralOfferGoal/100)) / currentNumberStudentClass).toFixed(2)); @@ -832,7 +851,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { // Agregar por estado e brasil let reduction = null; - if(req.dims.state || !req.dims.city) { // Se um dos dois acontecer, sabemos que devemos agregar + + if(req.dims.state || (!req.dims.city && !req.dims.school)) { // Se um dos dois acontecer, sabemos que devemos agregar let i = 0; reduction = []; let reductionSet = new Set(); @@ -1022,8 +1042,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } } - // console.log(teacherByFormation, teacherTotal); - // verifica se a soma de porcentagens vale 100. let sum = 0; for (let value of teacherByFormation) { @@ -1040,8 +1058,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } } - // console.log(teacherByFormation) - lastLocations.forEach((location) => { location.education_level.forEach((educationLevel) => { let educationLevelId = educationLevel.education_level_short_id; -- GitLab From 69173d03366ec951c82ca1f7a9c5da8d46b2809f Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 19 Nov 2021 13:23:59 -0300 Subject: [PATCH 056/305] clean code --- src/libs/routes/classroomCount.js | 59 ------------------------------- 1 file changed, 59 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index e3d380fa..3411f79c 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -494,11 +494,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let hashSet = new Set(); let enrollments = [...req.enrollment]; - let ei = 0; // index for idm table - let eiCityStart = 0; - - let verifySchoolYear; // Matriz para verificar se o idm já foi inserido no school year. - let ti = 0; // index for teacher table while (i < req.classroom.length) { @@ -553,9 +548,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { result.push(obj); currentClassroomObj = obj; - eiCityStart = ei; - - verifySchoolYear = Array.from(Array(2), () => new Array(15)); while (req.teacher[ti].city_id !== classroom.city_id) { // match da tabela de professores. ti++; @@ -563,7 +555,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } else { // Se a hash já existe, já temos a cidade nos resultados. Como está ordenado, é o último valor nos resultados currentClassroomObj = result[result.length - 1]; - ei = eiCityStart; } currentClassroomObj.locations.push(location); @@ -593,9 +584,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { continue; } } -// while (req.idm[ei].city_id !== enrollment.city_id) { -// ei++; -// } if(enrollment.year != classroom.year || enrollment.location_id != classroom.location_id) { // Se ano ou localização são diferentes, passa para o próximo ++j; @@ -704,21 +692,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } } - // Faz match da tabela de idm com a de enrollment - // Quer dizer achar no req.idm onde está o índice com a localidade e nível de educação do objeto atual. - // if (educationLevel.education_level_short_id !== 1) { - // while (req.idm[ei].school_year_id < educationLevel.education_level_short_id) ei++; - // while (req.idm[ei].school_year_id > educationLevel.education_level_short_id) ei--; - - // if (req.idm[ei].location_id < location.location_id) { - // ei++; - // } - // else if(req.idm[ei].location_id > location.location_id) { - // ei--; - // } - // } - // let enrollmentIdm = req.idm[ei]; - let cur_year = enrollment.year let cur_city = enrollment.city_id let hash = '' + cur_year + cur_city @@ -765,44 +738,12 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { currentEnrollmentOfferDay = enrollmentProjectionDay[enrollment.location_id - 1].stagesEnrollments[educationLevel.education_level_short_id - 1]; currentEnrollmentOfferNight = enrollmentProjectionNight[enrollment.location_id - 1].stagesEnrollments[educationLevel.education_level_short_id - 1]; } - if (!verifySchoolYear[location.location_id-1][educationLevel.education_level_short_id]) { // Garantimos que será somado apenas uma vez por localização. - verifySchoolYear[location.location_id-1][educationLevel.education_level_short_id] = 1; - - // Projeção de matricula multiplicada pelo indice de distribuição de matriculas da localização. - // if (req.projections && (currentEnrollmentOfferDay.enrollments !== undefined) ) { - // educationLevel.enrollment.total_enrollment_day += parseFloat(((currentEnrollmentOfferDay.enrollments[yearCount].quantity - currentEnrollmentOfferDay.currentOffer)*enrollmentIdm.idm).toFixed(2)); - // if (educationLevel.enrollment.total_enrollment_day < 0) educationLevel.enrollment.total_enrollment_day = 0; - // educationLevel.enrollment.total_enrollment_night += (educationLevel.education_level_short_id > 2) ? parseFloat(((currentEnrollmentOfferNight.enrollments[yearCount].quantity - currentEnrollmentOfferNight.currentOffer)*enrollmentIdm.idm).toFixed(2)) : 0; - // if (educationLevel.enrollment.total_enrollment_night < 0) educationLevel.enrollment.total_enrollment_night = 0; - // } - } // Faz os mesmos cálculos para a série escolar if(currentSchoolYear) { - // Faz match da enrollment com o idm, no caso de não usar o mod - // while (req.idm[ei].school_year_id < enrollment.school_year_id) ei++; - // while (req.idm[ei].school_year_id > enrollment.school_year_id) ei--; - - // if (req.idm[ei].location_id < location.location_id) { - // ei++; - // } - // else if(req.idm[ei].location_id > location.location_id) { - // ei--; - // } - // enrollmentIdm = req.idm[ei]; - - // Totais de matrícula currentSchoolYear.total_enrollment_day += enrollment.total_day; - // if (req.projections && !verifySchoolYear[location.location_id-1][currentSchoolYear.school_year_id]) { // Garantimos que será somado apenas uma vez por localização. - // verifySchoolYear[location.location_id-1][currentSchoolYear.school_year_id] = 1; - - // let currentEnrollmentSchoolYear = currentEnrollmentOfferDay.seriesEnrollments[Math.trunc(currentSchoolYear.school_year_id/10) - 1]; - // currentSchoolYear.total_enrollment_day += (currentEnrollmentSchoolYear !== undefined) ? parseFloat(((currentEnrollmentSchoolYear.enrollments[yearCount].quantity - currentEnrollmentSchoolYear.currentOffer)*enrollmentIdm.idm).toFixed(2)) : 0; - // if (currentSchoolYear.total_enrollment_day < 0) currentSchoolYear.total_enrollment_day = 0; - // } - // Número de turmas parcial currentSchoolYear.full_period_classes = parseFloat(((currentSchoolYear.total_enrollment_day * (currentIntegralOfferGoal/100)) / currentNumberStudentClass).toFixed(2)); -- GitLab From 484ff9da2d0c25c9dd5a9e9ad0d40e5f2e32cbdd Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Tue, 23 Nov 2021 10:49:44 -0300 Subject: [PATCH 057/305] issue 758 changes --- src/libs/routes/classroomCount.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 3411f79c..732aa868 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -989,15 +989,12 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { sum += value; } let diff = 1 - sum; - // Se for menor/maior que 100 soma/subtrai na P2 caso exista, se não na P1 + // Se for menor/maior que 100 soma/subtrai na P2 if (Math.abs(diff) > 0.0001) { - if (teacherByFormation[1] > 0) { - teacherByFormation[1] += diff; - } - else { - teacherByFormation[0] += diff; - } + teacherByFormation[1] += diff; } + teacherByFormation[1] += teacherByFormation[0] + teacherByFormation[0] = 0 lastLocations.forEach((location) => { location.education_level.forEach((educationLevel) => { -- GitLab From 6d9a446995b4f5730557601b2641a8a3cde8ed00 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 3 Dec 2021 14:45:30 -0300 Subject: [PATCH 058/305] add percentages classroom count --- src/libs/routes/classroomCount.js | 46 ++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 732aa868..249538dd 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -605,11 +605,29 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let educationLevel = null; if(!educationLevelSet.has(enrollmentEducationLevel.id)) { // cria e insere ordenadamente novo education level educationLevelSet.add(enrollmentEducationLevel.id); + + let itHash = '' + enrollment.year + enrollment.city_id + if (req.dims.school) itHash += enrollment.school_id + + let cur_education_level_short = enrollmentEducationLevel.id + + let level_diagnosis = 0 + let integral_time = 0; + let integral_time_total = 0; + if (req.integral_time[itHash].integral_time[cur_education_level_short]){ + level_diagnosis = parseFloat( (req.integral_time[itHash].integral_time[cur_education_level_short].diagnosis).toFixed(2) ) + integral_time = req.integral_time[itHash].integral_time[cur_education_level_short].integralTime + integral_time_total = req.integral_time[itHash].integral_time[cur_education_level_short].total + } educationLevel = { education_level_short_id: enrollmentEducationLevel.id, education_level_short_name: enrollmentEducationLevel.name, + enrollment: { + integral_percentage: level_diagnosis, + integral_time: integral_time, + integral_time_total: integral_time_total, total_enrollment_day: 0, total_enrollment_night: 0, full_period_classes: 0, @@ -692,22 +710,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } } - let cur_year = enrollment.year - let cur_city = enrollment.city_id - let hash = '' + cur_year + cur_city - if (req.dims.school){ - let cur_school = enrollment.school_id - hash += cur_school - } - - let cur_education_level_short = educationLevel.education_level_short_id - - let cur_diagnosis = 0 - if (req.integral_time[hash].integral_time[cur_education_level_short]){ - cur_diagnosis = req.integral_time[hash].integral_time[cur_education_level_short].diagnosis - } - - let currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, cur_diagnosis); + let currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, educationLevel.enrollment.integral_percentage); let currentNumberStudentClass = (enrollment.location_id == 1) ? enrollmentEducationLevel.numberStudentClass.urban : enrollmentEducationLevel.numberStudentClass.country; // Soma os totais de matrícula da etapa de ensino @@ -872,6 +875,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { currentEducation = currentLocation.education_level[m]; if(currentEducation.education_level_short_id == cityEducation.education_level_short_id) { + currentEducation.enrollment.integral_time += cityEducation.enrollment.integral_time; + currentEducation.enrollment.integral_time_total += cityEducation.enrollment.integral_time_total; currentEducation.enrollment.total_enrollment_day += cityEducation.enrollment.total_enrollment_day; currentEducation.enrollment.total_enrollment_night += cityEducation.enrollment.total_enrollment_night; currentEducation.enrollment.full_period_classes += cityEducation.enrollment.full_period_classes; @@ -963,6 +968,15 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } ++i; } + for (let state of reduction){ + for (let location of state.locations){ + for (let educationLevel of location.education_level){ + let total = educationLevel.enrollment.integral_time_total; + let integralTime = educationLevel.enrollment.integral_time; + educationLevel.enrollment.integral_percentage = total ? parseFloat( (100*(integralTime / total)).toFixed(2) ) : 0 + } + } + } } req.result = reduction || result; -- GitLab From 178d0368a6a14d0ddc9e636bb19b9aa16bfad721 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Mon, 22 Nov 2021 11:58:40 -0300 Subject: [PATCH 059/305] create dim course --- src/libs/convert/academicLevel.js | 2 + src/libs/routes/courseCount.js | 253 ++++++++++++++++++++++-- src/libs/routes/universityEnrollment.js | 36 +++- 3 files changed, 277 insertions(+), 14 deletions(-) diff --git a/src/libs/convert/academicLevel.js b/src/libs/convert/academicLevel.js index 3f76bc11..d04079de 100644 --- a/src/libs/convert/academicLevel.js +++ b/src/libs/convert/academicLevel.js @@ -26,6 +26,8 @@ module.exports = function academicLevel(id) { return 'Licenciatura'; case 3: return 'Tecnológico'; + case 4: + return 'Bacharelado e Licenciatura' default: return 'Não classificada'; } diff --git a/src/libs/routes/courseCount.js b/src/libs/routes/courseCount.js index b86a3a6d..04beaad4 100644 --- a/src/libs/routes/courseCount.js +++ b/src/libs/routes/courseCount.js @@ -19,6 +19,7 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. */ const express = require('express'); +const { join } = require('lodash'); const courseCountApp = express.Router(); @@ -42,6 +43,8 @@ const addMissing = require(`${libs}/middlewares/addMissing`); let rqf = new ReqQueryFields(); +let rqfMapfor = new ReqQueryFields(); + courseCountApp.get('/upper_adm_dependency', (req, res, next) => { req.result = []; for(let i = 1; i <= 7; ++i) { @@ -230,6 +233,135 @@ courseCountApp.get('/localoffer', (req, res, next) => { next(); }, query, response('localoffer')); + +rqfMapfor.addField({ + name: 'filter', + field: false, + where: true +}).addField({ + name: 'dims', + field: true, + where: false +}).addValueToField({ + name: 'state', + table: 'municipio', + tableField: 'estado_id', + resultField: 'state_id', + where: { + relation: '=', + type: 'integer', + field: 'estado_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio', + foreignTable: 'localoferta_ens_superior' + } +}, 'filter').addValue({ + name: 'mesoregion', + table: 'municipio', + tableField: ['nome_mesorregiao', 'mesorregiao_id'], + resultField: ['mesoregion_name', 'mesoregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'mesorregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio', + foreignTable: 'localoferta_ens_superior' + } +}).addValue({ + name: 'microregion', + table: 'municipio', + tableField: ['nome_microrregiao', 'microrregiao_id'], + resultField: ['microregion_name', 'microregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'microrregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio', + foreignTable: 'localoferta_ens_superior' + } +}).addValue({ + name: 'city', + table: 'municipio', + tableField: ['id', 'nome'], + resultField: ['city_id', 'city_name'], + where: { + relation: '=', + type: 'integer', + field: 'id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio', + foreignTable: 'localoferta_ens_superior' + } +}).addValue({ + name:'academic_level', + table: 'curso_ens_superior', + tableField: 'cod_grau_academico', + resultField: 'academic_level_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_grau_academico' + } +}).addValue({ + name: 'min_year', + table: 'localoferta_ens_superior', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '>=', + type: 'integer', + table: 'localoferta_ens_superior', + field: 'ano_censo' + } +}).addValue({ + name: 'max_year', + table: 'localoferta_ens_superior', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '<=', + type: 'integer', + table: 'localoferta_ens_superior', + field: 'ano_censo' + } +}).addValue({ + name:'course', + table: 'curso_ens_superior', + tableField: 'nome_curso', + resultField: 'course_name', + where: { + relation: 'LIKE', + type: 'string', + field: 'nome_curso' + } +}).addValueToField({ + name: 'campi', + table: 'localoferta_ens_superior', + tableField: ['cod_local_oferta', 'nome'], + resultField: ['campi_id', 'campi_name'], + where: { + relation: '=', + type: 'integer', + field: 'cod_local_oferta', + table: 'localoferta_ens_superior' + } +}, 'filter') + + rqf.addField({ name: 'filter', field: false, @@ -270,6 +402,38 @@ rqf.addField({ foreign: ['ano_censo', 'cod_curso'], foreignTable: 'curso_ens_superior' } +}).addValue({ + name: 'mesoregion', + table: 'municipio', + tableField: ['nome_mesorregiao', 'mesorregiao_id'], + resultField: ['mesoregion_name', 'mesoregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'mesorregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio_curso', + foreignTable: 'curso_ens_superior' + } +}).addValue({ + name: 'microregion', + table: 'municipio', + tableField: ['nome_microrregiao', 'microrregiao_id'], + resultField: ['microregion_name', 'microregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'microrregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio_curso', + foreignTable: 'curso_ens_superior' + } }).addValue({ name: 'city', table: 'localoferta_ens_superior', @@ -302,6 +466,22 @@ rqf.addField({ foreign: ['ano_censo', 'cod_curso'], foreignTable: 'curso_ens_superior' } +}).addValue({ + name: 'campi', + table: 'localoferta_ens_superior', + tableField: ['cod_local_oferta', 'nome'], + resultField: ['campi_id', 'campi_name'], + where: { + relation: '=', + type: 'integer', + field: 'cod_curso', + table: 'curso_ens_superior' + }, + join: { + primary: ['ano_censo', 'cod_curso'], + foreign: ['ano_censo', 'cod_curso'], + foreignTable: 'curso_ens_superior' + } }).addValue({ name: 'university', table: 'curso_ens_superior', @@ -494,10 +674,34 @@ rqf.addField({ table: 'curso_ens_superior', field: 'ano_censo' } -}); +}) + +courseCountApp.get('/count_by_name', rqfMapfor.parse(), (req, res, next) => { + req.sql.from('localoferta_ens_superior') + .field('COUNT(DISTINCT localoferta_ens_superior.cod_curso)', 'total') + .field('localoferta_ens_superior.ano_censo', 'ano_censo') + .join ('curso_ens_superior ON (localoferta_ens_superior.cod_curso = curso_ens_superior.cod_curso) AND (localoferta_ens_superior.ano_censo = curso_ens_superior.ano_censo)') + .where('curso_ens_superior.cod_nivel_academico = 1') + .where('curso_ens_superior.tipo_atributo_ingresso <> 1 OR curso_ens_superior.tipo_atributo_ingresso is NULL') + .group('localoferta_ens_superior.ano_censo') + .order('localoferta_ens_superior.ano_censo') + + next(); +}, rqfMapfor.build(), (req, res, next) => { + console.log(req.sql.toString()); + next(); +}, query, (req, res, next) =>{ + if ('course' in req.dims){ + var total_course = req.result.reduce((total, cur) => {return total += cur.total}, 0) + for (var course of req.result){ + course.percentage = Number((( course.total / total_course ) * 100).toFixed(1)) + } + } + next(); +}, id2str.transform(), response('count_by_name')); courseCountApp.get('/', rqf.parse(), (req, res, next) => { - if ("localoffer" in req.dims) { + if ("localoffer" in req.dims || "campi" in req.dims) { if ("university" in req.dims || "universityLocalOffer" in req.dims) { req.sql.from('curso_ens_superior') .field('curso_ens_superior.ano_censo', 'year') @@ -521,16 +725,28 @@ courseCountApp.get('/', rqf.parse(), (req, res, next) => { .order('curso_ens_superior.ano_censo') .order('localoferta_ens_superior.cod_local_oferta'); } - } else if (("state" in req.dims) || ("city" in req.dims) || ("region" in req.dims) || - ("state" in req.filter) || ("city" in req.filter) || ("region" in req.filter)) { - req.sql.from('curso_ens_superior') - .field('COUNT(DISTINCT curso_ens_superior.cod_curso)', 'total') - .field("'Brasil'", 'name') - .field('curso_ens_superior.ano_censo', 'year') - .group('curso_ens_superior.ano_censo') - .order('curso_ens_superior.ano_censo') - .where('curso_ens_superior.tipo_atributo_ingresso <> 1 OR curso_ens_superior.tipo_atributo_ingresso is NULL') - .where('curso_ens_superior.cod_nivel_academico = 1'); + } else if (("state" in req.dims) || ("city" in req.dims) || ("microregion" in req.dims) || ("mesoregion" in req.dims) || ("region" in req.dims) || + ("state" in req.filter) || ("city" in req.filter) || ("microregion" in req.filter) || ("mesoregion" in req.filter) || ("region" in req.filter) ) { + if ("course" in req.dims){ + req.sql.from('curso_ens_superior') + .field('COUNT(*)', 'total') + .field("'Brasil'", 'name') + .field('curso_ens_superior.ano_censo', 'year') + .group('curso_ens_superior.ano_censo') + .order('curso_ens_superior.ano_censo') + .where('curso_ens_superior.cod_nivel_academico = 1') + } + else{ + req.sql.from('curso_ens_superior') + .field('COUNT(DISTINCT curso_ens_superior.cod_curso)', 'total') + .field("'Brasil'", 'name') + .field('curso_ens_superior.ano_censo', 'year') + .group('curso_ens_superior.ano_censo') + .order('curso_ens_superior.ano_censo') + .where('curso_ens_superior.tipo_atributo_ingresso <> 1 OR curso_ens_superior.tipo_atributo_ingresso is NULL') + .where('curso_ens_superior.cod_nivel_academico = 1'); + } + } else if ("university" in req.dims || "universityLocalOffer" in req.dims) { req.sql.from('curso_ens_superior') .field('COUNT(curso_ens_superior.cod_curso)', 'total') @@ -553,6 +769,17 @@ courseCountApp.get('/', rqf.parse(), (req, res, next) => { .where('curso_ens_superior.cod_nivel_academico = 1'); } next(); -}, rqf.build(), query, id2str.transform(), addMissing(rqf), response('course_count')); +}, rqf.build(), (req, res, next) => { + console.log(req.sql.toString()); + next(); +}, query, (req, res, next) =>{ + if ('course' in req.dims){ + var total_course = req.result.reduce((total, cur) => {return total += cur.total}, 0) + for (var course of req.result){ + course.percentage = Number((( course.total / total_course ) * 100).toFixed(2)) + } + } + next(); +}, id2str.transform(), addMissing(rqf), response('course_count')); module.exports = courseCountApp; diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index d1670f7c..8e68c5cc 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -363,6 +363,16 @@ rqf.addField({ type: 'integer', field: 'cod_local_oferta' } +}).addValue({ + name: 'campi', + table: 'localoferta_ens_superior_matricula', + tableField: ['cod_local_oferta', 'localoferta_nome'], + resultField: ['campi_id', 'campi_name'], + where: { + relation: '=', + type: 'integer', + field: 'cod_local_oferta' + } }).addValue({ name: 'university', table: '@', @@ -647,6 +657,22 @@ rqf.addField({ foreign: 'localoferta_cod_municipio', foreignTable: 'localoferta_ens_superior_matricula' } +}).addValue({ + name: 'course', + table: 'curso_ens_superior', + tableField: 'nome_curso', + resultField: 'course_name', + where:{ + relation: '=', + type: 'string', + table: 'curso_ens_superior', + field: 'nome_curso' + }, + join:{ + primary: ['ano_censo', 'cod_curso'], + foreign: ['ano_censo', 'cod_curso'], + foreignTable: 'localoferta_ens_superior_matricula' + } }); universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { @@ -698,6 +724,14 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .order('localoferta_ens_superior_matricula.ano_censo') } next(); -}, rqf.build(), query, id2str.transform(), addMissing(rqf), response('universityEnrollment')); +}, rqf.build(), query, id2str.transform(), addMissing(rqf), (req, res, next) => { + if ('course' in req.dims){ + var total_course = req.result.reduce((total, cur) => {return total += cur.total}, 0) + for (var course of req.result){ + course.percentage = Number((( course.total / total_course ) * 100).toFixed(2)) + } + } + next() +}, response('universityEnrollment')); module.exports = universityEnrollmentApp; -- GitLab From 75b512a83a7d1dc022593edec228c30935de95fa Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Thu, 9 Dec 2021 11:47:24 -0300 Subject: [PATCH 060/305] change concluinte labels --- src/libs/convert/finishUniversity.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/convert/finishUniversity.js b/src/libs/convert/finishUniversity.js index 389b8f20..55c6265a 100644 --- a/src/libs/convert/finishUniversity.js +++ b/src/libs/convert/finishUniversity.js @@ -21,9 +21,9 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function finishUniversity(id) { switch (id) { case 0: - return 'Não'; + return 'Não concluinte'; case 1: - return 'Sim'; + return 'Concluinte'; default: return 'Não declarado'; } -- GitLab From 57c65d704e2762e97d0936eba2f9b603272de7e4 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 10 Dec 2021 12:24:18 -0300 Subject: [PATCH 061/305] get response from id2str --- src/libs/routes/universityEnrollment.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 8e68c5cc..f12626f3 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -93,10 +93,13 @@ universityEnrollmentApp.get('/ocde_geral', (req, res, next) => { universityEnrollmentApp.get('/finish', (req, res, next) => { - req.result = [ - {id: 0, name: "Não"}, - {id: 1, name: "Sim"}, - ]; + req.result = [] + for (let i = 0; i <= 1; ++i){ + req.result.push({ + id: i, + name: id2str.finishUniversity(i) + }) + } next(); }, response('finish')); -- GitLab From a9965dbdd4a02e6fd0ba694cd8557eb1c1f491ce Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 10 Dec 2021 12:24:34 -0300 Subject: [PATCH 062/305] create message route --- src/libs/middlewares/email.js | 3 ++- src/libs/routes/api.js | 3 +++ src/libs/routes/message.js | 47 +++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/libs/routes/message.js diff --git a/src/libs/middlewares/email.js b/src/libs/middlewares/email.js index 7e0403d4..610826fc 100644 --- a/src/libs/middlewares/email.js +++ b/src/libs/middlewares/email.js @@ -23,7 +23,8 @@ transporter.verify(function(error, success) { }); const mailOptions = { - from: config.email.from + from: config.email.from, + to: config.email.from }; module.exports = function send(options, cb) { diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index c96266b0..31fc9257 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -128,6 +128,8 @@ const disciplines = require(`${libs}/routes/disciplines`); const universityLocalOffer = require(`${libs}/routes/universityLocalOffer`); +const message = require(`${libs}/routes/message`); + api.get('/', (req, res) => { res.json({ msg: 'SimCAQ API is running' }); }); @@ -183,4 +185,5 @@ api.use('/microregion', microregion); api.use('/location', location); api.use('/disciplines', disciplines); api.use('/universityLocalOffer', universityLocalOffer); +api.use('/message', message); module.exports = api; diff --git a/src/libs/routes/message.js b/src/libs/routes/message.js new file mode 100644 index 00000000..81292a39 --- /dev/null +++ b/src/libs/routes/message.js @@ -0,0 +1,47 @@ +/* +Copyright (C) 2021 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/>. +*/ + +const express = require('express'); + +const messageApp = express.Router(); + +const email = require(`../middlewares/email`); + +messageApp.post('/', (req, res, next) => { + var reqName = JSON.parse(req.body.name) + var reqEmail = JSON.parse(req.body.email) + var reqContents = JSON.parse(req.body.contents) + + let mailOptions = { + from: `"${reqName} <${reqEmail}>"`, + text: reqContents + } + + email(mailOptions, (err, info) => { + if(err) { + log.error(err); + res.json({msg: 'Undelivered Contact Mail'}); + } + log.info(`Message ${info.messageId} sent: ${info.response}`); + res.json({msg: 'Contact Mail Successfully Delivered'}); + }); +}) + +module.exports = messageApp; -- GitLab From 0229135d826825e07051d77a600d571370d71457 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Tue, 14 Dec 2021 10:02:54 -0300 Subject: [PATCH 063/305] Add missing mapfor filters --- src/libs/routes/courseCount.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/courseCount.js b/src/libs/routes/courseCount.js index 04beaad4..44d2487a 100644 --- a/src/libs/routes/courseCount.js +++ b/src/libs/routes/courseCount.js @@ -359,7 +359,37 @@ rqfMapfor.addField({ field: 'cod_local_oferta', table: 'localoferta_ens_superior' } -}, 'filter') +}, 'filter').addValue({ + name:'upper_adm_dependency', + table: 'curso_ens_superior', + tableField: 'par_categoria_administrativa', + resultField: 'upper_adm_dependency_id', + where: { + relation: '=', + type: 'integer', + field: 'par_categoria_administrativa' + } +}).addValue({ + name:'upper_education_mod', + table: 'curso_ens_superior', + tableField: 'cod_modalidade_ensino', + resultField: 'upper_education_mod_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_modalidade_ensino' + } +}).addValue({ + name:'academic_organization', + table: 'curso_ens_superior', + tableField: 'cod_organizacao_academica', + resultField: 'academic_organization_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_organizacao_academica' + } +}) rqf.addField({ @@ -679,7 +709,7 @@ rqf.addField({ courseCountApp.get('/count_by_name', rqfMapfor.parse(), (req, res, next) => { req.sql.from('localoferta_ens_superior') .field('COUNT(DISTINCT localoferta_ens_superior.cod_curso)', 'total') - .field('localoferta_ens_superior.ano_censo', 'ano_censo') + .field('localoferta_ens_superior.ano_censo', 'year') .join ('curso_ens_superior ON (localoferta_ens_superior.cod_curso = curso_ens_superior.cod_curso) AND (localoferta_ens_superior.ano_censo = curso_ens_superior.ano_censo)') .where('curso_ens_superior.cod_nivel_academico = 1') .where('curso_ens_superior.tipo_atributo_ingresso <> 1 OR curso_ens_superior.tipo_atributo_ingresso is NULL') -- GitLab From ca77da208e87b73b7a3b0fd04213546b4ad22138 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 17 Dec 2021 12:07:24 -0300 Subject: [PATCH 064/305] update message route --- src/libs/middlewares/email.js | 16 ++++++++++++---- src/libs/routes/message.js | 19 +++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/libs/middlewares/email.js b/src/libs/middlewares/email.js index 610826fc..e6f2af2a 100644 --- a/src/libs/middlewares/email.js +++ b/src/libs/middlewares/email.js @@ -4,11 +4,19 @@ const config = require(`${libs}/config`); const nodemailer = require('nodemailer'); const htmlToText = require('nodemailer-html-to-text').htmlToText; +// let transporter = nodemailer.createTransport({ +// host: config.email.host, +// port: config.email.port, +// secure: config.email.secure, +// ignoreTLS: config.email.ignoreTLS +// }); + let transporter = nodemailer.createTransport({ - host: config.email.host, - port: config.email.port, - secure: config.email.secure, - ignoreTLS: config.email.ignoreTLS + host: "smtp.inf.ufpr.br", + port: 587, + secure: false, + ignoreTLS: false, + tls: {rejectUnauthorized: false} }); transporter.use('compile', htmlToText()); diff --git a/src/libs/routes/message.js b/src/libs/routes/message.js index 81292a39..57eb350f 100644 --- a/src/libs/routes/message.js +++ b/src/libs/routes/message.js @@ -24,10 +24,15 @@ const messageApp = express.Router(); const email = require(`../middlewares/email`); +const log = require(`../log`)(module); + +messageApp.get('/', (req, res, next) => { + res.json({msg: 'This is the message route'}); +}) messageApp.post('/', (req, res, next) => { - var reqName = JSON.parse(req.body.name) - var reqEmail = JSON.parse(req.body.email) - var reqContents = JSON.parse(req.body.contents) + var reqName = req.body.name + var reqEmail = req.body.email + var reqContents = req.body.contents let mailOptions = { from: `"${reqName} <${reqEmail}>"`, @@ -37,10 +42,12 @@ messageApp.post('/', (req, res, next) => { email(mailOptions, (err, info) => { if(err) { log.error(err); - res.json({msg: 'Undelivered Contact Mail'}); + console.log(err) + res.status(500).json({msg: 'Undelivered Contact Mail'}); + } else { + log.info(`Message ${info.messageId} sent: ${info.response}`); + res.json({msg: 'Contact Mail Successfully Delivered'}); } - log.info(`Message ${info.messageId} sent: ${info.response}`); - res.json({msg: 'Contact Mail Successfully Delivered'}); }); }) -- GitLab From 12d548a3b8d465ef3f058093f58bbe388c206ae9 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Mon, 20 Dec 2021 11:34:09 -0300 Subject: [PATCH 065/305] add missing values --- src/libs/routes/teacher.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 88ec7a1e..9e5b9a56 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -516,6 +516,34 @@ teacherApp.get('/', rqf.parse(), (req, res, next) => { // } next(); -}, rqf.build(), query, addMissing(rqf), id2str.transform(), response('teacher')); +}, rqf.build(), query, addMissing(rqf), (req, res, next) => { + if (req.dims.pos_training){ + var year = req.result[0].year; + var posTrainingIds = req.result.map(obj => { + if (year == obj.year) + return obj.pos_training_id + }).filter(num => num !== undefined) + + var missingValues = []; + for(let i = 1; i <= 4; ++i) { + if ( !posTrainingIds.includes(i) ){ + missingValues.push(i); + } + } + + for (let curYear = 2012; curYear <= 2020; ++curYear){ + for (let ptId of missingValues){ + req.result.push({ + total:0, + name:"Brasil", + year:curYear, + pos_training_id:ptId, + pos_training_name:id2str.posTraining(ptId) + }) + } + } + } + next(); +}, id2str.transform(), response('teacher')); module.exports = teacherApp; -- GitLab From f6e251ef57b4e5ab0e204cb7a8f2992d354617a7 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Mon, 20 Dec 2021 12:18:56 -0300 Subject: [PATCH 066/305] sort results --- src/libs/routes/teacher.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 9e5b9a56..8ad5721d 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -497,6 +497,19 @@ rqf.addField({ } }); +const sortYearPtid = (a, b) => { + if (a.year < b.year) + return -1 + if (a.year > b.year) + return 1 + + if (a.pos_training_id < b.pos_training_id) + return -1 + if (a.pos_training_id > b.pos_training_id) + return 1 + return 0 +} + teacherApp.get('/', rqf.parse(), (req, res, next) => { req.sql.field('COUNT(DISTINCT docente.id_docente)', 'total') .field("'Brasil'", 'name') @@ -517,6 +530,8 @@ teacherApp.get('/', rqf.parse(), (req, res, next) => { next(); }, rqf.build(), query, addMissing(rqf), (req, res, next) => { + // Função criada para preencher valores faltantes no gráfico do indicador de + // formação em pós graduação do MapFOR. if (req.dims.pos_training){ var year = req.result[0].year; var posTrainingIds = req.result.map(obj => { @@ -542,6 +557,8 @@ teacherApp.get('/', rqf.parse(), (req, res, next) => { }) } } + req.result.sort(sortYearPtid) + } next(); }, id2str.transform(), response('teacher')); -- GitLab From d3e9473a7b77ee6689ea1a5d85272d571db20d0b Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Wed, 19 Jan 2022 09:33:35 -0300 Subject: [PATCH 067/305] Fix Email send --- config.json.example | 6 +++--- src/libs/middlewares/email.js | 18 +++++------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/config.json.example b/config.json.example index 2c3a982e..d372fe57 100644 --- a/config.json.example +++ b/config.json.example @@ -38,7 +38,7 @@ "host": "mx.c3sl.ufpr.br", "secure": false, "ignoreTLS": true, - "from": "\"Laboratório de Dados Educacionais\" <lde@c3sl.ufpr.br>" + "from": "\"Laboratório de Dados Educacionais\" <simcaq@c3sl.ufpr.br>" }, "security": { "tokenLife": 3600 @@ -84,7 +84,7 @@ "host": "mx.c3sl.ufpr.br", "secure": false, "ignoreTLS": true, - "from": "\"Laboratório de Dados Educacionais\" <lde@c3sl.ufpr.br>" + "from": "\"Laboratório de Dados Educacionais\" <simcaq@c3sl.ufpr.br>" }, "security": { "tokenLife": 3600 @@ -130,7 +130,7 @@ "host": "mx.c3sl.ufpr.br", "secure": false, "ignoreTLS": true, - "from": "\"Laboratório de Dados Educacionais\" <lde@c3sl.ufpr.br>" + "from": "\"Laboratório de Dados Educacionais\" <simcaq@c3sl.ufpr.br>" }, "security": { "tokenLife": 3600 diff --git a/src/libs/middlewares/email.js b/src/libs/middlewares/email.js index e6f2af2a..2065dacb 100644 --- a/src/libs/middlewares/email.js +++ b/src/libs/middlewares/email.js @@ -4,19 +4,11 @@ const config = require(`${libs}/config`); const nodemailer = require('nodemailer'); const htmlToText = require('nodemailer-html-to-text').htmlToText; -// let transporter = nodemailer.createTransport({ -// host: config.email.host, -// port: config.email.port, -// secure: config.email.secure, -// ignoreTLS: config.email.ignoreTLS -// }); - let transporter = nodemailer.createTransport({ - host: "smtp.inf.ufpr.br", - port: 587, - secure: false, - ignoreTLS: false, - tls: {rejectUnauthorized: false} + host: config.email.host, + port: config.email.port, + secure: config.email.secure, + ignoreTLS: config.email.ignoreTLS }); transporter.use('compile', htmlToText()); @@ -43,4 +35,4 @@ module.exports = function send(options, cb) { } cb(null, info); }); -}; \ No newline at end of file +}; -- GitLab From f17a1d85240d2bf3deb4e830b0f30d6957e7e17a Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Thu, 20 Jan 2022 11:37:17 -0300 Subject: [PATCH 068/305] add consult when value is null --- src/libs/middlewares/reqQueryFields.js | 44 ++++++++++++++++++++++++-- src/libs/routes/disciplines.js | 13 ++++---- src/libs/routes/teacher.js | 13 ++++---- 3 files changed, 55 insertions(+), 15 deletions(-) diff --git a/src/libs/middlewares/reqQueryFields.js b/src/libs/middlewares/reqQueryFields.js index 57bcff33..37a37777 100644 --- a/src/libs/middlewares/reqQueryFields.js +++ b/src/libs/middlewares/reqQueryFields.js @@ -2,8 +2,15 @@ const libs = `${process.cwd()}/libs`; const log = require(`${libs}/log`)(module); +const id2str = require(`${libs}/middlewares/id2str`); + const _ = require('lodash'); +const nullFields = [ + "Não classificado", + "Não classificada" +] + function parseWhereValue(type, value) { if(type === 'integer') return parseInt(value, 10); if(type === 'double') return parseFloat(value); @@ -24,6 +31,22 @@ function parseWhereValue(type, value) { } } +function getConvertName(whereField){ // TODO: mudar para regex + // Pega nome no formato "exemplo_de_nome" e transforma em "exemploDeNome" + for (var i = 1; i < whereField.length; ++i){ + if (whereField[i] == "_" && i < whereField.length-1) + whereField = whereField.slice(0,i) + whereField[i+1].toUpperCase() + whereField.slice(i+2, whereField.length); + } + return whereField; +} + +function isNull(curFilter, value){ + let convertName = getConvertName(curFilter) + if (id2str[convertName] !== undefined) + return nullFields.indexOf(id2str[convertName](value)) > -1 + return false; +} + class ReqQueryFields { constructor(fields = {}, fieldValues = {}) { // Exemplo de requisição: `/api/v1/enrollments?dims=state,region,location` @@ -302,8 +325,15 @@ class ReqQueryFields { let whereString = '('; let arrayWhereValues = []; for(let i = 0; i < whereValue.length; ++i) { - whereString += whereField + ' ' + value.where.relation + lower; - arrayWhereValues.push(parseWhereValue(value.where.type, whereValue[i])); + let curRelation = value.where.relation; + let curValue = parseWhereValue(value.where.type, whereValue[i]) + if (isNull(k, curValue) ) { + curValue = null; + curRelation = "is"; + } + + whereString += whereField + ' ' + curRelation + lower; + arrayWhereValues.push(curValue); if(i < whereValue.length-1) { whereString += ' OR '; } @@ -311,7 +341,15 @@ class ReqQueryFields { whereString += ')'; sql.where(whereString, ...arrayWhereValues); } else { - sql.where(whereField + ' ' + value.where.relation + lower, parseWhereValue(value.where.type, whereValue)); + let curValue = parseWhereValue(value.where.type, whereValue) + let curRelation = value.where.relation; + + if (isNull(k, curValue) ) { + curValue = null; + curRelation = "is"; + } + + sql.where(whereField + ' ' + curRelation + lower, curValue); } } } diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 9a6658e6..d43d8d31 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -162,12 +162,13 @@ disciplinesApp.get('/gender', (req, res, next) => { disciplinesApp.get('/contract_type', (req, res, next) => { - req.result = [ - { id: 1, name: 'Concursado/Efetivo/Estável' }, - { id: 2, name: 'Contrato temporário' }, - { id: 3, name: 'Contrato terceirizado' }, - { id: 4, name: 'Contrato CLT' } - ]; + req.result = []; + for(let i = 1; i <= 5; ++i) { + req.result.push({ + id: i, + name: id2str.contractType(i) + }); + } next(); }, response('contract_type')); diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 8ad5721d..51e5fea4 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -162,12 +162,13 @@ teacherApp.get('/gender', (req, res, next) => { teacherApp.get('/contract_type', (req, res, next) => { - req.result = [ - {id: 1, name: 'Concursado/Efetivo/Estável'}, - {id: 2, name: 'Contrato temporário'}, - {id: 3, name: 'Contrato terceirizado'}, - {id: 4, name: 'Contrato CLT'} - ]; + req.result = []; + for(let i = 1; i <= 5; ++i) { + req.result.push({ + id: i, + name: id2str.contractType(i) + }); + } next(); }, response('contract_type')); -- GitLab From 3bd4d4d872b788c31a5f2de10161d53f8de80eff Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Thu, 20 Jan 2022 11:56:03 -0300 Subject: [PATCH 069/305] change node version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 49d758a4..afe3c156 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:dubnium-stretch +FROM node:carbon-buster ENV HTTP_PROXY=http://httpproxy.c3sl.ufpr.br:3128/ -- GitLab From 6f219f7798bfed2dac16b0d19de54c53648107f0 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Tue, 25 Jan 2022 10:53:07 -0300 Subject: [PATCH 070/305] change e-mail --- config.json.example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.json.example b/config.json.example index d372fe57..20ed3f1c 100644 --- a/config.json.example +++ b/config.json.example @@ -38,7 +38,7 @@ "host": "mx.c3sl.ufpr.br", "secure": false, "ignoreTLS": true, - "from": "\"Laboratório de Dados Educacionais\" <simcaq@c3sl.ufpr.br>" + "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, "security": { "tokenLife": 3600 @@ -84,7 +84,7 @@ "host": "mx.c3sl.ufpr.br", "secure": false, "ignoreTLS": true, - "from": "\"Laboratório de Dados Educacionais\" <simcaq@c3sl.ufpr.br>" + "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, "security": { "tokenLife": 3600 @@ -130,7 +130,7 @@ "host": "mx.c3sl.ufpr.br", "secure": false, "ignoreTLS": true, - "from": "\"Laboratório de Dados Educacionais\" <simcaq@c3sl.ufpr.br>" + "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, "security": { "tokenLife": 3600 -- GitLab From 1e8d086b9c84e8f8dbf73ea213c384a1e31ffc98 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Wed, 2 Feb 2022 09:58:07 -0300 Subject: [PATCH 071/305] adapt teacher index to dim school --- src/libs/routes/classroomCount.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 249538dd..601b0234 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -548,8 +548,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { result.push(obj); currentClassroomObj = obj; - - while (req.teacher[ti].city_id !== classroom.city_id) { // match da tabela de professores. + var id_attribute = req.dims.school ? "school_id" : "city_id" + while (req.teacher[ti][id_attribute] !== classroom[id_attribute]) { // match da tabela de professores. ti++; } -- GitLab From f24218f19078bb6f8d14f0055a4949a19ae6967b Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 18 Feb 2022 10:51:03 -0300 Subject: [PATCH 072/305] create new route --- src/libs/routes/api.js | 4 + src/libs/routes/courseStudents.js | 192 ++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 src/libs/routes/courseStudents.js diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 31fc9257..6a1c2c33 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -130,6 +130,8 @@ const universityLocalOffer = require(`${libs}/routes/universityLocalOffer`); const message = require(`${libs}/routes/message`); +const courseStudents = require(`${libs}/routes/courseStudents`); + api.get('/', (req, res) => { res.json({ msg: 'SimCAQ API is running' }); }); @@ -186,4 +188,6 @@ api.use('/location', location); api.use('/disciplines', disciplines); api.use('/universityLocalOffer', universityLocalOffer); api.use('/message', message); +api.use('/courseStudents', courseStudents); + module.exports = api; diff --git a/src/libs/routes/courseStudents.js b/src/libs/routes/courseStudents.js new file mode 100644 index 00000000..82ca6ca7 --- /dev/null +++ b/src/libs/routes/courseStudents.js @@ -0,0 +1,192 @@ +const express = require('express'); + +const courseStudentsApp = express.Router(); + +const libs = `${process.cwd()}/libs`; + +const squel = require('squel'); + +const query = require(`${libs}/middlewares/query`).query; + +const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); + +const response = require(`${libs}/middlewares/response`); + +const id2str = require(`${libs}/middlewares/id2str`); + +let rqf = new ReqQueryFields(); + +rqf.addField({ + name: 'filter', + field: false, + where: true +}).addField({ + name: 'dims', + field: true, + where: false +}).addValueToField({ + name: 'state', + table: 'localoferta_ens_superior2', + tableField: 'cod_uf', + resultField: 'state_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_uf', + table: 'localoferta_ens_superior2' + } +}, 'filter').addValue({ + name: 'mesoregion', + table: 'municipio', + tableField: ['nome_mesorregiao', 'mesorregiao_id'], + resultField: ['mesoregion_name', 'mesoregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'mesorregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio', + foreignTable: 'localoferta_ens_superior2' + } +}).addValue({ + name: 'microregion', + table: 'municipio', + tableField: ['nome_microrregiao', 'microrregiao_id'], + resultField: ['microregion_name', 'microregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'microrregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio', + foreignTable: 'localoferta_ens_superior2' + } +}).addValue({ + name: 'city', + table: 'municipio', + tableField: ['id', 'nome'], + resultField: ['city_id', 'city_name'], + where: { + relation: '=', + type: 'integer', + field: 'id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio', + foreignTable: 'localoferta_ens_superior2' + } +}).addValue({ + name: 'min_year', + table: 'localoferta_ens_superior2', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '>=', + type: 'integer', + table: 'localoferta_ens_superior2', + field: 'ano_censo' + } +}).addValue({ + name: 'max_year', + table: 'localoferta_ens_superior2', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '<=', + type: 'integer', + table: 'localoferta_ens_superior2', + field: 'ano_censo' + } +}).addValue({ + name:'course', + table: 'curso_ens_superior', + tableField: 'nome_curso', + resultField: 'course_name', + where: { + relation: '=', + type: 'string', + field: 'nome_curso' + } +}).addValue({ + name:'upper_education_mod', + table: 'curso_ens_superior', + tableField: 'cod_modalidade_ensino', + resultField: 'upper_education_mod_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_modalidade_ensino' + } +}).addValue({ + name:'upper_adm_dependency', + table: 'curso_ens_superior', + tableField: 'par_categoria_administrativa', + resultField: 'upper_adm_dependency_id', + where: { + relation: '=', + type: 'integer', + field: 'par_categoria_administrativa' + } +}).addValue({ + name:'academic_organization', + table: 'curso_ens_superior', + tableField: 'cod_organizacao_academica', + resultField: 'academic_organization_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_organizacao_academica' + } +}).addValueToField({ + name: 'campi', + table: 'localoferta_ens_superior', + tableField: ['cod_local_oferta', 'nome'], + resultField: ['campi_id', 'campi_name'], + where: { + relation: '=', + type: 'integer', + field: 'cod_local_oferta', + table: 'localoferta_ens_superior' + } +}, 'filter') + +courseStudentsApp.get('/', rqf.parse(), (req, res, next) => { + var b = squel.select().from( + squel.select().from('localoferta_ens_superior') + .field("localoferta_ens_superior.cod_curso", "cod_curso") + .field("localoferta_ens_superior.ano_censo", "ano_censo") + .field("ies_ens_superior.cod_municipio_ies", "cod_municipio") + .field("ies_ens_superior.cod_uf_ies", "cod_uf") + .join("ies_ens_superior on ies_ens_superior.cod_ies = localoferta_ens_superior.cod_ies AND ies_ens_superior.ano_censo=localoferta_ens_superior.ano_censo") + .group("localoferta_ens_superior.cod_curso" ) + .group("localoferta_ens_superior.ano_censo" ) + .group("ies_ens_superior.cod_uf_ies") + .group("ies_ens_superior.cod_municipio_ies") + , "localoferta_ens_superior2") + .field("localoferta_ens_superior2.ano_censo", "year") + .field("SUM(curso_ens_superior.quantidade_inscritos_total)", "inscritos_total") + .field("SUM(curso_ens_superior.quantidade_vagas_totais)", "vagas_totais") + .field("SUM(curso_ens_superior.quantidade_ingresso_curso)", "ingresso_curso") + .join("curso_ens_superior ON (localoferta_ens_superior2.cod_curso = curso_ens_superior.cod_curso) AND (localoferta_ens_superior2.ano_censo = curso_ens_superior.ano_censo)") + .where("curso_ens_superior.cod_nivel_academico = 1") + .where("(curso_ens_superior.tipo_atributo_ingresso <> 1 OR curso_ens_superior.tipo_atributo_ingresso is NULL)") + .where("(curso_ens_superior.cod_grau_academico = 2 OR curso_ens_superior.cod_grau_academico = 4) ") + .group("localoferta_ens_superior2.ano_censo") + .order("localoferta_ens_superior2.ano_censo") + + req.sql = b; + next(); +}, rqf.build(), (req, res, next) => { + console.log(req.sql.toString()); + next(); +}, query, id2str.transform(), response('course_students')) + +module.exports = courseStudentsApp; -- GitLab From 43ecf86fe9e66b86fb909e34b2125bcc711c05d9 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 18 Feb 2022 10:56:06 -0300 Subject: [PATCH 073/305] only relation like adds '%' to value --- src/libs/middlewares/reqQueryFields.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libs/middlewares/reqQueryFields.js b/src/libs/middlewares/reqQueryFields.js index 37a37777..36c33d38 100644 --- a/src/libs/middlewares/reqQueryFields.js +++ b/src/libs/middlewares/reqQueryFields.js @@ -11,10 +11,11 @@ const nullFields = [ "Não classificada" ] -function parseWhereValue(type, value) { +function parseWhereValue(type, value, relation) { if(type === 'integer') return parseInt(value, 10); if(type === 'double') return parseFloat(value); - if(type === 'string') return '%'+value+'%'; + if(type === 'string' && relation === 'LIKE') return '%'+value+'%'; + if(type === 'string') return value; if(type === 'boolean') { if(value === null || typeof value === 'boolean') { return value; @@ -306,14 +307,14 @@ class ReqQueryFields { let whereString = '('; for(let i = 0; i < whereValue.length; ++i) { whereString += whereField; - whereValues.push(parseWhereValue(value.where.type, whereValue[i])); + whereValues.push(parseWhereValue(value.where.type, whereValue[i], value.where.relation)); if(i < whereValue.length-1) { whereString += ' OR '; } } whereString += ')'; } else { - whereValues.push(parseWhereValue(value.where.type, whereValue)); + whereValues.push(parseWhereValue(value.where.type, whereValue, value.where.relation)); } }); @@ -326,7 +327,7 @@ class ReqQueryFields { let arrayWhereValues = []; for(let i = 0; i < whereValue.length; ++i) { let curRelation = value.where.relation; - let curValue = parseWhereValue(value.where.type, whereValue[i]) + let curValue = parseWhereValue(value.where.type, whereValue[i],value.where.relation) if (isNull(k, curValue) ) { curValue = null; curRelation = "is"; @@ -341,7 +342,7 @@ class ReqQueryFields { whereString += ')'; sql.where(whereString, ...arrayWhereValues); } else { - let curValue = parseWhereValue(value.where.type, whereValue) + let curValue = parseWhereValue(value.where.type, whereValue, value.where.relation) let curRelation = value.where.relation; if (isNull(k, curValue) ) { -- GitLab From 649be1441a38d97130a9ef7ae53d6b13625a0824 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Mon, 21 Feb 2022 09:42:08 -0300 Subject: [PATCH 074/305] Hotfix route path --- src/libs/routes/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 6a1c2c33..7fa6818b 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -188,6 +188,6 @@ api.use('/location', location); api.use('/disciplines', disciplines); api.use('/universityLocalOffer', universityLocalOffer); api.use('/message', message); -api.use('/courseStudents', courseStudents); +api.use('/course_students', courseStudents); module.exports = api; -- GitLab From 45427dc57a258611ec1c7945b9b646efbd1ad977 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Mon, 21 Feb 2022 11:06:12 -0300 Subject: [PATCH 075/305] add total field --- src/libs/routes/courseStudents.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/courseStudents.js b/src/libs/routes/courseStudents.js index 82ca6ca7..4b1aab58 100644 --- a/src/libs/routes/courseStudents.js +++ b/src/libs/routes/courseStudents.js @@ -187,6 +187,12 @@ courseStudentsApp.get('/', rqf.parse(), (req, res, next) => { }, rqf.build(), (req, res, next) => { console.log(req.sql.toString()); next(); -}, query, id2str.transform(), response('course_students')) +}, query, (req, res, next) => { + for (var res of req.result){ + res.total = null; + } + + next(); +}, id2str.transform(), response('course_students')) module.exports = courseStudentsApp; -- GitLab From c19cfa18b5d2c37e05c5afa0800bd2c30c5fa32d Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 21 Feb 2022 11:42:44 -0300 Subject: [PATCH 076/305] add subroute for enrolledVacanciesFreshmen --- src/libs/convert/enrolledVacanciesFreshmen.js | 32 +++++++++++++++++++ src/libs/middlewares/id2str.js | 4 ++- src/libs/routes/courseStudents.js | 11 +++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/libs/convert/enrolledVacanciesFreshmen.js diff --git a/src/libs/convert/enrolledVacanciesFreshmen.js b/src/libs/convert/enrolledVacanciesFreshmen.js new file mode 100644 index 00000000..890445cd --- /dev/null +++ b/src/libs/convert/enrolledVacanciesFreshmen.js @@ -0,0 +1,32 @@ +/* +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 enrolledVacanciesFreshmen(id) { + switch (id) { + case 1: + return 'Ingresso'; + case 2: + return 'Vagas totais'; + case 3: + return 'Inscritos'; + default: + return 'Não definido'; + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index b86232ca..fe1bf68d 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -89,6 +89,7 @@ const finishUniversity = require(`${libs}/convert/finishUniversity`); 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 ids = { gender_id: gender, @@ -169,7 +170,8 @@ const ids = { finish_id: finishUniversity, initial_training_id: initialTraining, pos_training_id: posTraining, - licentiate_degree_id: licentiateDegree + licentiate_degree_id: licentiateDegree, + enrolled_vacancies_freshmen: enrolledVacanciesFreshmen }; function transform(removeId=false) { diff --git a/src/libs/routes/courseStudents.js b/src/libs/routes/courseStudents.js index 4b1aab58..decd65f9 100644 --- a/src/libs/routes/courseStudents.js +++ b/src/libs/routes/courseStudents.js @@ -16,6 +16,17 @@ const id2str = require(`${libs}/middlewares/id2str`); let rqf = new ReqQueryFields(); +courseStudentsApp.get('/enrolled_vacancies_freshmen', (req, res, next) => { + req.result = []; + for(let i = 1; i <= 3; ++i) { + req.result.push({ + id: i, + name: id2str.enrolledVacanciesFreshmen(i) + }); + }; + next(); +}, response('enrolled_vacancies_freshmen')); + rqf.addField({ name: 'filter', field: false, -- GitLab From 6a6351a411f73c559fcd6b19387912b91103a10f Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 21 Feb 2022 11:53:44 -0300 Subject: [PATCH 077/305] add item to id2str --- src/libs/middlewares/id2str.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index fe1bf68d..fa6a20ca 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -279,5 +279,6 @@ module.exports = { finishUniversity, initialTraining, posTraining, - licentiateDegree + licentiateDegree, + enrolledVacanciesFreshmen }; -- GitLab From c226133c92fe3ec532275794cf5711fef9b573c6 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Feb 2022 09:28:54 -0300 Subject: [PATCH 078/305] changed results to numbers --- src/libs/routes/courseStudents.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/routes/courseStudents.js b/src/libs/routes/courseStudents.js index decd65f9..b50f704a 100644 --- a/src/libs/routes/courseStudents.js +++ b/src/libs/routes/courseStudents.js @@ -200,6 +200,9 @@ courseStudentsApp.get('/', rqf.parse(), (req, res, next) => { next(); }, query, (req, res, next) => { for (var res of req.result){ + res.inscritos_total = Number(res.inscritos_total); + res.vagas_totais = Number(res.vagas_totais); + res.ingresso_curso = Number(res.ingresso_curso); res.total = null; } -- GitLab From 853a34ea1f7f7c124350ae2eb47a9e00d0d58d8f Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 3 Mar 2022 10:35:50 -0300 Subject: [PATCH 079/305] testing --- src/libs/routes/api.js | 3 + src/libs/routes/disciplines.js | 2 +- src/libs/routes/tests.js | 200 +++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 src/libs/routes/tests.js diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 7fa6818b..ff770318 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -132,6 +132,8 @@ const message = require(`${libs}/routes/message`); const courseStudents = require(`${libs}/routes/courseStudents`); +const tests = require(`${libs}/routes/tests`); + api.get('/', (req, res) => { res.json({ msg: 'SimCAQ API is running' }); }); @@ -189,5 +191,6 @@ api.use('/disciplines', disciplines); api.use('/universityLocalOffer', universityLocalOffer); api.use('/message', message); api.use('/course_students', courseStudents); +api.use('/tests', tests); module.exports = api; diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index d43d8d31..23bdcfa3 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -628,7 +628,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { // else { let disciplinesNotSuitable = []; let disciplinesSuitable = []; - + console.log(req.result); req.result.forEach((r) => { let objNotSuitable = { total: parseInt(r.total) - parseInt(r.total_suitable), diff --git a/src/libs/routes/tests.js b/src/libs/routes/tests.js new file mode 100644 index 00000000..132a640c --- /dev/null +++ b/src/libs/routes/tests.js @@ -0,0 +1,200 @@ +const express = require('express'); + +const courseStudentsApp = express.Router(); + +const libs = `${process.cwd()}/libs`; + +const squel = require('squel'); + +const query = require(`${libs}/middlewares/query`).query; + +const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); + +const response = require(`${libs}/middlewares/response`); + +const id2str = require(`${libs}/middlewares/id2str`); + +let rqf = new ReqQueryFields(); + +courseStudentsApp.get('/enrolled_vacancies_freshmen', (req, res, next) => { + req.result = []; + for(let i = 1; i <= 3; ++i) { + req.result.push({ + id: i, + name: id2str.enrolledVacanciesFreshmen(i) + }); + }; + next(); +}, response('enrolled_vacancies_freshmen')); + +rqf.addField({ + name: 'filter', + field: false, + where: true +}).addField({ + name: 'dims', + field: true, + where: false +}).addValueToField({ + name: 'state', + table: 'localoferta_ens_superior2', + tableField: 'cod_uf', + resultField: 'state_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_uf', + table: 'localoferta_ens_superior2' + } +}, 'filter').addValue({ + name: 'mesoregion', + table: 'municipio', + tableField: ['nome_mesorregiao', 'mesorregiao_id'], + resultField: ['mesoregion_name', 'mesoregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'mesorregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio', + foreignTable: 'localoferta_ens_superior2' + } +}).addValue({ + name: 'microregion', + table: 'municipio', + tableField: ['nome_microrregiao', 'microrregiao_id'], + resultField: ['microregion_name', 'microregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'microrregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio', + foreignTable: 'localoferta_ens_superior2' + } +}).addValue({ + name: 'city', + table: 'municipio', + tableField: ['id', 'nome'], + resultField: ['city_id', 'city_name'], + where: { + relation: '=', + type: 'integer', + field: 'id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio', + foreignTable: 'localoferta_ens_superior2' + } +}).addValue({ + name: 'min_year', + table: 'localoferta_ens_superior2', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '>=', + type: 'integer', + table: 'localoferta_ens_superior2', + field: 'ano_censo' + } +}).addValue({ + name: 'max_year', + table: 'localoferta_ens_superior2', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '<=', + type: 'integer', + table: 'localoferta_ens_superior2', + field: 'ano_censo' + } +}).addValue({ + name:'course', + table: 'curso_ens_superior', + tableField: 'nome_curso', + resultField: 'course_name', + where: { + relation: '=', + type: 'string', + field: 'nome_curso' + } +}).addValue({ + name:'upper_education_mod', + table: 'curso_ens_superior', + tableField: 'cod_modalidade_ensino', + resultField: 'upper_education_mod_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_modalidade_ensino' + } +}).addValue({ + name:'upper_adm_dependency', + table: 'curso_ens_superior', + tableField: 'par_categoria_administrativa', + resultField: 'upper_adm_dependency_id', + where: { + relation: '=', + type: 'integer', + field: 'par_categoria_administrativa' + } +}).addValue({ + name:'academic_organization', + table: 'curso_ens_superior', + tableField: 'cod_organizacao_academica', + resultField: 'academic_organization_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_organizacao_academica' + } +}).addValueToField({ + name: 'campi', + table: 'localoferta_ens_superior', + tableField: ['cod_local_oferta', 'nome'], + resultField: ['campi_id', 'campi_name'], + where: { + relation: '=', + type: 'integer', + field: 'cod_local_oferta', + table: 'localoferta_ens_superior' + } +}, 'filter') + +courseStudentsApp.get('/', rqf.parse(), (req, res, next) => { + req.sql.field("curso_ens_superior.ano_censo") + .field("SUM(curso_ens_superior.quantidade_inscritos_total)", "inscritos_total") + .field("SUM(curso_ens_superior.quantidade_vagas_totais)", "vagas_totais") + .field("SUM(curso_ens_superior.quantidade_ingresso_curso)", "ingresso_curso") + .from("curso_ens_superior") + .join("ies_ens_superior ON curso_ens_superior.ano_censo = ies_ens_superior.ano_censo AND curso_ens_superior.cod_ies = ies_ens_superior.cod_ies") + .where("curso_ens_superior.cod_nivel_academico = 1") + .where("curso_ens_superior.cod_grau_academico = 2 OR curso_ens_superior.cod_grau_academico = 4") + .where("ies_ens_superior.cod_uf_ies = 41") + .group("curso_ens_superior.ano_censo") + .order("curso_ens_superior.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.inscritos_total = Number(res.inscritos_total); + res.vagas_totais = Number(res.vagas_totais); + res.ingresso_curso = Number(res.ingresso_curso); + res.total = null; + } + + next(); +}, id2str.transform(), response('course_students')) + +module.exports = courseStudentsApp; -- GitLab From 9b643327eb146a5f66de39dea738e5a03752b9d3 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 3 Mar 2022 11:37:52 -0300 Subject: [PATCH 080/305] testing2 --- src/libs/routes/tests.js | 137 +++++++++++++-------------------------- 1 file changed, 45 insertions(+), 92 deletions(-) diff --git a/src/libs/routes/tests.js b/src/libs/routes/tests.js index 132a640c..639ed7c9 100644 --- a/src/libs/routes/tests.js +++ b/src/libs/routes/tests.js @@ -32,142 +32,96 @@ rqf.addField({ field: false, where: true }).addField({ - name: 'dims', + name: 'dim', field: true, where: false -}).addValueToField({ +}) +.addValueToField({ name: 'state', - table: 'localoferta_ens_superior2', + table: 'ies_ens_superior', tableField: 'cod_uf', resultField: 'state_id', where: { relation: '=', type: 'integer', field: 'cod_uf', - table: 'localoferta_ens_superior2' + table: 'ies_ens_superior' } -}, 'filter').addValue({ - name: 'mesoregion', - table: 'municipio', - tableField: ['nome_mesorregiao', 'mesorregiao_id'], - resultField: ['mesoregion_name', 'mesoregion_id'], - where: { - relation: '=', - type: 'integer', - field: 'mesorregiao_id', - table: 'municipio' - }, - join: { - primary: 'id', - foreign: 'cod_municipio', - foreignTable: 'localoferta_ens_superior2' - } -}).addValue({ - name: 'microregion', - table: 'municipio', - tableField: ['nome_microrregiao', 'microrregiao_id'], - resultField: ['microregion_name', 'microregion_id'], - where: { - relation: '=', - type: 'integer', - field: 'microrregiao_id', - table: 'municipio' - }, - join: { - primary: 'id', - foreign: 'cod_municipio', - foreignTable: 'localoferta_ens_superior2' - } -}).addValue({ - name: 'city', - table: 'municipio', - tableField: ['id', 'nome'], - resultField: ['city_id', 'city_name'], - where: { - relation: '=', - type: 'integer', - field: 'id', - table: 'municipio' - }, - join: { - primary: 'id', - foreign: 'cod_municipio', - foreignTable: 'localoferta_ens_superior2' - } -}).addValue({ +}, 'filter') +.addValueToField({ name: 'min_year', - table: 'localoferta_ens_superior2', + table: 'curso_ens_superior', tableField: 'ano_censo', resultField: 'year', where: { relation: '>=', type: 'integer', - table: 'localoferta_ens_superior2', - field: 'ano_censo' + field: 'ano_censo', + table: 'curso_ens_superior' } -}).addValue({ +}, 'filter') +.addValueToField({ name: 'max_year', - table: 'localoferta_ens_superior2', + table: 'curso_ens_superior', tableField: 'ano_censo', resultField: 'year', where: { relation: '<=', type: 'integer', - table: 'localoferta_ens_superior2', - field: 'ano_censo' + field: 'ano_censo', + table: 'ies_ens_superior' + } +}, 'filter') +.addValue({ + name: 'upper_adm_dependency', + table: 'curso_ens_superior', + tableField: 'par_categoria_administrativa', + resultField: 'upper_adm_dependency_id', + where: { + relation: '=', + type: 'integer', + field: 'par_categoria_administrativa', //cod_categoria_administrativa + table: 'curso_ens_superior' } -}).addValue({ - name:'course', +}) +.addValue({ + name: 'course', table: 'curso_ens_superior', tableField: 'nome_curso', resultField: 'course_name', where: { relation: '=', type: 'string', - field: 'nome_curso' + field: 'nome_curso', + table: 'curso_ens_superior' } -}).addValue({ - name:'upper_education_mod', +}) +.addValue({ + name: 'upper_education_mod', table: 'curso_ens_superior', tableField: 'cod_modalidade_ensino', resultField: 'upper_education_mod_id', where: { relation: '=', type: 'integer', - field: 'cod_modalidade_ensino' - } -}).addValue({ - name:'upper_adm_dependency', - table: 'curso_ens_superior', - tableField: 'par_categoria_administrativa', - resultField: 'upper_adm_dependency_id', - where: { - relation: '=', - type: 'integer', - field: 'par_categoria_administrativa' + field: 'cod_modalidade_ensino', + table: 'curso_ens_superior' } -}).addValue({ - name:'academic_organization', +}) +.addValue({ + name: 'academic_organization', table: 'curso_ens_superior', tableField: 'cod_organizacao_academica', resultField: 'academic_organization_id', where: { relation: '=', type: 'integer', - field: 'cod_organizacao_academica' + field: 'cod_organizacao_academica', + table: 'curso_ens_superior' } -}).addValueToField({ - name: 'campi', - table: 'localoferta_ens_superior', - tableField: ['cod_local_oferta', 'nome'], - resultField: ['campi_id', 'campi_name'], - where: { - relation: '=', - type: 'integer', - field: 'cod_local_oferta', - table: 'localoferta_ens_superior' - } -}, 'filter') +}) + + courseStudentsApp.get('/', rqf.parse(), (req, res, next) => { req.sql.field("curso_ens_superior.ano_censo") @@ -178,7 +132,6 @@ courseStudentsApp.get('/', rqf.parse(), (req, res, next) => { .join("ies_ens_superior ON curso_ens_superior.ano_censo = ies_ens_superior.ano_censo AND curso_ens_superior.cod_ies = ies_ens_superior.cod_ies") .where("curso_ens_superior.cod_nivel_academico = 1") .where("curso_ens_superior.cod_grau_academico = 2 OR curso_ens_superior.cod_grau_academico = 4") - .where("ies_ens_superior.cod_uf_ies = 41") .group("curso_ens_superior.ano_censo") .order("curso_ens_superior.ano_censo") next(); -- GitLab From fa01e30f11947e0a0806cfff4e3614c75c3a4764 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 3 Mar 2022 11:42:12 -0300 Subject: [PATCH 081/305] aaa --- src/libs/routes/tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/tests.js b/src/libs/routes/tests.js index 639ed7c9..edc4a227 100644 --- a/src/libs/routes/tests.js +++ b/src/libs/routes/tests.js @@ -39,12 +39,12 @@ rqf.addField({ .addValueToField({ name: 'state', table: 'ies_ens_superior', - tableField: 'cod_uf', + tableField: 'cod_uf_ies', resultField: 'state_id', where: { relation: '=', type: 'integer', - field: 'cod_uf', + field: 'cod_uf_ies', table: 'ies_ens_superior' } }, 'filter') -- GitLab From 0575682f369ba8276888edba9eedce501bfc342e Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Fri, 4 Mar 2022 08:37:36 -0300 Subject: [PATCH 082/305] updated the courseStudents route --- src/libs/routes/courseStudents.js | 175 ++++++++++-------------------- src/libs/routes/tests.js | 153 -------------------------- 2 files changed, 58 insertions(+), 270 deletions(-) delete mode 100644 src/libs/routes/tests.js diff --git a/src/libs/routes/courseStudents.js b/src/libs/routes/courseStudents.js index b50f704a..edc4a227 100644 --- a/src/libs/routes/courseStudents.js +++ b/src/libs/routes/courseStudents.js @@ -32,169 +32,110 @@ rqf.addField({ field: false, where: true }).addField({ - name: 'dims', + name: 'dim', field: true, where: false -}).addValueToField({ +}) +.addValueToField({ name: 'state', - table: 'localoferta_ens_superior2', - tableField: 'cod_uf', + table: 'ies_ens_superior', + tableField: 'cod_uf_ies', resultField: 'state_id', where: { relation: '=', type: 'integer', - field: 'cod_uf', - table: 'localoferta_ens_superior2' + field: 'cod_uf_ies', + table: 'ies_ens_superior' } -}, 'filter').addValue({ - name: 'mesoregion', - table: 'municipio', - tableField: ['nome_mesorregiao', 'mesorregiao_id'], - resultField: ['mesoregion_name', 'mesoregion_id'], - where: { - relation: '=', - type: 'integer', - field: 'mesorregiao_id', - table: 'municipio' - }, - join: { - primary: 'id', - foreign: 'cod_municipio', - foreignTable: 'localoferta_ens_superior2' - } -}).addValue({ - name: 'microregion', - table: 'municipio', - tableField: ['nome_microrregiao', 'microrregiao_id'], - resultField: ['microregion_name', 'microregion_id'], - where: { - relation: '=', - type: 'integer', - field: 'microrregiao_id', - table: 'municipio' - }, - join: { - primary: 'id', - foreign: 'cod_municipio', - foreignTable: 'localoferta_ens_superior2' - } -}).addValue({ - name: 'city', - table: 'municipio', - tableField: ['id', 'nome'], - resultField: ['city_id', 'city_name'], - where: { - relation: '=', - type: 'integer', - field: 'id', - table: 'municipio' - }, - join: { - primary: 'id', - foreign: 'cod_municipio', - foreignTable: 'localoferta_ens_superior2' - } -}).addValue({ +}, 'filter') +.addValueToField({ name: 'min_year', - table: 'localoferta_ens_superior2', + table: 'curso_ens_superior', tableField: 'ano_censo', resultField: 'year', where: { relation: '>=', type: 'integer', - table: 'localoferta_ens_superior2', - field: 'ano_censo' + field: 'ano_censo', + table: 'curso_ens_superior' } -}).addValue({ +}, 'filter') +.addValueToField({ name: 'max_year', - table: 'localoferta_ens_superior2', + table: 'curso_ens_superior', tableField: 'ano_censo', resultField: 'year', where: { relation: '<=', type: 'integer', - table: 'localoferta_ens_superior2', - field: 'ano_censo' + field: 'ano_censo', + table: 'ies_ens_superior' } -}).addValue({ - name:'course', +}, 'filter') +.addValue({ + name: 'upper_adm_dependency', + table: 'curso_ens_superior', + tableField: 'par_categoria_administrativa', + resultField: 'upper_adm_dependency_id', + where: { + relation: '=', + type: 'integer', + field: 'par_categoria_administrativa', //cod_categoria_administrativa + table: 'curso_ens_superior' + } +}) +.addValue({ + name: 'course', table: 'curso_ens_superior', tableField: 'nome_curso', resultField: 'course_name', where: { relation: '=', type: 'string', - field: 'nome_curso' + field: 'nome_curso', + table: 'curso_ens_superior' } -}).addValue({ - name:'upper_education_mod', +}) +.addValue({ + name: 'upper_education_mod', table: 'curso_ens_superior', tableField: 'cod_modalidade_ensino', resultField: 'upper_education_mod_id', where: { relation: '=', type: 'integer', - field: 'cod_modalidade_ensino' - } -}).addValue({ - name:'upper_adm_dependency', - table: 'curso_ens_superior', - tableField: 'par_categoria_administrativa', - resultField: 'upper_adm_dependency_id', - where: { - relation: '=', - type: 'integer', - field: 'par_categoria_administrativa' + field: 'cod_modalidade_ensino', + table: 'curso_ens_superior' } -}).addValue({ - name:'academic_organization', +}) +.addValue({ + name: 'academic_organization', table: 'curso_ens_superior', tableField: 'cod_organizacao_academica', resultField: 'academic_organization_id', where: { relation: '=', type: 'integer', - field: 'cod_organizacao_academica' - } -}).addValueToField({ - name: 'campi', - table: 'localoferta_ens_superior', - tableField: ['cod_local_oferta', 'nome'], - resultField: ['campi_id', 'campi_name'], - where: { - relation: '=', - type: 'integer', - field: 'cod_local_oferta', - table: 'localoferta_ens_superior' + field: 'cod_organizacao_academica', + table: 'curso_ens_superior' } -}, 'filter') +}) + + courseStudentsApp.get('/', rqf.parse(), (req, res, next) => { - var b = squel.select().from( - squel.select().from('localoferta_ens_superior') - .field("localoferta_ens_superior.cod_curso", "cod_curso") - .field("localoferta_ens_superior.ano_censo", "ano_censo") - .field("ies_ens_superior.cod_municipio_ies", "cod_municipio") - .field("ies_ens_superior.cod_uf_ies", "cod_uf") - .join("ies_ens_superior on ies_ens_superior.cod_ies = localoferta_ens_superior.cod_ies AND ies_ens_superior.ano_censo=localoferta_ens_superior.ano_censo") - .group("localoferta_ens_superior.cod_curso" ) - .group("localoferta_ens_superior.ano_censo" ) - .group("ies_ens_superior.cod_uf_ies") - .group("ies_ens_superior.cod_municipio_ies") - , "localoferta_ens_superior2") - .field("localoferta_ens_superior2.ano_censo", "year") - .field("SUM(curso_ens_superior.quantidade_inscritos_total)", "inscritos_total") - .field("SUM(curso_ens_superior.quantidade_vagas_totais)", "vagas_totais") - .field("SUM(curso_ens_superior.quantidade_ingresso_curso)", "ingresso_curso") - .join("curso_ens_superior ON (localoferta_ens_superior2.cod_curso = curso_ens_superior.cod_curso) AND (localoferta_ens_superior2.ano_censo = curso_ens_superior.ano_censo)") - .where("curso_ens_superior.cod_nivel_academico = 1") - .where("(curso_ens_superior.tipo_atributo_ingresso <> 1 OR curso_ens_superior.tipo_atributo_ingresso is NULL)") - .where("(curso_ens_superior.cod_grau_academico = 2 OR curso_ens_superior.cod_grau_academico = 4) ") - .group("localoferta_ens_superior2.ano_censo") - .order("localoferta_ens_superior2.ano_censo") - - req.sql = b; + req.sql.field("curso_ens_superior.ano_censo") + .field("SUM(curso_ens_superior.quantidade_inscritos_total)", "inscritos_total") + .field("SUM(curso_ens_superior.quantidade_vagas_totais)", "vagas_totais") + .field("SUM(curso_ens_superior.quantidade_ingresso_curso)", "ingresso_curso") + .from("curso_ens_superior") + .join("ies_ens_superior ON curso_ens_superior.ano_censo = ies_ens_superior.ano_censo AND curso_ens_superior.cod_ies = ies_ens_superior.cod_ies") + .where("curso_ens_superior.cod_nivel_academico = 1") + .where("curso_ens_superior.cod_grau_academico = 2 OR curso_ens_superior.cod_grau_academico = 4") + .group("curso_ens_superior.ano_censo") + .order("curso_ens_superior.ano_censo") next(); + }, rqf.build(), (req, res, next) => { console.log(req.sql.toString()); next(); diff --git a/src/libs/routes/tests.js b/src/libs/routes/tests.js deleted file mode 100644 index edc4a227..00000000 --- a/src/libs/routes/tests.js +++ /dev/null @@ -1,153 +0,0 @@ -const express = require('express'); - -const courseStudentsApp = express.Router(); - -const libs = `${process.cwd()}/libs`; - -const squel = require('squel'); - -const query = require(`${libs}/middlewares/query`).query; - -const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); - -const response = require(`${libs}/middlewares/response`); - -const id2str = require(`${libs}/middlewares/id2str`); - -let rqf = new ReqQueryFields(); - -courseStudentsApp.get('/enrolled_vacancies_freshmen', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 3; ++i) { - req.result.push({ - id: i, - name: id2str.enrolledVacanciesFreshmen(i) - }); - }; - next(); -}, response('enrolled_vacancies_freshmen')); - -rqf.addField({ - name: 'filter', - field: false, - where: true -}).addField({ - name: 'dim', - field: true, - where: false -}) -.addValueToField({ - name: 'state', - table: 'ies_ens_superior', - tableField: 'cod_uf_ies', - resultField: 'state_id', - where: { - relation: '=', - type: 'integer', - field: 'cod_uf_ies', - table: 'ies_ens_superior' - } -}, 'filter') -.addValueToField({ - name: 'min_year', - table: 'curso_ens_superior', - tableField: 'ano_censo', - resultField: 'year', - where: { - relation: '>=', - type: 'integer', - field: 'ano_censo', - table: 'curso_ens_superior' - } -}, 'filter') -.addValueToField({ - name: 'max_year', - table: 'curso_ens_superior', - tableField: 'ano_censo', - resultField: 'year', - where: { - relation: '<=', - type: 'integer', - field: 'ano_censo', - table: 'ies_ens_superior' - } -}, 'filter') -.addValue({ - name: 'upper_adm_dependency', - table: 'curso_ens_superior', - tableField: 'par_categoria_administrativa', - resultField: 'upper_adm_dependency_id', - where: { - relation: '=', - type: 'integer', - field: 'par_categoria_administrativa', //cod_categoria_administrativa - table: 'curso_ens_superior' - } -}) -.addValue({ - name: 'course', - table: 'curso_ens_superior', - tableField: 'nome_curso', - resultField: 'course_name', - where: { - relation: '=', - type: 'string', - field: 'nome_curso', - table: 'curso_ens_superior' - } -}) -.addValue({ - name: 'upper_education_mod', - table: 'curso_ens_superior', - tableField: 'cod_modalidade_ensino', - resultField: 'upper_education_mod_id', - where: { - relation: '=', - type: 'integer', - field: 'cod_modalidade_ensino', - table: 'curso_ens_superior' - } -}) -.addValue({ - name: 'academic_organization', - table: 'curso_ens_superior', - tableField: 'cod_organizacao_academica', - resultField: 'academic_organization_id', - where: { - relation: '=', - type: 'integer', - field: 'cod_organizacao_academica', - table: 'curso_ens_superior' - } -}) - - - -courseStudentsApp.get('/', rqf.parse(), (req, res, next) => { - req.sql.field("curso_ens_superior.ano_censo") - .field("SUM(curso_ens_superior.quantidade_inscritos_total)", "inscritos_total") - .field("SUM(curso_ens_superior.quantidade_vagas_totais)", "vagas_totais") - .field("SUM(curso_ens_superior.quantidade_ingresso_curso)", "ingresso_curso") - .from("curso_ens_superior") - .join("ies_ens_superior ON curso_ens_superior.ano_censo = ies_ens_superior.ano_censo AND curso_ens_superior.cod_ies = ies_ens_superior.cod_ies") - .where("curso_ens_superior.cod_nivel_academico = 1") - .where("curso_ens_superior.cod_grau_academico = 2 OR curso_ens_superior.cod_grau_academico = 4") - .group("curso_ens_superior.ano_censo") - .order("curso_ens_superior.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.inscritos_total = Number(res.inscritos_total); - res.vagas_totais = Number(res.vagas_totais); - res.ingresso_curso = Number(res.ingresso_curso); - res.total = null; - } - - next(); -}, id2str.transform(), response('course_students')) - -module.exports = courseStudentsApp; -- GitLab From 1d0aef8101cc770ca6d70d1139bd7c4deff264f6 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 10 Mar 2022 09:01:15 -0300 Subject: [PATCH 083/305] add period_not filter in enrollment --- src/libs/routes/enrollment.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index b3310b30..c3a1e68d 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -588,6 +588,16 @@ rqf.addField({ type: 'boolean', field: 'exclusiva_especial' } +}).addValue({ + name: 'period_not', + table: 'matricula', + tableField: 'turma_turno_id', + resultField: 'period_id', + where: { + relation: '<>', + type: 'integer', + field: 'turma_turno_id' + } }); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { -- GitLab From 9e11a7dfe40e194c53460a8b2906ea99862a96ac Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 10 Mar 2022 09:06:43 -0300 Subject: [PATCH 084/305] removed tests route on api.js --- src/libs/routes/api.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index ff770318..7fa6818b 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -132,8 +132,6 @@ const message = require(`${libs}/routes/message`); const courseStudents = require(`${libs}/routes/courseStudents`); -const tests = require(`${libs}/routes/tests`); - api.get('/', (req, res) => { res.json({ msg: 'SimCAQ API is running' }); }); @@ -191,6 +189,5 @@ api.use('/disciplines', disciplines); api.use('/universityLocalOffer', universityLocalOffer); api.use('/message', message); api.use('/course_students', courseStudents); -api.use('/tests', tests); module.exports = api; -- GitLab From 3222e5134b235d8f19a5efbbacfd5c115c3a4879 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 11 Mar 2022 09:47:14 -0300 Subject: [PATCH 085/305] Hotfix dim to dims --- src/libs/routes/courseStudents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/courseStudents.js b/src/libs/routes/courseStudents.js index edc4a227..19349f2f 100644 --- a/src/libs/routes/courseStudents.js +++ b/src/libs/routes/courseStudents.js @@ -32,7 +32,7 @@ rqf.addField({ field: false, where: true }).addField({ - name: 'dim', + name: 'dims', field: true, where: false }) -- GitLab From c10a03ff7bf12b274ca517abceb4f17ef4c45c71 Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 11 Mar 2022 10:14:16 -0300 Subject: [PATCH 086/305] add filters --- src/libs/routes/courseStudents.js | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/libs/routes/courseStudents.js b/src/libs/routes/courseStudents.js index edc4a227..f3c67678 100644 --- a/src/libs/routes/courseStudents.js +++ b/src/libs/routes/courseStudents.js @@ -120,6 +120,57 @@ rqf.addField({ table: 'curso_ens_superior' } }) +.addValue({ + name: 'mesoregion', + table: 'municipio', + tableField: ['nome_mesorregiao', 'mesorregiao_id'], + resultField: ['mesoregion_name', 'mesoregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'mesorregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio_ies', + foreignTable: 'ies_ens_superior' + } +}) +.addValue({ + name: 'microregion', + table: 'municipio', + tableField: ['nome_microrregiao', 'microrregiao_id'], + resultField: ['microregion_name', 'microregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'microrregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio_ies', + foreignTable: 'ies_ens_superior' + } +}) +.addValue({ + name: 'city', + table: 'municipio', + tableField: ['id', 'nome'], + resultField: ['city_id', 'city_name'], + where: { + relation: '=', + type: 'integer', + field: 'id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio_ies', + foreignTable: 'ies_ens_superior' + } +}) -- GitLab From f92086ecc9f881b7f382957f437cff345421e91a Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 11 Mar 2022 10:25:27 -0300 Subject: [PATCH 087/305] add city filters to courseStudents --- src/libs/routes/courseStudents.js | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/libs/routes/courseStudents.js b/src/libs/routes/courseStudents.js index 19349f2f..afe2cfdf 100644 --- a/src/libs/routes/courseStudents.js +++ b/src/libs/routes/courseStudents.js @@ -120,6 +120,57 @@ rqf.addField({ table: 'curso_ens_superior' } }) +.addValue({ + name: 'mesoregion', + table: 'municipio', + tableField: ['nome_mesorregiao', 'mesorregiao_id'], + resultField: ['mesoregion_name', 'mesoregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'mesorregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio_ies', + foreignTable: 'ies_ens_superior' + } +}) +.addValue({ + name: 'microregion', + table: 'municipio', + tableField: ['nome_microrregiao', 'microrregiao_id'], + resultField: ['microregion_name', 'microregion_id'], + where: { + relation: '=', + type: 'integer', + field: 'microrregiao_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio_ies', + foreignTable: 'ies_ens_superior' + } +}) +.addValue({ + name: 'city', + table: 'municipio', + tableField: ['id', 'nome'], + resultField: ['city_id', 'city_name'], + where: { + relation: '=', + type: 'integer', + field: 'id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'cod_municipio_ies', + foreignTable: 'ies_ens_superior' + } +}) -- GitLab From d5a7ff9a82e25958ef6fadd03110430462321d7f Mon Sep 17 00:00:00 2001 From: ppc19 <ppc19@inf.ufpr.br> Date: Fri, 11 Mar 2022 11:17:22 -0300 Subject: [PATCH 088/305] hotfix year --- src/libs/routes/courseStudents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/courseStudents.js b/src/libs/routes/courseStudents.js index afe2cfdf..cd0aea1b 100644 --- a/src/libs/routes/courseStudents.js +++ b/src/libs/routes/courseStudents.js @@ -175,7 +175,7 @@ rqf.addField({ courseStudentsApp.get('/', rqf.parse(), (req, res, next) => { - req.sql.field("curso_ens_superior.ano_censo") + req.sql.field("curso_ens_superior.ano_censo", "year") .field("SUM(curso_ens_superior.quantidade_inscritos_total)", "inscritos_total") .field("SUM(curso_ens_superior.quantidade_vagas_totais)", "vagas_totais") .field("SUM(curso_ens_superior.quantidade_ingresso_curso)", "ingresso_curso") -- GitLab From e9d423efb33391fcd0da091c631750e52aa34c01 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 09:32:01 -0300 Subject: [PATCH 089/305] added route to enter_situation --- src/libs/routes/universityEnrollment.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index f12626f3..15ce729d 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -736,5 +736,9 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { } next() }, response('universityEnrollment')); +universityEnrollmentApp.get('/enter_situation ', rqf.parse(), (req, res, next) => { + + next() +}, rqf.build(), query, id2str.transform(), response('universityEnrollment')); module.exports = universityEnrollmentApp; -- GitLab From e834d9f877b31557d9dc48274523ccac45e697dc Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 09:41:35 -0300 Subject: [PATCH 090/305] added route to enter_situation --- src/libs/routes/universityEnrollment.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 15ce729d..c9c045af 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -736,9 +736,18 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { } next() }, response('universityEnrollment')); -universityEnrollmentApp.get('/enter_situation ', rqf.parse(), (req, res, next) => { - +universityEnrollmentApp.get('/enter_situation ', rqf.parse(), (req, res, next) => { + req.sql.from('localoferta_ens_superior_matricula2') + .field('SUM(CASE WHEN cod_aluno_situacao=2 THEN 1 ELSE 0 END)', 'cursando') + .field('SUM(CASE WHEN cod_aluno_situacao=6 THEN 1 ELSE 0 END)', 'concluinte') + .field('SUM(CASE WHEN cod_aluno_situacao=4 OR cod_aluno_situacao=5 OR cod_aluno_situacao=7 THEN 1 ELSE 0 END)', 'evadido') + .field('SUM(CASE WHEN cod_aluno_situacao=3 THEN 1 ELSE 0 END)', 'trancado') + .field('COUNT(*)', 'total') + .where('ano_censo=2018') + .where('cod_nivel_academico=1') + .where('cod_grau_academico=2 OR cod_grau_academico=4') + .where('localoferta_cod_uf=41') next() }, rqf.build(), query, id2str.transform(), response('universityEnrollment')); module.exports = universityEnrollmentApp; -- GitLab From 29de6b069651b7b74851655c66e3862d1e10cace Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 10:07:28 -0300 Subject: [PATCH 091/305] switched results to numbers --- src/libs/routes/universityEnrollment.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index c9c045af..69509042 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -739,15 +739,23 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { universityEnrollmentApp.get('/enter_situation ', rqf.parse(), (req, res, next) => { req.sql.from('localoferta_ens_superior_matricula2') - .field('SUM(CASE WHEN cod_aluno_situacao=2 THEN 1 ELSE 0 END)', 'cursando') - .field('SUM(CASE WHEN cod_aluno_situacao=6 THEN 1 ELSE 0 END)', 'concluinte') - .field('SUM(CASE WHEN cod_aluno_situacao=4 OR cod_aluno_situacao=5 OR cod_aluno_situacao=7 THEN 1 ELSE 0 END)', 'evadido') - .field('SUM(CASE WHEN cod_aluno_situacao=3 THEN 1 ELSE 0 END)', 'trancado') + .field('SUM(CASE WHEN cod_aluno_situacao=2 AND ingressante=1 THEN 1 ELSE 0 END)', 'cursando') + .field('SUM(CASE WHEN cod_aluno_situacao=6 AND ingressante=1THEN 1 ELSE 0 END)', 'concluinte') + .field('SUM(CASE WHEN (cod_aluno_situacao=4 OR cod_aluno_situacao=5 OR cod_aluno_situacao=7) AND ingressante=1 THEN 1 ELSE 0 END)', 'evadido') + .field('SUM(CASE WHEN cod_aluno_situacao=3 AND ingressante=1 THEN 1 ELSE 0 END)', 'trancado') .field('COUNT(*)', 'total') .where('ano_censo=2018') .where('cod_nivel_academico=1') .where('cod_grau_academico=2 OR cod_grau_academico=4') .where('localoferta_cod_uf=41') next() -}, rqf.build(), query, id2str.transform(), response('universityEnrollment')); +}, rqf.build(), 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); + } + + next(); +}, id2str.transform(), response('enterSituation')); module.exports = universityEnrollmentApp; -- GitLab From 376480329f26b4ecf41f6de755eac59ccabb8b18 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 10:08:57 -0300 Subject: [PATCH 092/305] switched results to numbers and fixed a bug --- src/libs/routes/universityEnrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 69509042..707dbea5 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -737,7 +737,7 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { next() }, response('universityEnrollment')); -universityEnrollmentApp.get('/enter_situation ', rqf.parse(), (req, res, next) => { +universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => { req.sql.from('localoferta_ens_superior_matricula2') .field('SUM(CASE WHEN cod_aluno_situacao=2 AND ingressante=1 THEN 1 ELSE 0 END)', 'cursando') .field('SUM(CASE WHEN cod_aluno_situacao=6 AND ingressante=1THEN 1 ELSE 0 END)', 'concluinte') -- GitLab From ade9839b4b0db2d5cb1c34a8ecb9f26266fa41d1 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 10:12:20 -0300 Subject: [PATCH 093/305] added number conversion to 'trancado' indicator --- src/libs/routes/universityEnrollment.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 707dbea5..15f695f9 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -754,6 +754,7 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => res.cursando = Number(res.cursando); res.concluinte = Number(res.concluinte); res.evadido = Number(res.evadido); + res.trancado = Number(res.trancado); } next(); -- GitLab From 76ae97e654c21e842a20108d81d00cbdeabc7870 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 10:33:57 -0300 Subject: [PATCH 094/305] adding year order --- src/libs/routes/universityEnrollment.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 15f695f9..943d0622 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -739,15 +739,18 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => { req.sql.from('localoferta_ens_superior_matricula2') - .field('SUM(CASE WHEN cod_aluno_situacao=2 AND ingressante=1 THEN 1 ELSE 0 END)', 'cursando') - .field('SUM(CASE WHEN cod_aluno_situacao=6 AND ingressante=1THEN 1 ELSE 0 END)', 'concluinte') - .field('SUM(CASE WHEN (cod_aluno_situacao=4 OR cod_aluno_situacao=5 OR cod_aluno_situacao=7) AND ingressante=1 THEN 1 ELSE 0 END)', 'evadido') - .field('SUM(CASE WHEN cod_aluno_situacao=3 AND ingressante=1 THEN 1 ELSE 0 END)', 'trancado') + .field('SUM(CASE WHEN localoferta_ens_superior_matricula2.cod_aluno_situacao=2 AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'cursando') + .field('SUM(CASE WHEN localoferta_ens_superior_matricula2.cod_aluno_situacao=6 AND localoferta_ens_superior_matricula2.ingressante=1THEN 1 ELSE 0 END)', 'concluinte') + .field('SUM(CASE WHEN (localoferta_ens_superior_matricula2.cod_aluno_situacao=4 OR localoferta_ens_superior_matricula2.cod_aluno_situacao=5 OR localoferta_ens_superior_matricula2.cod_aluno_situacao=7) AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'evadido') + .field('SUM(CASE WHEN localoferta_ens_superior_matricula2.cod_aluno_situacao=3 AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'trancado') .field('COUNT(*)', 'total') - .where('ano_censo=2018') - .where('cod_nivel_academico=1') - .where('cod_grau_academico=2 OR cod_grau_academico=4') - .where('localoferta_cod_uf=41') + .field('localoferta_ens_superior_matricula2.ano_censo') + .where('localoferta_ens_superior_matricula2.ano_censo=2018') + .where('localoferta_ens_superior_matricula2.cod_nivel_academico=1') + .where('localoferta_ens_superior_matricula2.cod_grau_academico=2 OR localoferta_ens_superior_matricula2.od_grau_academico=4') + .where('localoferta_ens_superior_matricula2.localoferta_cod_uf=41') + .group('localoferta_ens_superior_matricula2.ano_censo') + .order('localoferta_ens_superior_matricula2.ano_censo') next() }, rqf.build(), query, (req, res, next) => { for (var res of req.result){ -- GitLab From cf727c39799cf6cbcc718838cc2b303f149c4e86 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 10:58:29 -0300 Subject: [PATCH 095/305] adding year order --- src/libs/routes/universityEnrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 943d0622..21f6ec34 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -740,7 +740,7 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => { req.sql.from('localoferta_ens_superior_matricula2') .field('SUM(CASE WHEN localoferta_ens_superior_matricula2.cod_aluno_situacao=2 AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'cursando') - .field('SUM(CASE WHEN localoferta_ens_superior_matricula2.cod_aluno_situacao=6 AND localoferta_ens_superior_matricula2.ingressante=1THEN 1 ELSE 0 END)', 'concluinte') + .field('SUM(CASE WHEN localoferta_ens_superior_matricula2.cod_aluno_situacao=6 AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'concluinte') .field('SUM(CASE WHEN (localoferta_ens_superior_matricula2.cod_aluno_situacao=4 OR localoferta_ens_superior_matricula2.cod_aluno_situacao=5 OR localoferta_ens_superior_matricula2.cod_aluno_situacao=7) AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'evadido') .field('SUM(CASE WHEN localoferta_ens_superior_matricula2.cod_aluno_situacao=3 AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'trancado') .field('COUNT(*)', 'total') -- GitLab From 11029533b09fd2bf2fdb3db5cec89570a8b24f13 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 10:59:07 -0300 Subject: [PATCH 096/305] adding year order --- src/libs/routes/universityEnrollment.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 21f6ec34..913b6e66 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -745,10 +745,8 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => .field('SUM(CASE WHEN localoferta_ens_superior_matricula2.cod_aluno_situacao=3 AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'trancado') .field('COUNT(*)', 'total') .field('localoferta_ens_superior_matricula2.ano_censo') - .where('localoferta_ens_superior_matricula2.ano_censo=2018') .where('localoferta_ens_superior_matricula2.cod_nivel_academico=1') .where('localoferta_ens_superior_matricula2.cod_grau_academico=2 OR localoferta_ens_superior_matricula2.od_grau_academico=4') - .where('localoferta_ens_superior_matricula2.localoferta_cod_uf=41') .group('localoferta_ens_superior_matricula2.ano_censo') .order('localoferta_ens_superior_matricula2.ano_censo') next() -- GitLab From 9d4d0da1c9f2515aa8d9c286ecd6c83f6306b8bd Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 11:04:07 -0300 Subject: [PATCH 097/305] adding console logs to test --- src/libs/routes/universityEnrollment.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 913b6e66..7cf18474 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -750,14 +750,13 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => .group('localoferta_ens_superior_matricula2.ano_censo') .order('localoferta_ens_superior_matricula2.ano_censo') next() -}, rqf.build(), query, (req, res, 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; -- GitLab From 77ab838b0a411666353785638fc5de8fa323b2cb Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 11:08:27 -0300 Subject: [PATCH 098/305] definitive edition --- src/libs/routes/universityEnrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 7cf18474..4819a6e8 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -746,7 +746,7 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => .field('COUNT(*)', 'total') .field('localoferta_ens_superior_matricula2.ano_censo') .where('localoferta_ens_superior_matricula2.cod_nivel_academico=1') - .where('localoferta_ens_superior_matricula2.cod_grau_academico=2 OR localoferta_ens_superior_matricula2.od_grau_academico=4') + .where('localoferta_ens_superior_matricula2.cod_grau_academico=2 OR localoferta_ens_superior_matricula2.cod_grau_academico=4') .group('localoferta_ens_superior_matricula2.ano_censo') .order('localoferta_ens_superior_matricula2.ano_censo') next() -- GitLab From ad2d5cba40934c83ce609961398cfff513c30363 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 11:14:13 -0300 Subject: [PATCH 099/305] fixing filters --- src/libs/routes/universityEnrollment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 4819a6e8..b4747a62 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -333,12 +333,12 @@ rqf.addField({ relation: '=', type: 'integer', field: 'localoferta_cod_uf', - table: 'localoferta_ens_superior_matricula' + table: 'localoferta_ens_superior_matricula2' }, join: { primary: 'id', foreign: 'localoferta_cod_uf', - foreignTable: 'localoferta_ens_superior_matricula' + foreignTable: 'localoferta_ens_superior_matricula2' } }).addValue({ name: 'region', -- GitLab From c31d96c717751a44b670fc8b09e2f8d6b3caca8e Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 22 Mar 2022 11:19:49 -0300 Subject: [PATCH 100/305] changing the consult table --- src/libs/routes/universityEnrollment.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index b4747a62..bc51ee85 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -333,12 +333,12 @@ rqf.addField({ relation: '=', type: 'integer', field: 'localoferta_cod_uf', - table: 'localoferta_ens_superior_matricula2' + table: 'localoferta_ens_superior_matricula' }, join: { primary: 'id', foreign: 'localoferta_cod_uf', - foreignTable: 'localoferta_ens_superior_matricula2' + foreignTable: 'localoferta_ens_superior_matricula' } }).addValue({ name: 'region', @@ -738,17 +738,17 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { }, response('universityEnrollment')); universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => { - req.sql.from('localoferta_ens_superior_matricula2') - .field('SUM(CASE WHEN localoferta_ens_superior_matricula2.cod_aluno_situacao=2 AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'cursando') - .field('SUM(CASE WHEN localoferta_ens_superior_matricula2.cod_aluno_situacao=6 AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'concluinte') - .field('SUM(CASE WHEN (localoferta_ens_superior_matricula2.cod_aluno_situacao=4 OR localoferta_ens_superior_matricula2.cod_aluno_situacao=5 OR localoferta_ens_superior_matricula2.cod_aluno_situacao=7) AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'evadido') - .field('SUM(CASE WHEN localoferta_ens_superior_matricula2.cod_aluno_situacao=3 AND localoferta_ens_superior_matricula2.ingressante=1 THEN 1 ELSE 0 END)', 'trancado') + 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('localoferta_ens_superior_matricula2.ano_censo') - .where('localoferta_ens_superior_matricula2.cod_nivel_academico=1') - .where('localoferta_ens_superior_matricula2.cod_grau_academico=2 OR localoferta_ens_superior_matricula2.cod_grau_academico=4') - .group('localoferta_ens_superior_matricula2.ano_censo') - .order('localoferta_ens_superior_matricula2.ano_censo') + .field('localoferta_ens_superior_matricula.ano_censo') + .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){ -- GitLab From 20d265cf77ca5955072572f11b3dea9104475b48 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Wed, 23 Mar 2022 09:32:20 -0300 Subject: [PATCH 101/305] added enrollment_situation sub-route on universityEnrollment route --- src/libs/routes/universityEnrollment.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index bc51ee85..fb3e2e1f 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -760,3 +760,23 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => 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') + .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); + } + next(); +}, id2str.transform(), response('enrollmentSituation')); \ No newline at end of file -- GitLab From b61446e09e3789d2fce40745b9cfe061ad66ec73 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Wed, 23 Mar 2022 09:36:15 -0300 Subject: [PATCH 102/305] switched 'total' result to integer --- src/libs/routes/universityEnrollment.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index fb3e2e1f..eaea3215 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -777,6 +777,7 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex 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')); \ No newline at end of file -- GitLab From 133d65d6a2e377869da72f6ccbebc8c55054f91b Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Wed, 23 Mar 2022 11:19:42 -0300 Subject: [PATCH 103/305] changing names of result --- src/libs/routes/universityEnrollment.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 5adec697..29a1d0f3 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -684,8 +684,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('localoferta_ens_superior_matricula') .field('curso_ens_superior.ano_censo', 'year') .field('COUNT(localoferta_ens_superior.cod_local_oferta)', 'total') - .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') - .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior.cod_local_oferta'); @@ -695,8 +693,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('COUNT(*)', 'total') .field('localoferta_ens_superior_matricula.cod_ies', 'university_id') .field('localoferta_ens_superior_matricula.nome_ies', 'university_name') - .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') - .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .group('localoferta_ens_superior_matricula.cod_ies') .group('localoferta_ens_superior_matricula.nome_ies') @@ -709,8 +705,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('DISTINCT COUNT(*)', 'total') .field("'Brasil'", 'name') .field('localoferta_ens_superior_matricula.ano_censo', 'year') - .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') - .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') } else if ("university" in req.dims || "universityLocalOffer" in req.dims) { @@ -729,8 +723,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('COUNT(*)', 'total') .field("'Brasil'", 'name') .field('localoferta_ens_superior_matricula.ano_censo', 'year') - .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') - .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') } @@ -752,7 +744,8 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => .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('localoferta_ens_superior_matricula.ano_censo') + .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') @@ -774,7 +767,8 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex .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') + .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') @@ -788,4 +782,5 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex res.total = Number(res.total); } next(); -}, id2str.transform(), response('enrollmentSituation')); \ No newline at end of file +}, id2str.transform(), response('enrollmentSituation')); + -- GitLab From ac780e088161a59e56d4930ec58238e63e84ba0c Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 23 Mar 2022 11:24:24 -0300 Subject: [PATCH 104/305] add filters to old route --- src/libs/routes/universityEnrollment.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index eaea3215..5adec697 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -684,6 +684,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('localoferta_ens_superior_matricula') .field('curso_ens_superior.ano_censo', 'year') .field('COUNT(localoferta_ens_superior.cod_local_oferta)', 'total') + .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') + .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior.cod_local_oferta'); @@ -693,6 +695,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('COUNT(*)', 'total') .field('localoferta_ens_superior_matricula.cod_ies', 'university_id') .field('localoferta_ens_superior_matricula.nome_ies', 'university_name') + .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') + .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .group('localoferta_ens_superior_matricula.cod_ies') .group('localoferta_ens_superior_matricula.nome_ies') @@ -705,6 +709,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('DISTINCT COUNT(*)', 'total') .field("'Brasil'", 'name') .field('localoferta_ens_superior_matricula.ano_censo', 'year') + .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') + .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') } else if ("university" in req.dims || "universityLocalOffer" in req.dims) { @@ -723,6 +729,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('COUNT(*)', 'total') .field("'Brasil'", 'name') .field('localoferta_ens_superior_matricula.ano_censo', 'year') + .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') + .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') } -- GitLab From 9e8a187c4e83477914a07dc1aa45e72978479f16 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 23 Mar 2022 11:54:49 -0300 Subject: [PATCH 105/305] add subroutes --- src/libs/convert/enrollmentSituation.js | 33 +++++++++++++++++++++++ src/libs/convert/enterSituation.js | 35 +++++++++++++++++++++++++ src/libs/middlewares/id2str.js | 10 +++++-- src/libs/routes/universityEnrollment.js | 24 +++++++++++++++++ 4 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 src/libs/convert/enrollmentSituation.js create mode 100644 src/libs/convert/enterSituation.js diff --git a/src/libs/convert/enrollmentSituation.js b/src/libs/convert/enrollmentSituation.js new file mode 100644 index 00000000..9b709ea2 --- /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 00000000..1fe551d9 --- /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 fa6a20ca..668faa80 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 5adec697..d68166c3 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') -- GitLab From 5324f1d990c4c0dca6b8036a41722afa51650008 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Fri, 25 Mar 2022 09:43:00 -0300 Subject: [PATCH 106/305] change dim to subroute --- src/libs/routes/universityEnrollment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index a856f82d..5bded40f 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -287,7 +287,7 @@ universityEnrollmentApp.get('/age_student_code', function (req, res, next) { }, response('age_student_code')); -universityEnrollmentApp.get('/student_enter_situation', function (req, res, next) { +universityEnrollmentApp.get('/enter_situation/student_enter_situation', function (req, res, next) { req.result = []; for (var i = 1; i <= 4; ++i) { req.result.push({ @@ -299,7 +299,7 @@ universityEnrollmentApp.get('/student_enter_situation', function (req, res, next }, response('student_enter_situation')); -universityEnrollmentApp.get('/student_enrollment_situation', function (req, res, next) { +universityEnrollmentApp.get('/enter_situation/student_enrollment_situation', function (req, res, next) { req.result = []; for (var i = 1; i <= 3; ++i) { req.result.push({ -- GitLab From bb1b25e38bf9408bbf38a5464298ff04c10e0b94 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 30 Mar 2022 09:35:13 -0300 Subject: [PATCH 107/305] hotfix add taxa_evasao --- src/libs/routes/universityEnrollment.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index a856f82d..f39d9f81 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -781,10 +781,12 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => res.concluinte = Number(res.concluinte); res.evadido = Number(res.evadido); res.trancado = Number(res.trancado); + res.total = res.cursando + res.concluinte + res.evadido + res.trancado + res.taxa_evasao = Number(res.evadido/res.total) } 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') @@ -808,3 +810,5 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex next(); }, id2str.transform(), response('enrollmentSituation')); + +module.exports = universityEnrollmentApp; \ No newline at end of file -- GitLab From c9d54cfcc399000b5e8cbfcda0207291dab6fa80 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 30 Mar 2022 09:48:55 -0300 Subject: [PATCH 108/305] hotfix percentage --- src/libs/routes/universityEnrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 329bfff2..262ac88f 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -782,7 +782,7 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => res.evadido = Number(res.evadido); res.trancado = Number(res.trancado); res.total = res.cursando + res.concluinte + res.evadido + res.trancado - res.taxa_evasao = Number(res.evadido/res.total) + res.taxa_evasao = Number( ((res.evadido/res.total) * 100).toFixed(2) ) } next(); }, id2str.transform(), response('enterSituation')); -- GitLab From 45d8249e5a374dde3d2a67cab6bdee699b72ece6 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Tue, 5 Apr 2022 10:23:22 -0300 Subject: [PATCH 109/305] hotfix filters --- src/libs/routes/universityEnrollment.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 262ac88f..81f53808 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -709,6 +709,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('curso_ens_superior.ano_censo', 'year') .field('COUNT(localoferta_ens_superior.cod_local_oferta)', 'total') .group('localoferta_ens_superior_matricula.ano_censo') + .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') .order('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior.cod_local_oferta'); } else { @@ -720,6 +722,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .group('localoferta_ens_superior_matricula.ano_censo') .group('localoferta_ens_superior_matricula.cod_ies') .group('localoferta_ens_superior_matricula.nome_ies') + .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') .order('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.cod_local_oferta'); } @@ -729,6 +733,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('DISTINCT 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') } else if ("university" in req.dims || "universityLocalOffer" in req.dims) { @@ -747,6 +753,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .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') } -- GitLab From 51b5589402d6ccb2c57a01bd7205a14fb4f7be59 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Tue, 5 Apr 2022 11:25:09 -0300 Subject: [PATCH 110/305] hotfix filters --- src/libs/routes/universityEnrollment.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 81f53808..6d1a08f1 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -709,8 +709,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('curso_ens_superior.ano_censo', 'year') .field('COUNT(localoferta_ens_superior.cod_local_oferta)', 'total') .group('localoferta_ens_superior_matricula.ano_censo') - .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') + .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') + .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .order('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior.cod_local_oferta'); } else { @@ -722,8 +722,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .group('localoferta_ens_superior_matricula.ano_censo') .group('localoferta_ens_superior_matricula.cod_ies') .group('localoferta_ens_superior_matricula.nome_ies') - .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') + .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') + .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .order('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.cod_local_oferta'); } @@ -733,8 +733,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('DISTINCT 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') + .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') + .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') } else if ("university" in req.dims || "universityLocalOffer" in req.dims) { @@ -753,8 +753,8 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .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') + .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') + .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') } @@ -766,7 +766,7 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { course.percentage = Number((( course.total / total_course ) * 100).toFixed(2)) } } - next() + next(); }, response('universityEnrollment')); universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => { -- GitLab From 659ac15e91dc14c2ea3b2af9a288ba92a6f4023d Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 7 Apr 2022 11:48:26 -0300 Subject: [PATCH 111/305] updated local_type in schools, class and enrollment tables --- src/libs/routes/class.js | 10 ++++++++++ src/libs/routes/employees.js | 10 ++++++++++ src/libs/routes/enrollment.js | 10 ++++++++++ src/libs/routes/school.js | 10 ++++++++++ 4 files changed, 40 insertions(+) diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index 4cf349fa..88df17a2 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -275,6 +275,16 @@ rqfCount.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: 'turma', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'rural_location', table: 'turma', diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js index 89b5ebd0..927aea51 100644 --- a/src/libs/routes/employees.js +++ b/src/libs/routes/employees.js @@ -253,6 +253,16 @@ rqfSchool.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: 'funcionarios_por_escola', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'rural_location', table: '@', diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index c3a1e68d..e0da7fbf 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -498,6 +498,16 @@ rqf.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: 'matricula', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'rural_location', table: 'matricula', diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index e8527400..f100b6e6 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -429,6 +429,16 @@ rqfCount.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: 'escola', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'rural_location', table: 'escola', -- GitLab From a546bd1082d9899021aa5e16e2ce12f947ea241a Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Fri, 8 Apr 2022 11:31:46 -0300 Subject: [PATCH 112/305] adding filters and changing base consult on employees and teacher tables --- src/libs/routes/employees.js | 2 +- src/libs/routes/teacher.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js index 927aea51..20dcb7b2 100644 --- a/src/libs/routes/employees.js +++ b/src/libs/routes/employees.js @@ -255,7 +255,7 @@ rqfSchool.addField({ } }).addValue({ name: 'diff_location', - table: 'funcionarios_por_escola', + table: '@', tableField: 'localizacao_diferenciada_par', resultField: 'diff_location_id_par', where: { diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 51e5fea4..2ce66328 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -416,6 +416,16 @@ rqf.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: 'docente', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'rural_location', table: 'docente', -- GitLab From 87332cdcf4d3447588575a9aaff08f3891152fe3 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Mon, 11 Apr 2022 09:46:17 -0300 Subject: [PATCH 113/305] edit base consult filters --- src/libs/routes/auxiliar.js | 2 +- src/libs/routes/teacher.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/auxiliar.js b/src/libs/routes/auxiliar.js index 5a4198d3..08a910e5 100644 --- a/src/libs/routes/auxiliar.js +++ b/src/libs/routes/auxiliar.js @@ -370,7 +370,7 @@ auxiliarApp.get('/', rqf.parse(), (req, res, next) => { .where('(docente.tipo_docente = 2) AND \ ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) \ - AND (docente.ano_censo <> 2009 or docente.escola_estado_id <> 42)'); // não devemos trazer SC em 2009. + AND (docente.ano_censo <> 2009 or (docente.escola_estado_id <> 42 AND docente.escola_estado_id <> 43))'); // não devemos trazer SC em 2009. next(); }, rqf.build(), query, addMissing(rqf), id2str.transform(), response('auxiliar')); diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 2ce66328..05f31222 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -532,7 +532,7 @@ teacherApp.get('/', rqf.parse(), (req, res, next) => { .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) \ - AND (docente.ano_censo <> 2009 or docente.escola_estado_id <> 42)'); // não devemos trazer SC em 2009. + AND (docente.ano_censo <> 2009 or (docente.escola_estado_id <> 42 and docente.escola_estado_id <> 43) )'); // não devemos trazer SC em 2009. // if("education_level_mod" in req.dims) { // req.hadEducationLevelMod = true; -- GitLab From f9398d305ca4e4a25a38d90be8a707444f37799d Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 7 Apr 2022 11:48:26 -0300 Subject: [PATCH 114/305] updated local_type in schools, class and enrollment tables adding filters and changing base consult on employees and teacher tables edit base consult filters --- src/libs/routes/auxiliar.js | 2 +- src/libs/routes/class.js | 10 ++++++++++ src/libs/routes/employees.js | 10 ++++++++++ src/libs/routes/enrollment.js | 10 ++++++++++ src/libs/routes/school.js | 10 ++++++++++ src/libs/routes/teacher.js | 12 +++++++++++- 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/auxiliar.js b/src/libs/routes/auxiliar.js index 5a4198d3..08a910e5 100644 --- a/src/libs/routes/auxiliar.js +++ b/src/libs/routes/auxiliar.js @@ -370,7 +370,7 @@ auxiliarApp.get('/', rqf.parse(), (req, res, next) => { .where('(docente.tipo_docente = 2) AND \ ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) \ - AND (docente.ano_censo <> 2009 or docente.escola_estado_id <> 42)'); // não devemos trazer SC em 2009. + AND (docente.ano_censo <> 2009 or (docente.escola_estado_id <> 42 AND docente.escola_estado_id <> 43))'); // não devemos trazer SC em 2009. next(); }, rqf.build(), query, addMissing(rqf), id2str.transform(), response('auxiliar')); diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index 4cf349fa..88df17a2 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -275,6 +275,16 @@ rqfCount.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: 'turma', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'rural_location', table: 'turma', diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js index 89b5ebd0..20dcb7b2 100644 --- a/src/libs/routes/employees.js +++ b/src/libs/routes/employees.js @@ -253,6 +253,16 @@ rqfSchool.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: '@', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'rural_location', table: '@', diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index c3a1e68d..e0da7fbf 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -498,6 +498,16 @@ rqf.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: 'matricula', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'rural_location', table: 'matricula', diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index e8527400..f100b6e6 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -429,6 +429,16 @@ rqfCount.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: 'escola', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'rural_location', table: 'escola', diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 51e5fea4..05f31222 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -416,6 +416,16 @@ rqf.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: 'docente', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'rural_location', table: 'docente', @@ -522,7 +532,7 @@ teacherApp.get('/', rqf.parse(), (req, res, next) => { .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) \ - AND (docente.ano_censo <> 2009 or docente.escola_estado_id <> 42)'); // não devemos trazer SC em 2009. + AND (docente.ano_censo <> 2009 or (docente.escola_estado_id <> 42 and docente.escola_estado_id <> 43) )'); // não devemos trazer SC em 2009. // if("education_level_mod" in req.dims) { // req.hadEducationLevelMod = true; -- GitLab From 81cfa25ffa522c2dee6ea9b0d86624d2994f3875 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 13 Apr 2022 11:59:56 -0300 Subject: [PATCH 115/305] Change calculations enrollment_situation --- src/libs/routes/universityEnrollment.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 6d1a08f1..e6976572 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -797,10 +797,10 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => 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('SUM(CASE WHEN localoferta_ens_superior_matricula.cod_aluno_situacao=2 THEN 1 ELSE 0 END)', 'cursando') + .field('SUM(CASE WHEN localoferta_ens_superior_matricula.cod_aluno_situacao=6 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) THEN 1 ELSE 0 END)', 'evadido') + .field('SUM(CASE WHEN localoferta_ens_superior_matricula.cod_aluno_situacao=3 THEN 1 ELSE 0 END)', 'trancado') .field('localoferta_ens_superior_matricula.ano_censo', 'year') .field("'Brasil'", 'name') .where('localoferta_ens_superior_matricula.cod_nivel_academico=1') -- GitLab From ba2ed8b049ee98190ccc22cb8850b34a0db19204 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 13 Apr 2022 12:06:55 -0300 Subject: [PATCH 116/305] add enrollment_situation/student_enter_situation subroute --- src/libs/routes/universityEnrollment.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index e6976572..b4b698a0 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -298,6 +298,17 @@ universityEnrollmentApp.get('/enter_situation/student_enter_situation', function next(); }, response('student_enter_situation')); +universityEnrollmentApp.get('/enrollment_situation/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('/enter_situation/student_enrollment_situation', function (req, res, next) { req.result = []; -- GitLab From 6cb77cf2d406a0eb55c60550a544c4053a1b0f8c Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 13 Apr 2022 12:09:24 -0300 Subject: [PATCH 117/305] Change parse values --- src/libs/routes/universityEnrollment.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index b4b698a0..b58d923b 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -821,10 +821,11 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex 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); + res.concluinte = Number(res.concluinte); + res.evadido = Number(res.evadido); + res.trancado = Number(res.trancado); + res.total = res.cursando + res.concluinte + res.evadido + res.trancado } next(); }, id2str.transform(), response('enrollmentSituation')); -- GitLab From 9076c094f13d6d5ed630028d7d0832e65f9f1ced Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 14 Apr 2022 10:49:03 -0300 Subject: [PATCH 118/305] changed rural location to diff location on schools route --- src/libs/routes/school.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index f100b6e6..d0aa269e 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -58,14 +58,12 @@ schoolApp.get('/location', cache('15 day'), (req, res, next) => { next(); }, response('location')); -schoolApp.get('/rural_location', cache('15 day'), (req, res, next) => { +schoolApp.get('/diff_location', cache('15 day'), (req, res, next) => { req.result = [ - {id: 1, name: "Urbana"}, - {id: 2, name: "Rural"}, - {id: 3, name: "Rural - Área de assentamento"}, - {id: 4, name: "Rural - Terra indígena"}, - {id: 5, name: "Rural - Área remanescente de quilombos"}, - {id: 6, name: "Rural - Unidade de uso sustentável"} + {id: 0, name: "A escola não está em localidade diferenciada"}, + {id: 1, name: "Área de assentamento"}, + {id: 2, name: "Terra indígena"}, + {id: 3, name: "Terra remanescente de quilombos"}, ]; next(); }, response('rural_location')); -- GitLab From 499bd6311f14e405548a11001f31ffd5a694ce02 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 14 Apr 2022 11:55:50 -0300 Subject: [PATCH 119/305] add diff_location filter to rqf --- src/libs/routes/school.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index f100b6e6..f2a6d6ca 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -294,7 +294,17 @@ rqf.addField({ foreign: 'estado_id', foreignTable: 'escola' } -}, 'search'); +}, 'search').addValue({ + name: 'diff_location', + table: 'escola', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } +}); rqfCount.addField({ name: 'filter', -- GitLab From b82e177a6682d414b2f8fd5387b8d46be720dc4a Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Tue, 26 Apr 2022 10:43:06 -0300 Subject: [PATCH 120/305] update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 99a279fb..dcf0f82a 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ docs/ .vscode/ package-lock.json + +Dockerfile -- GitLab From b136374e5316d3ecd6048e7467b2a8a38da236c2 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Tue, 26 Apr 2022 10:45:01 -0300 Subject: [PATCH 121/305] remove dockerfile --- Dockerfile | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 49d758a4..00000000 --- a/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -FROM node:dubnium-stretch - -ENV HTTP_PROXY=http://httpproxy.c3sl.ufpr.br:3128/ - -ENV HTTPS_PROXY=http://httpproxy.c3sl.ufpr.br:3128/ - -RUN npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint istanbul --force - -RUN npm un -g gulp - -RUN npm i -g gulp@3.9.0 - -RUN mkdir API - -COPY . ./API - -WORKDIR ./API - -RUN npm install - -RUN gulp build - -EXPOSE 3000 - -CMD NODE_ENV=production gulp -- GitLab From 865c9502ae00bb4f91fd3a8ce0b9b63ded45a7bd Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Tue, 26 Apr 2022 10:52:56 -0300 Subject: [PATCH 122/305] update gitignore --- .gitignore | 3 +++ Dockerfile | 25 ------------------------- 2 files changed, 3 insertions(+), 25 deletions(-) delete mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index 99a279fb..349e3af1 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ docs/ .vscode/ package-lock.json + +Dockerfile + diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index afe3c156..00000000 --- a/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -FROM node:carbon-buster - -ENV HTTP_PROXY=http://httpproxy.c3sl.ufpr.br:3128/ - -ENV HTTPS_PROXY=http://httpproxy.c3sl.ufpr.br:3128/ - -RUN npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint istanbul --force - -RUN npm un -g gulp - -RUN npm i -g gulp@3.9.0 - -RUN mkdir API - -COPY . ./API - -WORKDIR ./API - -RUN npm install - -RUN gulp build - -EXPOSE 3000 - -CMD NODE_ENV=production gulp -- GitLab From 7faf3b9fa2345758be3768d89fe41f70a405c5e9 Mon Sep 17 00:00:00 2001 From: SimCAQ-Homologa <root@simcaqhomologa.c3sl.ufpr.br> Date: Mon, 2 May 2022 09:19:29 -0300 Subject: [PATCH 123/305] add message route --- src/libs/routes/message.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libs/routes/message.js b/src/libs/routes/message.js index 57eb350f..dd6f90a1 100644 --- a/src/libs/routes/message.js +++ b/src/libs/routes/message.js @@ -26,19 +26,22 @@ const email = require(`../middlewares/email`); const log = require(`../log`)(module); -messageApp.get('/', (req, res, next) => { - res.json({msg: 'This is the message route'}); -}) messageApp.post('/', (req, res, next) => { var reqName = req.body.name var reqEmail = req.body.email var reqContents = req.body.contents + var reqOrigin = req.body.origin ? req.body.origin : ""; + var sub = "Contato " + reqOrigin let mailOptions = { - from: `"${reqName} <${reqEmail}>"`, - text: reqContents + from: `\"${reqName}\" <${reqEmail}>`, + text: reqContents, + subject: sub } + console.log("reqbody", req.body) + console.log("mail options", mailOptions) + email(mailOptions, (err, info) => { if(err) { log.error(err); @@ -52,3 +55,4 @@ messageApp.post('/', (req, res, next) => { }) module.exports = messageApp; + -- GitLab From 1f65154d7c0f1a47e4a5480275eb4f8f7845acc6 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 2 May 2022 10:33:27 -0300 Subject: [PATCH 124/305] fix gitlab-ci --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 356b1c4b..13096dc7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,13 +31,13 @@ regression_tests: - npm install - gulp build && gulp & - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - - python get-pip.py + - python3 get-pip.py - sleep 60 script: - git clone https://gitlab.c3sl.ufpr.br/simcaq/lde-api-regression-test.git - cd lde-api-regression-test - - pip install -r requirements.txt - - python manage.py compare --verbose + - pip3 install -r requirements.txt + - python3 manage.py compare --verbose tags: - node -- GitLab From 0aeda285dccfea4f47a10d810190ea3734d0df7a Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 2 May 2022 10:38:03 -0300 Subject: [PATCH 125/305] fix gitlab-ci --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 13096dc7..d21b3fcb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,14 +30,14 @@ regression_tests: - npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint - npm install - gulp build && gulp & - - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - - python3 get-pip.py + - curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py + - python get-pip.py - sleep 60 script: - git clone https://gitlab.c3sl.ufpr.br/simcaq/lde-api-regression-test.git - cd lde-api-regression-test - - pip3 install -r requirements.txt - - python3 manage.py compare --verbose + - pip install -r requirements.txt + - python manage.py compare --verbose tags: - node -- GitLab From cba7de54b09a06c1acb5d9a34fe0986acd91a82e Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 2 May 2022 11:12:52 -0300 Subject: [PATCH 126/305] fix gitlab-ci --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d21b3fcb..87783caa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,9 @@ variables: regression_tests: stage: test before_script: + - sudo apt-get update + - sudo apt-get install apt-transport-https ca-certificates -y + - sudo update-ca-certificates - npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint - npm install - gulp build && gulp & -- GitLab From 1da47988a5091005809942b96265150602d4695f Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 2 May 2022 11:14:13 -0300 Subject: [PATCH 127/305] fix gitlab-ci --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 87783caa..71632ec4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,9 +27,9 @@ variables: regression_tests: stage: test before_script: - - sudo apt-get update - - sudo apt-get install apt-transport-https ca-certificates -y - - sudo update-ca-certificates + - apt update + - apt install apt-transport-https ca-certificates -y + - update-ca-certificates - npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint - npm install - gulp build && gulp & -- GitLab From fe4d3fe02d008cade6a61be1aa32d2e54a3d7342 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 2 May 2022 11:22:51 -0300 Subject: [PATCH 128/305] fix gitlab-ci --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 71632ec4..738c3b11 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: node:9.2.1 +image: node:10.24.1 stages: - test -- GitLab From e3b2ed0d48c9a3f53a7d45794f3646a813cb2e42 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 2 May 2022 11:26:37 -0300 Subject: [PATCH 129/305] return original gitlab-ci --- .gitlab-ci.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 738c3b11..d9d7a062 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: node:10.24.1 +image: node:9.2.1 stages: - test @@ -27,13 +27,10 @@ variables: regression_tests: stage: test before_script: - - apt update - - apt install apt-transport-https ca-certificates -y - - update-ca-certificates - npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint - npm install - gulp build && gulp & - - curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py + - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - python get-pip.py - sleep 60 script: @@ -44,3 +41,4 @@ regression_tests: - python manage.py compare --verbose tags: - node + -- GitLab From a313c3a5af5c6a516bb86783918c80a7036e1f45 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 2 May 2022 11:29:30 -0300 Subject: [PATCH 130/305] remove gitlab-ci --- .gitlab-ci.yml | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index d9d7a062..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,44 +0,0 @@ -image: node:9.2.1 - -stages: - - test - -services: - - mongo:latest - -variables: - MONGO_URI: 'mongodb://mongo/app_name' - NODE_ENV: 'test' - -#run_tests: -# stage: test -# before_script: -# - node -v -# - npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha #gulp-eslint -# - npm install -# script: -# - ping -W1 -c1 mongo -# - sed -i -e 's/false/true/g' config.json -# - gulp build -# - gulp test -# tags: -# - node - -regression_tests: - stage: test - before_script: - - npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint - - npm install - - gulp build && gulp & - - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - - python get-pip.py - - sleep 60 - script: - - - git clone https://gitlab.c3sl.ufpr.br/simcaq/lde-api-regression-test.git - - cd lde-api-regression-test - - pip install -r requirements.txt - - python manage.py compare --verbose - tags: - - node - -- GitLab From 186eb58e64c6ce3213c9aed314bc431acd2764cb Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 2 May 2022 11:56:23 -0300 Subject: [PATCH 131/305] remove gitlab-ci --- .gitlab-ci.yml | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 356b1c4b..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,43 +0,0 @@ -image: node:9.2.1 - -stages: - - test - -services: - - mongo:latest - -variables: - MONGO_URI: 'mongodb://mongo/app_name' - NODE_ENV: 'test' - -#run_tests: -# stage: test -# before_script: -# - node -v -# - npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha #gulp-eslint -# - npm install -# script: -# - ping -W1 -c1 mongo -# - sed -i -e 's/false/true/g' config.json -# - gulp build -# - gulp test -# tags: -# - node - -regression_tests: - stage: test - before_script: - - npm install --global gulp gulp-cli babel babel-cli babel-core babel-register mocha gulp-mocha gulp-eslint - - npm install - - gulp build && gulp & - - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - - python get-pip.py - - sleep 60 - script: - - - git clone https://gitlab.c3sl.ufpr.br/simcaq/lde-api-regression-test.git - - cd lde-api-regression-test - - pip install -r requirements.txt - - python manage.py compare --verbose - tags: - - node -- GitLab From bc50ee056aa04353ce73625f8d0dac35c087d9df Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 4 May 2022 11:34:17 -0300 Subject: [PATCH 132/305] add turma turno id filter --- src/libs/routes/classCount.js | 2 +- src/libs/routes/classroomCount.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/classCount.js b/src/libs/routes/classCount.js index 27132383..ffdbe34f 100644 --- a/src/libs/routes/classCount.js +++ b/src/libs/routes/classCount.js @@ -367,7 +367,7 @@ classCountApp.get('/count', rqf.parse(), (req, res, next) => { .from('turma') .group('turma.ano_censo') .order('turma.ano_censo') - .where('turma.local_turma = 0 AND turma.dependencia_adm_id <= 3 AND ((turma.etapa_resumida >= 1 AND turma.etapa_resumida <= 7) OR turma.etapa_resumida = 99)'); + .where('turma.local_turma = 0 AND turma.dependencia_adm_id <= 3 AND ((turma.etapa_resumida >= 1 AND turma.etapa_resumida <= 7) OR turma.etapa_resumida = 99) AND turma.turma_turno_id <> 99') next(); }, rqf.build(), query, addMissing(rqf), id2str.transform(), response('class_count')); diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 601b0234..15a0f7ee 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -403,7 +403,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { .from('matricula') .group('matricula.ano_censo') .order('matricula.ano_censo') - .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); + .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2) AND matricula.turma_turno_id <> 99)'); next(); }, rqf.build() ,query, id2str.transform(), (req, res, next) => { // constrói objeto de tempo integral e calcula diagnósticos -- GitLab From 24c05be5a9dc1291b84dc8699b4eb9b188d081b7 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Mon, 9 May 2022 11:22:21 -0300 Subject: [PATCH 133/305] adding diff_location necessary conversions --- src/libs/convert/diffLocation.js | 32 ++++++++++++++++++++++++++++++++ src/libs/middlewares/id2str.js | 7 +++++-- src/libs/routes/employees.js | 2 ++ src/libs/routes/school.js | 2 +- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 src/libs/convert/diffLocation.js diff --git a/src/libs/convert/diffLocation.js b/src/libs/convert/diffLocation.js new file mode 100644 index 00000000..a25d6983 --- /dev/null +++ b/src/libs/convert/diffLocation.js @@ -0,0 +1,32 @@ +/* +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 location(id) { + switch (id) { + case 0: + return 'Não está em localidade diferenciada'; + case 1: + return 'Área de assentamento'; + case 2: + return 'Terra indígena'; + case 3: + return 'Área remanescente de quilombos' + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index 668faa80..80086152 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -92,6 +92,7 @@ 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 diffLocation = require(`${libs}/convert/diffLocation`); const ids = { gender_id: gender, @@ -175,7 +176,8 @@ const ids = { licentiate_degree_id: licentiateDegree, enrolled_vacancies_freshmen: enrolledVacanciesFreshmen, enter_situation: enterSituation, - enrollment_situation: enrollmentSituation + enrollment_situation: enrollmentSituation, + diff_location_id_par: diffLocation }; function transform(removeId=false) { @@ -286,5 +288,6 @@ module.exports = { licentiateDegree, enrolledVacanciesFreshmen, enterSituation, - enrollmentSituation + enrollmentSituation, + diffLocation }; diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js index 20dcb7b2..83c9971c 100644 --- a/src/libs/routes/employees.js +++ b/src/libs/routes/employees.js @@ -593,6 +593,7 @@ employeesApp.get('/', rqfSchool.parse(), (req, res, next) => { }, rqfSchool.build(), query, rqfSchool.parse(), id2str.transform(), (req, res, next) => { req.allTeacher = req.result; + console.log("resultado employees", req.allTeacher) req.resetSql(); if ("function" in req.dims) { req.sql.field('SUM(CASE WHEN escola.qt_prof_admin = 88888 THEN 0 ELSE escola.qt_prof_admin END)', 'qtde_admin') @@ -628,6 +629,7 @@ employeesApp.get('/', rqfSchool.parse(), (req, res, next) => { }, rqfSchool.build(), query, rqfSchool.parse(), id2str.transform(), (req, res, next) => { + console.log("resultado employees2", req.allTeacher) if ("function" in req.dims) { let aux_employes = formatFunction(req.result, req.dims); req.allTeacher = formatFunction(req.allTeacher, req.dims); diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index eb521f6b..1101d355 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -66,7 +66,7 @@ schoolApp.get('/diff_location', cache('15 day'), (req, res, next) => { {id: 3, name: "Terra remanescente de quilombos"}, ]; next(); -}, response('rural_location')); +}, response('diff_location')); schoolApp.get('/adm_dependency', (req, res, next) => { req.result = []; -- GitLab From 351d17ea14cef1e83f4cccc8296d7b3448ca1e6a Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Tue, 10 May 2022 11:22:04 -0300 Subject: [PATCH 134/305] remove logs from routes --- src/libs/routes/courseCount.js | 10 ++-------- src/libs/routes/courseStudents.js | 5 +---- src/libs/routes/disciplines.js | 2 +- src/libs/routes/message.js | 5 +---- src/libs/routes/universityEnrollment.js | 4 ++-- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/libs/routes/courseCount.js b/src/libs/routes/courseCount.js index 44d2487a..4cc8974a 100644 --- a/src/libs/routes/courseCount.js +++ b/src/libs/routes/courseCount.js @@ -717,10 +717,7 @@ courseCountApp.get('/count_by_name', rqfMapfor.parse(), (req, res, next) => { .order('localoferta_ens_superior.ano_censo') next(); -}, rqfMapfor.build(), (req, res, next) => { - console.log(req.sql.toString()); - next(); -}, query, (req, res, next) =>{ +}, rqfMapfor.build(), query, (req, res, next) =>{ if ('course' in req.dims){ var total_course = req.result.reduce((total, cur) => {return total += cur.total}, 0) for (var course of req.result){ @@ -799,10 +796,7 @@ courseCountApp.get('/', rqf.parse(), (req, res, next) => { .where('curso_ens_superior.cod_nivel_academico = 1'); } next(); -}, rqf.build(), (req, res, next) => { - console.log(req.sql.toString()); - next(); -}, query, (req, res, next) =>{ +}, rqf.build(), query, (req, res, next) =>{ if ('course' in req.dims){ var total_course = req.result.reduce((total, cur) => {return total += cur.total}, 0) for (var course of req.result){ diff --git a/src/libs/routes/courseStudents.js b/src/libs/routes/courseStudents.js index cd0aea1b..77180cb2 100644 --- a/src/libs/routes/courseStudents.js +++ b/src/libs/routes/courseStudents.js @@ -187,10 +187,7 @@ courseStudentsApp.get('/', rqf.parse(), (req, res, next) => { .order("curso_ens_superior.ano_censo") next(); -}, rqf.build(), (req, res, next) => { - console.log(req.sql.toString()); - next(); -}, query, (req, res, next) => { +}, rqf.build(), query, (req, res, next) => { for (var res of req.result){ res.inscritos_total = Number(res.inscritos_total); res.vagas_totais = Number(res.vagas_totais); diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 23bdcfa3..d43d8d31 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -628,7 +628,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { // else { let disciplinesNotSuitable = []; let disciplinesSuitable = []; - console.log(req.result); + req.result.forEach((r) => { let objNotSuitable = { total: parseInt(r.total) - parseInt(r.total_suitable), diff --git a/src/libs/routes/message.js b/src/libs/routes/message.js index dd6f90a1..56427865 100644 --- a/src/libs/routes/message.js +++ b/src/libs/routes/message.js @@ -39,13 +39,10 @@ messageApp.post('/', (req, res, next) => { subject: sub } - console.log("reqbody", req.body) - console.log("mail options", mailOptions) - email(mailOptions, (err, info) => { if(err) { log.error(err); - console.log(err) + console.log(err); res.status(500).json({msg: 'Undelivered Contact Mail'}); } else { log.info(`Message ${info.messageId} sent: ${info.response}`); diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index b58d923b..c938385c 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -794,7 +794,7 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => .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) => { +}, rqf.build(), query, (req, res, next) => { for (var res of req.result){ res.cursando = Number(res.cursando); res.concluinte = Number(res.concluinte); @@ -819,7 +819,7 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex .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) => { +}, rqf.build(), query, (req, res, next) => { for (var res of req.result){ res.cursando = Number(res.cursando); res.concluinte = Number(res.concluinte); -- GitLab From 886e4540dd4f74e8c8e168dab795e2ff6ebeb959 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Wed, 11 May 2022 10:00:14 -0300 Subject: [PATCH 135/305] adding diff_location sub-routes to all required routes --- src/libs/routes/class.js | 19 +++++++++++++++++++ src/libs/routes/employees.js | 18 ++++++++++++++++++ src/libs/routes/enrollment.js | 18 ++++++++++++++++++ src/libs/routes/teacher.js | 18 ++++++++++++++++++ 4 files changed, 73 insertions(+) diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index 88df17a2..50e31df4 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -68,6 +68,25 @@ classApp.get('/source', (req, res, next) => { next(); }, query, response('source')); +classApp.get('/location', cache('15 day'), (req, res, next) => { + req.result = [ + {id: 1, name: 'Urbana'}, + {id: 2, name: 'Rural'} + ]; + next(); +}, response('location')); + +classApp.get('/diff_location', cache('15 day'), (req, res, next) => { + req.result = [ + {id: 0, name: "A escola não está em localidade diferenciada"}, + {id: 1, name: "Área de assentamento"}, + {id: 2, name: "Terra indígena"}, + {id: 3, name: "Terra remanescente de quilombos"}, + ]; + next(); +}, response('diff_location')); + + classApp.get('/location', (req, res, next) => { req.result = []; for(let i = 1; i <= 2; ++i) { diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js index 83c9971c..ffb8c735 100644 --- a/src/libs/routes/employees.js +++ b/src/libs/routes/employees.js @@ -70,6 +70,24 @@ employeesApp.get('/source', (req, res, next) => { next(); }, query, response('source')); +employeesApp.get('/location', cache('15 day'), (req, res, next) => { + req.result = [ + {id: 1, name: 'Urbana'}, + {id: 2, name: 'Rural'} + ]; + next(); +}, response('location')); + +employeesApp.get('/diff_location', cache('15 day'), (req, res, next) => { + req.result = [ + {id: 0, name: "A escola não está em localidade diferenciada"}, + {id: 1, name: "Área de assentamento"}, + {id: 2, name: "Terra indígena"}, + {id: 3, name: "Terra remanescente de quilombos"}, + ]; + next(); +}, response('diff_location')); + employeesApp.get('/adm_dependency_detailed', (req, res, next) => { req.result = []; for(let i = 1; i <= 6; ++i) { diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index e0da7fbf..d41c82c1 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -68,6 +68,24 @@ enrollmentApp.get('/source', (req, res, next) => { next(); }, query, response('source')); +enrollmentApp.get('/location', cache('15 day'), (req, res, next) => { + req.result = [ + {id: 1, name: 'Urbana'}, + {id: 2, name: 'Rural'} + ]; + next(); +}, response('location')); + +enrollmentApp.get('/diff_location', cache('15 day'), (req, res, next) => { + req.result = [ + {id: 0, name: "A escola não está em localidade diferenciada"}, + {id: 1, name: "Área de assentamento"}, + {id: 2, name: "Terra indígena"}, + {id: 3, name: "Terra remanescente de quilombos"}, + ]; + next(); +}, response('diff_location')); + enrollmentApp.get('/location', (req, res, next) => { req.result = []; for(let i = 1; i <= 2; ++i) { diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 05f31222..77df5a19 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -67,6 +67,24 @@ teacherApp.get('/source', (req, res, next) => { next(); }, query, response('source')); +teacherApp.get('/location', cache('15 day'), (req, res, next) => { + req.result = [ + {id: 1, name: 'Urbana'}, + {id: 2, name: 'Rural'} + ]; + next(); +}, response('location')); + +teacherApp.get('/diff_location', cache('15 day'), (req, res, next) => { + req.result = [ + {id: 0, name: "A escola não está em localidade diferenciada"}, + {id: 1, name: "Área de assentamento"}, + {id: 2, name: "Terra indígena"}, + {id: 3, name: "Terra remanescente de quilombos"}, + ]; + next(); +}, response('diff_location')); + teacherApp.get('/adm_dependency_detailed', (req, res, next) => { req.result = []; for(let i = 1; i <= 8; ++i) { -- GitLab From 32c325181c01da1a0c8009c43756c8d4be5f4dac Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Wed, 11 May 2022 10:26:25 -0300 Subject: [PATCH 136/305] removing confliting sub-routes --- src/libs/routes/class.js | 26 -------------------------- src/libs/routes/employees.js | 23 ----------------------- src/libs/routes/enrollment.js | 22 ---------------------- src/libs/routes/teacher.js | 22 ---------------------- 4 files changed, 93 deletions(-) diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index 50e31df4..e24b1b48 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -86,32 +86,6 @@ classApp.get('/diff_location', cache('15 day'), (req, res, next) => { next(); }, response('diff_location')); - -classApp.get('/location', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 2; ++i) { - req.result.push({ - id: i, - name: id2str.location(i) - }); - }; - next(); -}, response('location')); - -classApp.get('/rural_location', (req, res, next) => { - req.result = [ - {id: 1, name: "Urbana"}, - {id: 2, name: "Rural"}, - {id: 3, name: "Rural - Área de assentamento"}, - {id: 4, name: "Rural - Terra indígena"}, - {id: 5, name: "Rural - Área remanescente de quilombos"}, - {id: 6, name: "Rural - Unidade de uso sustentável"}, - {id: 7, name: "Unidade de uso sustentavel em terra indígena"}, - {id: 8, name: "Unidade de uso sustentável em área remanescente de quilombos"} - ]; - next(); -}, response('rural_location')); - // Returns all adm dependencies classApp.get('/adm_dependency', (req, res, next) => { req.result = []; diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js index ffb8c735..8fbcd2a1 100644 --- a/src/libs/routes/employees.js +++ b/src/libs/routes/employees.js @@ -110,29 +110,6 @@ employeesApp.get('/adm_dependency', (req, res, next) => { next(); }, response('adm_dependency')); -employeesApp.get('/location', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 2; ++i) { - req.result.push({ - id: i, - name: id2str.location(i) - }); - }; - next(); -}, response('location')); - -employeesApp.get('/rural_location', (req, res, next) => { - req.result = [ - {id: 1, name: "Urbana"}, - {id: 2, name: "Rural"}, - {id: 3, name: "Rural - Área de assentamento"}, - {id: 4, name: "Rural - Terra indígena"}, - {id: 5, name: "Rural - Área remanescente de quilombos"}, - {id: 6, name: "Rural - Unidade de uso sustentável"} - ]; - next(); -}, response('rural_location')); - employeesApp.get('/function', (req, res, next) => { req.result = [ {id: 0, name: "Administrativos"}, diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index d41c82c1..d749336d 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -86,28 +86,6 @@ enrollmentApp.get('/diff_location', cache('15 day'), (req, res, next) => { next(); }, response('diff_location')); -enrollmentApp.get('/location', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 2; ++i) { - req.result.push({ - id: i, - name: id2str.location(i) - }); - }; - next(); -}, response('location')); - -enrollmentApp.get('/rural_location', (req, res, next) => { - req.result = []; - for (let i = 1; i <= 8; i++) { - req.result.push({ - id: i, - name: id2str.ruralLocation(i) - }); - }; - next(); -}, response('rural_location')); - // Returns all school years available enrollmentApp.get('/school_year', (req, res, next) => { req.result = []; diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 77df5a19..70580e09 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -136,28 +136,6 @@ teacherApp.get('/education_level_short', (req, res, next) => { next(); }, response('education_level_short')); -teacherApp.get('/location', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 2; ++i) { - req.result.push({ - id: i, - name: id2str.location(i) - }); - }; - next(); -}, response('location')); - -teacherApp.get('/rural_location', (req, res, next) => { - req.result = []; - for (let i = 1; i <= 8; i++) { - req.result.push({ - id: i, - name: id2str.ruralLocation(i) - }); - }; - next(); -}, response('rural_location')); - teacherApp.get('/education_type', (req, res, next) => { req.sql.from('docente') .field('DISTINCT nivel_tipo_formacao', 'id') -- GitLab From a79c0e6e3ea0b3ec1c893afa1d3758fac5f2dcac Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Wed, 11 May 2022 10:47:22 -0300 Subject: [PATCH 137/305] removing 'cache' parameters from new subroutes --- src/libs/routes/class.js | 4 ++-- src/libs/routes/employees.js | 4 ++-- src/libs/routes/enrollment.js | 4 ++-- src/libs/routes/teacher.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index e24b1b48..678bfbd3 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -68,7 +68,7 @@ classApp.get('/source', (req, res, next) => { next(); }, query, response('source')); -classApp.get('/location', cache('15 day'), (req, res, next) => { +classApp.get('/location', (req, res, next) => { req.result = [ {id: 1, name: 'Urbana'}, {id: 2, name: 'Rural'} @@ -76,7 +76,7 @@ classApp.get('/location', cache('15 day'), (req, res, next) => { next(); }, response('location')); -classApp.get('/diff_location', cache('15 day'), (req, res, next) => { +classApp.get('/diff_location', (req, res, next) => { req.result = [ {id: 0, name: "A escola não está em localidade diferenciada"}, {id: 1, name: "Área de assentamento"}, diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js index 8fbcd2a1..d0cce903 100644 --- a/src/libs/routes/employees.js +++ b/src/libs/routes/employees.js @@ -70,7 +70,7 @@ employeesApp.get('/source', (req, res, next) => { next(); }, query, response('source')); -employeesApp.get('/location', cache('15 day'), (req, res, next) => { +employeesApp.get('/location', (req, res, next) => { req.result = [ {id: 1, name: 'Urbana'}, {id: 2, name: 'Rural'} @@ -78,7 +78,7 @@ employeesApp.get('/location', cache('15 day'), (req, res, next) => { next(); }, response('location')); -employeesApp.get('/diff_location', cache('15 day'), (req, res, next) => { +employeesApp.get('/diff_location', (req, res, next) => { req.result = [ {id: 0, name: "A escola não está em localidade diferenciada"}, {id: 1, name: "Área de assentamento"}, diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index d749336d..a66c3cec 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -68,7 +68,7 @@ enrollmentApp.get('/source', (req, res, next) => { next(); }, query, response('source')); -enrollmentApp.get('/location', cache('15 day'), (req, res, next) => { +enrollmentApp.get('/location', (req, res, next) => { req.result = [ {id: 1, name: 'Urbana'}, {id: 2, name: 'Rural'} @@ -76,7 +76,7 @@ enrollmentApp.get('/location', cache('15 day'), (req, res, next) => { next(); }, response('location')); -enrollmentApp.get('/diff_location', cache('15 day'), (req, res, next) => { +enrollmentApp.get('/diff_location', (req, res, next) => { req.result = [ {id: 0, name: "A escola não está em localidade diferenciada"}, {id: 1, name: "Área de assentamento"}, diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 70580e09..f4494edd 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -67,7 +67,7 @@ teacherApp.get('/source', (req, res, next) => { next(); }, query, response('source')); -teacherApp.get('/location', cache('15 day'), (req, res, next) => { +teacherApp.get('/location', (req, res, next) => { req.result = [ {id: 1, name: 'Urbana'}, {id: 2, name: 'Rural'} @@ -75,7 +75,7 @@ teacherApp.get('/location', cache('15 day'), (req, res, next) => { next(); }, response('location')); -teacherApp.get('/diff_location', cache('15 day'), (req, res, next) => { +teacherApp.get('/diff_location', (req, res, next) => { req.result = [ {id: 0, name: "A escola não está em localidade diferenciada"}, {id: 1, name: "Área de assentamento"}, -- GitLab From ed46fe56504c21d61d4dc4346f413d44a3a52c66 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Wed, 11 May 2022 10:54:10 -0300 Subject: [PATCH 138/305] adding diff_location filters --- src/libs/routes/employees.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js index d0cce903..dc8406ca 100644 --- a/src/libs/routes/employees.js +++ b/src/libs/routes/employees.js @@ -428,6 +428,16 @@ rqfTeacher.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: '@', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id_par', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'rural_location', table: '@', -- GitLab From ed610b3f5b693584427470aac2f4ccc0a97f1179 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Wed, 11 May 2022 11:16:21 -0300 Subject: [PATCH 139/305] changing route return --- src/libs/middlewares/id2str.js | 2 +- src/libs/routes/class.js | 2 +- src/libs/routes/employees.js | 4 ++-- src/libs/routes/enrollment.js | 2 +- src/libs/routes/school.js | 4 ++-- src/libs/routes/teacher.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index 80086152..7b5ff18e 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -177,7 +177,7 @@ const ids = { enrolled_vacancies_freshmen: enrolledVacanciesFreshmen, enter_situation: enterSituation, enrollment_situation: enrollmentSituation, - diff_location_id_par: diffLocation + diff_location_id: diffLocation }; function transform(removeId=false) { diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index 678bfbd3..cf8afac0 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -272,7 +272,7 @@ rqfCount.addField({ name: 'diff_location', table: 'turma', tableField: 'localizacao_diferenciada_par', - resultField: 'diff_location_id_par', + resultField: 'diff_location_id', where: { relation: '=', type: 'integer', diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js index dc8406ca..7596eab1 100644 --- a/src/libs/routes/employees.js +++ b/src/libs/routes/employees.js @@ -252,7 +252,7 @@ rqfSchool.addField({ name: 'diff_location', table: '@', tableField: 'localizacao_diferenciada_par', - resultField: 'diff_location_id_par', + resultField: 'diff_location_id', where: { relation: '=', type: 'integer', @@ -432,7 +432,7 @@ rqfTeacher.addField({ name: 'diff_location', table: '@', tableField: 'localizacao_diferenciada_par', - resultField: 'diff_location_id_par', + resultField: 'diff_location_id', where: { relation: '=', type: 'integer', diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index a66c3cec..3d2f32d3 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -498,7 +498,7 @@ rqf.addField({ name: 'diff_location', table: 'matricula', tableField: 'localizacao_diferenciada_par', - resultField: 'diff_location_id_par', + resultField: 'diff_location_id', where: { relation: '=', type: 'integer', diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index 1101d355..f918b429 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -296,7 +296,7 @@ rqf.addField({ name: 'diff_location', table: 'escola', tableField: 'localizacao_diferenciada_par', - resultField: 'diff_location_id_par', + resultField: 'diff_location_id', where: { relation: '=', type: 'integer', @@ -441,7 +441,7 @@ rqfCount.addField({ name: 'diff_location', table: 'escola', tableField: 'localizacao_diferenciada_par', - resultField: 'diff_location_id_par', + resultField: 'diff_location_id', where: { relation: '=', type: 'integer', diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index f4494edd..86bcf184 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -416,7 +416,7 @@ rqf.addField({ name: 'diff_location', table: 'docente', tableField: 'localizacao_diferenciada_par', - resultField: 'diff_location_id_par', + resultField: 'diff_location_id', where: { relation: '=', type: 'integer', -- GitLab From 613e743bb9d5061e6054762b8e260f5c84d5d38f Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Wed, 11 May 2022 12:01:23 -0300 Subject: [PATCH 140/305] adding new diff_location to auxiliar route --- src/libs/routes/auxiliar.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/libs/routes/auxiliar.js b/src/libs/routes/auxiliar.js index 08a910e5..51ff543e 100644 --- a/src/libs/routes/auxiliar.js +++ b/src/libs/routes/auxiliar.js @@ -101,27 +101,22 @@ auxiliarApp.get('/adm_dependency', (req, res, next) => { }, response('adm_dependency')); auxiliarApp.get('/location', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 2; ++i) { - req.result.push({ - id: i, - name: id2str.location(i) - }); - }; + req.result = [ + {id: 1, name: 'Urbana'}, + {id: 2, name: 'Rural'} + ]; next(); }, response('location')); -auxiliarApp.get('/rural_location', (req, res, next) => { +auxiliarApp.get('/diff_location', (req, res, next) => { req.result = [ - {id: 1, name: "Urbana"}, - {id: 2, name: "Rural"}, - {id: 3, name: "Rural - Área de assentamento"}, - {id: 4, name: "Rural - Terra indígena"}, - {id: 5, name: "Rural - Área remanescente de quilombos"}, - {id: 6, name: "Rural - Unidade de uso sustentável"} + {id: 0, name: "A escola não está em localidade diferenciada"}, + {id: 1, name: "Área de assentamento"}, + {id: 2, name: "Terra indígena"}, + {id: 3, name: "Terra remanescente de quilombos"}, ]; next(); -}, response('rural_location')); +}, response('diff_location')); auxiliarApp.get('/education_level_mod', (req, res, next) => { req.result = []; @@ -316,6 +311,16 @@ rqf.addField({ type: 'integer', field: 'localizacao_id' } +}).addValue({ + name: 'diff_location', + table: 'docente', + tableField: 'localizacao_diferenciada_par', + resultField: 'diff_location_id', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_diferenciada_par' + } }).addValue({ name: 'min_year', table: 'docente', -- GitLab From 981985c0aedc0da0dca9339c4a9bddfc570fa6c9 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 12 May 2022 09:35:43 -0300 Subject: [PATCH 141/305] add period_not as filter to class and enrollment --- src/libs/routes/class.js | 10 ++++++++++ src/libs/routes/enrollment.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index cf8afac0..80e12a1c 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -368,6 +368,16 @@ rqfCount.addField({ foreign: ['escola_id', 'ano_censo'], foreignTable: 'turma' } +}, 'filter').addValueToField({ + name: 'period_not', + table: 'turma', + tableField: 'turma_turno_id', + resultField: 'period_id', + where: { + relation: '<>', + type: 'integer', + field: 'turma_turno_id' + } }, 'filter'); diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 3d2f32d3..f9fd7137 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -594,7 +594,7 @@ rqf.addField({ type: 'boolean', field: 'exclusiva_especial' } -}).addValue({ +}).addValueToField({ name: 'period_not', table: 'matricula', tableField: 'turma_turno_id', @@ -604,7 +604,7 @@ rqf.addField({ type: 'integer', field: 'turma_turno_id' } -}); +}, 'filter'); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { req.sql.field('COUNT(*)', 'total') -- GitLab From 6c0ada5664733e74053ffc96536aee629d905f65 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 12 May 2022 11:28:58 -0300 Subject: [PATCH 142/305] add addmissing and remove logs --- src/libs/routes/employees.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js index 7596eab1..e1b954ae 100644 --- a/src/libs/routes/employees.js +++ b/src/libs/routes/employees.js @@ -598,7 +598,6 @@ employeesApp.get('/', rqfSchool.parse(), (req, res, next) => { }, rqfSchool.build(), query, rqfSchool.parse(), id2str.transform(), (req, res, next) => { req.allTeacher = req.result; - console.log("resultado employees", req.allTeacher) req.resetSql(); if ("function" in req.dims) { req.sql.field('SUM(CASE WHEN escola.qt_prof_admin = 88888 THEN 0 ELSE escola.qt_prof_admin END)', 'qtde_admin') @@ -632,9 +631,8 @@ employeesApp.get('/', rqfSchool.parse(), (req, res, next) => { } next(); -}, rqfSchool.build(), query, rqfSchool.parse(), id2str.transform(), (req, res, next) => { +}, rqfSchool.build(), query, rqfSchool.parse(), id2str.transform(), addMissing(rqfSchool), (req, res, next) => { - console.log("resultado employees2", req.allTeacher) if ("function" in req.dims) { let aux_employes = formatFunction(req.result, req.dims); req.allTeacher = formatFunction(req.allTeacher, req.dims); -- GitLab From b17087998f835f823258eebed0e74b385a27125e Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 12 May 2022 09:23:05 -0300 Subject: [PATCH 143/305] [wip] Separate teacher percentages --- src/libs/routes/classroomCount.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 15a0f7ee..5c77b66b 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -515,6 +515,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { obj.school_id = classroom.school_id, obj.school_name = classroom.school_name } + if (req.teacherCalc) + obj.percentage_teacher_career = []; obj.locations = [] // Inserimos a localidade no array de locations da sala @@ -530,6 +532,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentClassroomObj = null; if( !hashSet.has(hash) ) { // Nunca passou por esse município/escola if (result[result.length - 1] !== undefined) { // Após mudar de cidade, passamos pela cidade anterior e juntamos o valor to_be_built de localizações com o mesmo id + let last_city = result[result.length - 1] let last_locations = result[result.length - 1].locations for (let i = 0; i < last_locations.length - 1; i++) { if (last_locations[i].location_id === last_locations[i+1].location_id) { @@ -542,7 +545,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { last_locations[i].total_classroom_be_built = (last_locations[i].total_classroom_be_built < 0) ? 0 : last_locations[i].total_classroom_be_built; } - if (req.teacherCalc) executeTeacherCalc(last_locations, ti); + if (req.teacherCalc) executeTeacherCalc(last_city, ti); } hashSet.add(hash); result.push(obj); @@ -777,6 +780,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { // Tratamento do último resultado, para remover double location, tirar negativo do to_be_built. if (result[result.length - 1] !== undefined) { // Após mudar de cidade, passamos pela cidade anterior e juntamos o valor to_be_built de localizações com o mesmo id + let last_city = result[result.length - 1] let last_locations = result[result.length - 1].locations for (let i = 0; i < last_locations.length - 1; i++) { if (last_locations[i].location_id === last_locations[i+1].location_id) { @@ -789,7 +793,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { last_locations[i].total_classroom_be_built = (last_locations[i].total_classroom_be_built < 0) ? 0 : last_locations[i].total_classroom_be_built; } - if (req.teacherCalc) executeTeacherCalc(last_locations, ti); + if (req.teacherCalc) executeTeacherCalc(last_city, ti); } } @@ -958,6 +962,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ++l; } } + // Reinicia vetor percentage_teacher_career e calcula porcentagens pelos totais currentLocation.total_classroom += cityLocation.total_classroom; currentLocation.total_classroom_be_built += cityLocation.total_classroom_be_built; @@ -982,7 +987,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { req.result = reduction || result; - function executeTeacherCalc(lastLocations, index) { + function executeTeacherCalc(lastCity, index) { + let lastLocations = lastCity.locations let teacherByFormation = []; // Vetor com a porcentagem de professores por formação. let teacherTotal = req.teacher[index].total; @@ -1010,6 +1016,14 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { teacherByFormation[1] += teacherByFormation[0] teacherByFormation[0] = 0 + // Cria vetor de porcentagens de carreira dos professores + req.teacherFormation.forEach((formation, i) => { + lastCity.percentage_teacher_career.push({ + formation_level_id: formation.idFormationLevel, + percentage: (teacherByFormation[i]*100).toFixed(2), + }) + }); + lastLocations.forEach((location) => { location.education_level.forEach((educationLevel) => { let educationLevelId = educationLevel.education_level_short_id; -- GitLab From ab7957b6022eaa3e72b56abdf312b19d48cb8bf2 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Tue, 17 May 2022 12:05:55 -0300 Subject: [PATCH 144/305] [wip] start dealing with reduction of percentages --- src/libs/routes/classroomCount.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 5c77b66b..c258ba03 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -808,7 +808,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let city = result[i]; let obj = { year: city.year, - name: city.name + name: city.name, + count: 1 } if(req.dims.state) { @@ -828,6 +829,16 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { currentObj = obj; } else { // Está ordenado, podemos pegar o último currentObj = reduction[reduction.length - 1]; + currentObj.count++; + } + + if (currentObj.count == 1) + currentObj.percentage_teacher_career = city.percentage_teacher_career + else { + // Incrementa valores percentuais de cada nivel de carreira no objeto atual + currentObj.percentage_teacher_career.forEach((item, ind, thisArr) => { + thisArr[ind].percentage += city.percentage_teacher_career[ind].percentage + }) } // Fazer "merge" do array locations da cidade com o da agregação @@ -974,6 +985,10 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ++i; } for (let state of reduction){ + state.percentage_teacher_career.forEach((item, ind, thisArr) => { + thisArr[ind] /= state.count; + }) + delete state.count for (let location of state.locations){ for (let educationLevel of location.education_level){ let total = educationLevel.enrollment.integral_time_total; -- GitLab From 6cac716bc28d0d096e43b6fd63f44f91328ba739 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <pietro.polinari@gmail.com> Date: Thu, 19 May 2022 10:15:52 -0300 Subject: [PATCH 145/305] [wip] fix negative percentages and string format --- src/libs/routes/classroomCount.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index c258ba03..27ff6e86 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -1023,19 +1023,24 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { for (let value of teacherByFormation) { sum += value; } + teacherByFormation[1] += teacherByFormation[0] + teacherByFormation[0] = 0 + let diff = 1 - sum; - // Se for menor/maior que 100 soma/subtrai na P2 + + // Se soma de porcentagens for menor/maior que 100, faz correção if (Math.abs(diff) > 0.0001) { - teacherByFormation[1] += diff; + // Garante que a porcentagem corrigida não ficará negativa + let indDiff = 1; + while (teacherByFormation[indDiff] + diff < 0) indDiff++; + teacherByFormation[indDiff] += diff; } - teacherByFormation[1] += teacherByFormation[0] - teacherByFormation[0] = 0 // Cria vetor de porcentagens de carreira dos professores req.teacherFormation.forEach((formation, i) => { lastCity.percentage_teacher_career.push({ formation_level_id: formation.idFormationLevel, - percentage: (teacherByFormation[i]*100).toFixed(2), + percentage: Number((teacherByFormation[i]*100).toFixed(2)), }) }); -- GitLab From d77bd121df7a401193e182eae0ab5be6117c9bde Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <pietro.polinari@gmail.com> Date: Thu, 19 May 2022 10:57:27 -0300 Subject: [PATCH 146/305] Fix result calculations for state and country --- src/libs/routes/classroomCount.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 27ff6e86..458117db 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -816,9 +816,9 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { obj.state_id = city.state_id; obj.state_name = city.state_name; } - + obj.percentage_teacher_career = [] obj.locations = []; - + let hash = '' + city.year; if(req.dims.state) hash += '' + city.state_id; @@ -986,7 +986,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } for (let state of reduction){ state.percentage_teacher_career.forEach((item, ind, thisArr) => { - thisArr[ind] /= state.count; + thisArr[ind].percentage = Number((thisArr[ind].percentage / state.count).toFixed(2)) }) delete state.count for (let location of state.locations){ -- GitLab From c3a1aebbda8a4386bcd63e078cfab3d21465d98a Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <pietro.polinari@gmail.com> Date: Mon, 6 Jun 2022 14:32:12 -0300 Subject: [PATCH 147/305] add sum_suitable and sum_total parameters --- src/libs/routes/disciplines.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index d43d8d31..217626aa 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -633,18 +633,30 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { let objNotSuitable = { total: parseInt(r.total) - parseInt(r.total_suitable), suitable: 0, - discipline_name: 'Formação não adequada' + discipline_name: 'Formação não adequada', + sum_total: 0, + sum_suitable: 0 } let objSuitable = { total: parseInt(r.total_suitable), suitable: 1, - discipline_name: 'Formação adequada' + discipline_name: 'Formação adequada', + sum_total: 0, + sum_suitable: 0 } Object.keys(r).forEach(k => { if (k !== 'total' && k !== 'total_suitable') { objNotSuitable[k] = r[k]; objSuitable[k] = r[k]; + if (/^total_suitable/.test(k)){ // if k starts with total_suitable + objSuitable.sum_suitable += parseInt(r[k]); + objNotSuitable.sum_suitable += parseInt(r[k]); + } + else if (/^total_/.test(k)){ + objSuitable.sum_total += parseInt(r[k]); + objNotSuitable.sum_total += parseInt(r[k]); + } } }) @@ -658,3 +670,4 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { module.exports = disciplinesApp; + -- GitLab From 7fc525133f136e21f909a70b02e8f14974a1ed3f Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Tue, 7 Jun 2022 09:26:23 -0300 Subject: [PATCH 148/305] remove sums from consult without dim --- src/libs/routes/disciplines.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 217626aa..3fde7c6e 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -634,21 +634,25 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { total: parseInt(r.total) - parseInt(r.total_suitable), suitable: 0, discipline_name: 'Formação não adequada', - sum_total: 0, - sum_suitable: 0 } let objSuitable = { total: parseInt(r.total_suitable), suitable: 1, discipline_name: 'Formação adequada', - sum_total: 0, - sum_suitable: 0 - } + } Object.keys(r).forEach(k => { - if (k !== 'total' && k !== 'total_suitable') { - objNotSuitable[k] = r[k]; + if (k !== 'total' && k !== 'total_suitable') { + objNotSuitable[k] = r[k]; objSuitable[k] = r[k]; + } + }) + if ('discipline' in req.dims){ + objNotSuitable["sum_total"] = 0; + objNotSuitable["sum_suitable"] = 0; + objSuitable["sum_total"] = 0; + objSuitable["sum_suitable"] = 0; + Object.keys(r).forEach(k => { if (/^total_suitable/.test(k)){ // if k starts with total_suitable objSuitable.sum_suitable += parseInt(r[k]); objNotSuitable.sum_suitable += parseInt(r[k]); @@ -657,8 +661,8 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { objSuitable.sum_total += parseInt(r[k]); objNotSuitable.sum_total += parseInt(r[k]); } - } - }) + }) + } disciplinesNotSuitable.push(objNotSuitable) disciplinesSuitable.push(objSuitable) -- GitLab From 2b2f35f1f174be1d5e16297208f93a666ae7d2ab Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Tue, 7 Jun 2022 11:18:44 -0300 Subject: [PATCH 149/305] add sum parameters to dim disciplines --- src/libs/routes/disciplines.js | 54 ++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 3fde7c6e..0d491d79 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -460,6 +460,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { if ('discipline' in req.dims) { // delete req.filter.discipline; delete req.dims.discipline; + req.tmp_discipline = true; req.sql.field('SUM(n_disc)', 'total') .field('SUM(n_disc_adequada)', 'total_suitable') @@ -630,40 +631,41 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { let disciplinesSuitable = []; req.result.forEach((r) => { - let objNotSuitable = { - total: parseInt(r.total) - parseInt(r.total_suitable), - suitable: 0, - discipline_name: 'Formação não adequada', - } - let objSuitable = { - total: parseInt(r.total_suitable), - suitable: 1, - discipline_name: 'Formação adequada', + let obj = { + sum_total: 0, + sum_suitable: 0 } + Object.keys(r).forEach(k => { - if (k !== 'total' && k !== 'total_suitable') { - objNotSuitable[k] = r[k]; - objSuitable[k] = r[k]; - } + if (k !== 'total' && k !== 'total_suitable') + obj[k] = r[k]; }) - if ('discipline' in req.dims){ - objNotSuitable["sum_total"] = 0; - objNotSuitable["sum_suitable"] = 0; - objSuitable["sum_total"] = 0; - objSuitable["sum_suitable"] = 0; + + if (req.tmp_discipline){ Object.keys(r).forEach(k => { - if (/^total_suitable/.test(k)){ // if k starts with total_suitable - objSuitable.sum_suitable += parseInt(r[k]); - objNotSuitable.sum_suitable += parseInt(r[k]); - } - else if (/^total_/.test(k)){ - objSuitable.sum_total += parseInt(r[k]); - objNotSuitable.sum_total += parseInt(r[k]); - } + if (/^total_suitable/.test(k)) // if k starts with total_suitable + obj.sum_suitable += parseInt(r[k]); + else if (/^total_/.test(k)) + obj.sum_total += parseInt(r[k]); }) + } else { + delete obj.sum_total; + delete obj.sum_suitable; } + let objNotSuitable = Object.assign({}, { + total: parseInt(r.total) - parseInt(r.total_suitable), + suitable: 0, + discipline_name: 'Formação não adequada', + }, obj) + + let objSuitable = Object.assign({}, { + total: parseInt(r.total_suitable), + suitable: 1, + discipline_name: 'Formação adequada', + }, obj) + disciplinesNotSuitable.push(objNotSuitable) disciplinesSuitable.push(objSuitable) }) -- GitLab From fdcb79d44791a598604f954a9f38319e4538da02 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 9 Jun 2022 12:02:58 -0300 Subject: [PATCH 150/305] Fix bug integral_time --- src/libs/routes/dailyChargeAmount.js | 2 +- src/libs/routes/enrollment.js | 2 +- src/libs/routes/school.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/dailyChargeAmount.js b/src/libs/routes/dailyChargeAmount.js index 4af6cb7d..0c1fd0c7 100644 --- a/src/libs/routes/dailyChargeAmount.js +++ b/src/libs/routes/dailyChargeAmount.js @@ -326,7 +326,7 @@ rqf.addField({ resultField: 'integral_time_id', where: { relation: '=', - type: 'boolean', + type: 'integer', field: 'tempo_integral' } }).addValue({ diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index f9fd7137..302d3186 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -571,7 +571,7 @@ rqf.addField({ resultField: 'integral_time_id', where: { relation: '=', - type: 'boolean', + type: 'integer', field: 'tempo_integral' } }).addValue({ diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index f918b429..3752e0fa 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -504,7 +504,7 @@ rqfCount.addField({ resultField: 'integral_time_id', where: { relation: '=', - type: 'boolean', + type: 'integer', field: 'tempo_integral' } }).addValue({ -- GitLab From 35fb72ac8b1f9717b5aa158a92c0c8bf4eca9467 Mon Sep 17 00:00:00 2001 From: Pietro Cavassin <ppc19@inf.ufpr.br> Date: Fri, 10 Jun 2022 14:35:33 +0000 Subject: [PATCH 151/305] Revert "Merge branch 'jpko19' into 'homologa'" This reverts merge request !291 --- src/libs/routes/dailyChargeAmount.js | 2 +- src/libs/routes/enrollment.js | 2 +- src/libs/routes/school.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/dailyChargeAmount.js b/src/libs/routes/dailyChargeAmount.js index 0c1fd0c7..4af6cb7d 100644 --- a/src/libs/routes/dailyChargeAmount.js +++ b/src/libs/routes/dailyChargeAmount.js @@ -326,7 +326,7 @@ rqf.addField({ resultField: 'integral_time_id', where: { relation: '=', - type: 'integer', + type: 'boolean', field: 'tempo_integral' } }).addValue({ diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 302d3186..f9fd7137 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -571,7 +571,7 @@ rqf.addField({ resultField: 'integral_time_id', where: { relation: '=', - type: 'integer', + type: 'boolean', field: 'tempo_integral' } }).addValue({ diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index 3752e0fa..f918b429 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -504,7 +504,7 @@ rqfCount.addField({ resultField: 'integral_time_id', where: { relation: '=', - type: 'integer', + type: 'boolean', field: 'tempo_integral' } }).addValue({ -- GitLab From 8dfbd02a6b63a5e35a4677b684ead07fe637b953 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <pietro.polinari@gmail.com> Date: Mon, 6 Jun 2022 14:17:13 -0300 Subject: [PATCH 152/305] classroom_count calculations by education level change classroom count calculation --- src/libs/routes/classroomCount.js | 38 ++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 458117db..03dd1422 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -1050,8 +1050,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeachingHours = req.teachingHours[educationLevelId-1].shifts; - let journey = req.teacherJourney.journeyTotal * req.teacherJourney.journeyWithInteraction/100; - if(educationLevelId === 1) { // Devido a divisão da creche é necessário tratá-la separadamente. educationLevel.classes_school_year.forEach((schoolYear) => { // Aplicamos os cálculos para os anos da creche let teachingTimeFullPeriod = schoolYear.full_period_classes * currentTeachingHours[2].value * req.schoolDays[educationLevelId-1].value; @@ -1060,9 +1058,23 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeacherByClass = (location.location_id === 1) ? req.educationSchoolYear[schoolYear.school_year_id].teacherByClass.urban : req.educationSchoolYear[schoolYear.school_year_id].teacherByClass.country; - let numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2)); + let numberOfTeacherFullPeriod = 0; + let numberOfTeacherNight = 0; + let numberOfTeacherDay = 0; + lastCity.percentage_teacher_career.forEach(career => { + let journeyObj = req.teacherFormation.find(formation => formation.idFormationLevel === career.formation_level_id) + let journey = journeyObj.journeyWithInteraction/100 * journeyObj.journeyTotal; + numberOfTeacherFullPeriod += (teachingTimeFullPeriod / journey) * currentTeacherByClass * career.percentage; + numberOfTeacherNight += (teachingTimeNight / journey) * currentTeacherByClass * career.percentage; + numberOfTeacherDay += (teachingTimeDay / journey) * currentTeacherByClass * career.percentage; + }) + numberOfTeacherFullPeriod = parseFloat(numberOfTeacherFullPeriod.toFixed(2)); + numberOfTeacherNight = parseFloat(numberOfTeacherNight.toFixed(2)); + numberOfTeacherDay = parseFloat(numberOfTeacherDay.toFixed(2)); + + // numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2)); + // numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2)); + // numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2)); schoolYear.teacherNumber = { total_teacher : numberOfTeacherDay + numberOfTeacherNight + numberOfTeacherFullPeriod, @@ -1150,9 +1162,19 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeacherByClass = (location.location_id === 1) ? req.educationSchoolYear[educationLevelId].teacherByClass.urban : req.educationSchoolYear[educationLevelId].teacherByClass.country; - let numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2)); + let numberOfTeacherFullPeriod = 0; + let numberOfTeacherNight = 0; + let numberOfTeacherDay = 0; + lastCity.percentage_teacher_career.forEach(career => { + let journeyObj = req.teacherFormation.find(formation => formation.idFormationLevel === career.formation_level_id) + let journey = journeyObj.journeyWithInteraction/100 * journeyObj.journeyTotal; + numberOfTeacherFullPeriod += (teachingTimeFullPeriod / journey) * currentTeacherByClass * career.percentage; + numberOfTeacherNight += (teachingTimeNight / journey) * currentTeacherByClass * career.percentage; + numberOfTeacherDay += (teachingTimeDay / journey) * currentTeacherByClass * career.percentage; + }) + numberOfTeacherFullPeriod = parseFloat(numberOfTeacherFullPeriod.toFixed(2)); + numberOfTeacherNight = parseFloat(numberOfTeacherNight.toFixed(2)); + numberOfTeacherDay = parseFloat(numberOfTeacherDay.toFixed(2)); educationLevel.teacherNumber = { total_teacher : numberOfTeacherDay + numberOfTeacherNight + numberOfTeacherFullPeriod, -- GitLab From a95d9ad73055c2d060ba25362d82edc6ac798db5 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 20 Jun 2022 11:15:48 -0300 Subject: [PATCH 153/305] change mail options --- config.json.example | 42 +++++++++++++++++++++++++---------- src/libs/middlewares/email.js | 5 +++-- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/config.json.example b/config.json.example index 20ed3f1c..ff5bae90 100644 --- a/config.json.example +++ b/config.json.example @@ -34,10 +34,16 @@ } }, "email": { - "port": 25, - "host": "mx.c3sl.ufpr.br", - "secure": false, - "ignoreTLS": true, + host: "SMTP.office365.com", + port: 587, + secureConnection: false, + auth: { + user: "dadoseducacionais@ufpr.br", + pass: "COLOCAR_A_SENHA_AQUI", + }, + tls: { + ciphers: 'SSLv3' + } "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, "security": { @@ -80,10 +86,16 @@ } }, "email": { - "port": 25, - "host": "mx.c3sl.ufpr.br", - "secure": false, - "ignoreTLS": true, + host: "SMTP.office365.com", + port: 587, + secureConnection: false, + auth: { + user: "dadoseducacionais@ufpr.br", + pass: "COLOCAR_A_SENHA_AQUI", + }, + tls: { + ciphers: 'SSLv3' + } "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, "security": { @@ -126,10 +138,16 @@ } }, "email": { - "port": 25, - "host": "mx.c3sl.ufpr.br", - "secure": false, - "ignoreTLS": true, + host: "SMTP.office365.com", + port: 587, + secureConnection: false, + auth: { + user: "dadoseducacionais@ufpr.br", + pass: "COLOCAR_A_SENHA_AQUI", + }, + tls: { + ciphers: 'SSLv3' + } "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, "security": { diff --git a/src/libs/middlewares/email.js b/src/libs/middlewares/email.js index 2065dacb..4d1d5171 100644 --- a/src/libs/middlewares/email.js +++ b/src/libs/middlewares/email.js @@ -7,8 +7,9 @@ const htmlToText = require('nodemailer-html-to-text').htmlToText; let transporter = nodemailer.createTransport({ host: config.email.host, port: config.email.port, - secure: config.email.secure, - ignoreTLS: config.email.ignoreTLS + secureConnection: config.email.secureConnection, + auth: config.email.auth, + tls: config.email.tls, }); transporter.use('compile', htmlToText()); -- GitLab From 5c6842cd6c3b67349146722a037c5af582d2b60c Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 20 Jun 2022 11:32:58 -0300 Subject: [PATCH 154/305] fix json error --- config.json.example | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/config.json.example b/config.json.example index ff5bae90..d07db308 100644 --- a/config.json.example +++ b/config.json.example @@ -34,15 +34,15 @@ } }, "email": { - host: "SMTP.office365.com", - port: 587, - secureConnection: false, - auth: { - user: "dadoseducacionais@ufpr.br", - pass: "COLOCAR_A_SENHA_AQUI", + "host": "SMTP.office365.com", + "port": 587, + "secureConnection": false, + "auth": { + "user": "dadoseducacionais@ufpr.br", + "pass": "COLOCAR_A_SENHA_AQUI", }, - tls: { - ciphers: 'SSLv3' + "tls": { + "ciphers": 'SSLv3' } "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, @@ -86,15 +86,15 @@ } }, "email": { - host: "SMTP.office365.com", - port: 587, - secureConnection: false, - auth: { - user: "dadoseducacionais@ufpr.br", - pass: "COLOCAR_A_SENHA_AQUI", + "host": "SMTP.office365.com", + "port": 587, + "secureConnection": false, + "auth": { + "user": "dadoseducacionais@ufpr.br", + "pass": "COLOCAR_A_SENHA_AQUI", }, - tls: { - ciphers: 'SSLv3' + "tls": { + "ciphers": 'SSLv3' } "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, @@ -138,15 +138,15 @@ } }, "email": { - host: "SMTP.office365.com", - port: 587, - secureConnection: false, - auth: { - user: "dadoseducacionais@ufpr.br", - pass: "COLOCAR_A_SENHA_AQUI", + "host": "SMTP.office365.com", + "port": 587, + "secureConnection": false, + "auth": { + "user": "dadoseducacionais@ufpr.br", + "pass": "COLOCAR_A_SENHA_AQUI", }, - tls: { - ciphers: 'SSLv3' + "tls": { + "ciphers": 'SSLv3' } "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, -- GitLab From a0d985f470f1b55ddb1b1fe6ac6d2961c4aeaff4 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Mon, 20 Jun 2022 11:39:05 -0300 Subject: [PATCH 155/305] revert calculation changes --- src/libs/routes/classroomCount.js | 38 +++++++------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 03dd1422..458117db 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -1050,6 +1050,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeachingHours = req.teachingHours[educationLevelId-1].shifts; + let journey = req.teacherJourney.journeyTotal * req.teacherJourney.journeyWithInteraction/100; + if(educationLevelId === 1) { // Devido a divisão da creche é necessário tratá-la separadamente. educationLevel.classes_school_year.forEach((schoolYear) => { // Aplicamos os cálculos para os anos da creche let teachingTimeFullPeriod = schoolYear.full_period_classes * currentTeachingHours[2].value * req.schoolDays[educationLevelId-1].value; @@ -1058,23 +1060,9 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeacherByClass = (location.location_id === 1) ? req.educationSchoolYear[schoolYear.school_year_id].teacherByClass.urban : req.educationSchoolYear[schoolYear.school_year_id].teacherByClass.country; - let numberOfTeacherFullPeriod = 0; - let numberOfTeacherNight = 0; - let numberOfTeacherDay = 0; - lastCity.percentage_teacher_career.forEach(career => { - let journeyObj = req.teacherFormation.find(formation => formation.idFormationLevel === career.formation_level_id) - let journey = journeyObj.journeyWithInteraction/100 * journeyObj.journeyTotal; - numberOfTeacherFullPeriod += (teachingTimeFullPeriod / journey) * currentTeacherByClass * career.percentage; - numberOfTeacherNight += (teachingTimeNight / journey) * currentTeacherByClass * career.percentage; - numberOfTeacherDay += (teachingTimeDay / journey) * currentTeacherByClass * career.percentage; - }) - numberOfTeacherFullPeriod = parseFloat(numberOfTeacherFullPeriod.toFixed(2)); - numberOfTeacherNight = parseFloat(numberOfTeacherNight.toFixed(2)); - numberOfTeacherDay = parseFloat(numberOfTeacherDay.toFixed(2)); - - // numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2)); - // numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2)); - // numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2)); + let numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2)); + let numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2)); + let numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2)); schoolYear.teacherNumber = { total_teacher : numberOfTeacherDay + numberOfTeacherNight + numberOfTeacherFullPeriod, @@ -1162,19 +1150,9 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeacherByClass = (location.location_id === 1) ? req.educationSchoolYear[educationLevelId].teacherByClass.urban : req.educationSchoolYear[educationLevelId].teacherByClass.country; - let numberOfTeacherFullPeriod = 0; - let numberOfTeacherNight = 0; - let numberOfTeacherDay = 0; - lastCity.percentage_teacher_career.forEach(career => { - let journeyObj = req.teacherFormation.find(formation => formation.idFormationLevel === career.formation_level_id) - let journey = journeyObj.journeyWithInteraction/100 * journeyObj.journeyTotal; - numberOfTeacherFullPeriod += (teachingTimeFullPeriod / journey) * currentTeacherByClass * career.percentage; - numberOfTeacherNight += (teachingTimeNight / journey) * currentTeacherByClass * career.percentage; - numberOfTeacherDay += (teachingTimeDay / journey) * currentTeacherByClass * career.percentage; - }) - numberOfTeacherFullPeriod = parseFloat(numberOfTeacherFullPeriod.toFixed(2)); - numberOfTeacherNight = parseFloat(numberOfTeacherNight.toFixed(2)); - numberOfTeacherDay = parseFloat(numberOfTeacherDay.toFixed(2)); + let numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2)); + let numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2)); + let numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2)); educationLevel.teacherNumber = { total_teacher : numberOfTeacherDay + numberOfTeacherNight + numberOfTeacherFullPeriod, -- GitLab From d1494b610a2af0ca3df02551323131137b55a0ec Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Mon, 20 Jun 2022 11:46:21 -0300 Subject: [PATCH 156/305] fix json error --- config.json.example | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/config.json.example b/config.json.example index d07db308..1fa157c1 100644 --- a/config.json.example +++ b/config.json.example @@ -39,11 +39,11 @@ "secureConnection": false, "auth": { "user": "dadoseducacionais@ufpr.br", - "pass": "COLOCAR_A_SENHA_AQUI", + "pass": "COLOCAR_A_SENHA_AQUI" }, "tls": { - "ciphers": 'SSLv3' - } + "ciphers": "SSLv3" + }, "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, "security": { @@ -91,11 +91,11 @@ "secureConnection": false, "auth": { "user": "dadoseducacionais@ufpr.br", - "pass": "COLOCAR_A_SENHA_AQUI", + "pass": "COLOCAR_A_SENHA_AQUI" }, "tls": { - "ciphers": 'SSLv3' - } + "ciphers": "SSLv3" + }, "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, "security": { @@ -143,11 +143,11 @@ "secureConnection": false, "auth": { "user": "dadoseducacionais@ufpr.br", - "pass": "COLOCAR_A_SENHA_AQUI", + "pass": "COLOCAR_A_SENHA_AQUI" }, "tls": { - "ciphers": 'SSLv3' - } + "ciphers": "SSLv3" + }, "from": "\"Laboratório de Dados Educacionais\" <dadoseducacionais@ufpr.br>" }, "security": { -- GitLab From ff21b8a2a3a12cacbd631f55bd5c2c5b1e22e50a Mon Sep 17 00:00:00 2001 From: Pietro Cavassin <ppc19@inf.ufpr.br> Date: Wed, 22 Jun 2022 13:25:59 +0000 Subject: [PATCH 157/305] Update from boolean to integer --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index f9fd7137..302d3186 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -571,7 +571,7 @@ rqf.addField({ resultField: 'integral_time_id', where: { relation: '=', - type: 'boolean', + type: 'integer', field: 'tempo_integral' } }).addValue({ -- GitLab From c1c6ac4cd178a3f9606b7b744eb389c7efac0b6d Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Fri, 24 Jun 2022 11:19:34 -0300 Subject: [PATCH 158/305] Update classroom_count journey calculations --- src/libs/routes/classroomCount.js | 34 +++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 458117db..b36b2fba 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -1050,8 +1050,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeachingHours = req.teachingHours[educationLevelId-1].shifts; - let journey = req.teacherJourney.journeyTotal * req.teacherJourney.journeyWithInteraction/100; - if(educationLevelId === 1) { // Devido a divisão da creche é necessário tratá-la separadamente. educationLevel.classes_school_year.forEach((schoolYear) => { // Aplicamos os cálculos para os anos da creche let teachingTimeFullPeriod = schoolYear.full_period_classes * currentTeachingHours[2].value * req.schoolDays[educationLevelId-1].value; @@ -1060,9 +1058,19 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeacherByClass = (location.location_id === 1) ? req.educationSchoolYear[schoolYear.school_year_id].teacherByClass.urban : req.educationSchoolYear[schoolYear.school_year_id].teacherByClass.country; - let numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2)); + let numberOfTeacherFullPeriod = 0; + let numberOfTeacherNight = 0; + let numberOfTeacherDay = 0; + lastCity.percentage_teacher_career.forEach(career => { + let journeyObj = req.teacherFormation.find(formation => formation.idFormationLevel === career.formation_level_id) + let journey = journeyObj.journeyWithInteraction/100 * journeyObj.journeyTotal; + numberOfTeacherFullPeriod += (teachingTimeFullPeriod / journey) * currentTeacherByClass * career.percentage/100; + numberOfTeacherNight += (teachingTimeNight / journey) * currentTeacherByClass * career.percentage/100; + numberOfTeacherDay += (teachingTimeDay / journey) * currentTeacherByClass * career.percentage/100; + }) + numberOfTeacherFullPeriod = parseFloat(numberOfTeacherFullPeriod.toFixed(2)); + numberOfTeacherNight = parseFloat(numberOfTeacherNight.toFixed(2)); + numberOfTeacherDay = parseFloat(numberOfTeacherDay.toFixed(2)); schoolYear.teacherNumber = { total_teacher : numberOfTeacherDay + numberOfTeacherNight + numberOfTeacherFullPeriod, @@ -1150,9 +1158,19 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeacherByClass = (location.location_id === 1) ? req.educationSchoolYear[educationLevelId].teacherByClass.urban : req.educationSchoolYear[educationLevelId].teacherByClass.country; - let numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2)); + let numberOfTeacherFullPeriod = 0; + let numberOfTeacherNight = 0; + let numberOfTeacherDay = 0; + lastCity.percentage_teacher_career.forEach(career => { + let journeyObj = req.teacherFormation.find(formation => formation.idFormationLevel === career.formation_level_id) + let journey = journeyObj.journeyWithInteraction/100 * journeyObj.journeyTotal; + numberOfTeacherFullPeriod += (teachingTimeFullPeriod / journey) * currentTeacherByClass * career.percentage/100; + numberOfTeacherNight += (teachingTimeNight / journey) * currentTeacherByClass * career.percentage/100; + numberOfTeacherDay += (teachingTimeDay / journey) * currentTeacherByClass * career.percentage/100; + }) + numberOfTeacherFullPeriod = parseFloat(numberOfTeacherFullPeriod.toFixed(2)); + numberOfTeacherNight = parseFloat(numberOfTeacherNight.toFixed(2)); + numberOfTeacherDay = parseFloat(numberOfTeacherDay.toFixed(2)); educationLevel.teacherNumber = { total_teacher : numberOfTeacherDay + numberOfTeacherNight + numberOfTeacherFullPeriod, -- GitLab From cf3f2d103dea8b94ca0b0b3ef3c72c4b3f800ffc Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 30 Jun 2022 08:21:59 -0300 Subject: [PATCH 159/305] school relative solicitations on issue 792 are completed --- src/libs/convert/integralTime.js | 2 +- src/libs/routes/school.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libs/convert/integralTime.js b/src/libs/convert/integralTime.js index 1a1f8d30..44f2abdb 100644 --- a/src/libs/convert/integralTime.js +++ b/src/libs/convert/integralTime.js @@ -25,6 +25,6 @@ module.exports = function integralTime(id) { case 1: return 'Sim'; case 2: - return 'Não se aplica (semi presencial e EaD)'; + return 'Não se aplica - Semi presencial e EaD'; } }; diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index f918b429..1f2c22eb 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -60,7 +60,7 @@ schoolApp.get('/location', cache('15 day'), (req, res, next) => { schoolApp.get('/diff_location', cache('15 day'), (req, res, next) => { req.result = [ - {id: 0, name: "A escola não está em localidade diferenciada"}, + {id: 0, name: "Não está em localidade diferenciada"}, {id: 1, name: "Área de assentamento"}, {id: 2, name: "Terra indígena"}, {id: 3, name: "Terra remanescente de quilombos"}, @@ -70,6 +70,7 @@ schoolApp.get('/diff_location', cache('15 day'), (req, res, next) => { schoolApp.get('/adm_dependency', (req, res, next) => { req.result = []; + for(let i = 1; i <= 4; ++i) { req.result.push({ id: i, @@ -81,7 +82,7 @@ schoolApp.get('/adm_dependency', (req, res, next) => { schoolApp.get('/adm_dependency_detailed', cache('15 day'), (req, res, next) => { req.result = []; - for(let i = 1; i <= 6; ++i) { + for(let i = 1; i <= 8; i++) { req.result.push({ id: i, name: id2str.admDependencyPriv(i) @@ -92,7 +93,7 @@ schoolApp.get('/adm_dependency_detailed', cache('15 day'), (req, res, next) => { schoolApp.get('/government_agreement', cache('15 day'), (req, res, next) => { req.result = []; - for(let i = 1; i <= 6; ++i) { + for(let i = 1; i <= 7; ++i) { req.result.push({ id: i, name: id2str.govermentAgreement(i) -- GitLab From cc78bf9f798663ff7ac2d8c6bb72d29ee053c86d Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Fri, 3 Jun 2022 10:19:37 -0300 Subject: [PATCH 160/305] adding new filter to class component --- src/libs/routes/class.js | 16 +++++++++++----- src/libs/routes/enrollment.js | 12 +++++++----- src/libs/routes/school.js | 12 +++++++----- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index 80e12a1c..da5b43a0 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -118,16 +118,22 @@ classApp.get('/period', (req, res, next) => { name: id2str.period(i) }); } + req.result.push({ + id: 99, + name: id2str.period(99) + }); next(); }, response('period')); // Returns integral-time avaible classApp.get('/integral_time', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Disponível'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; + req.result = []; + for(let i = 0; i <= 2; ++i) { + req.result.push({ + id: i, + name: id2str.integralTime(i) + }); + } next(); }, response('integral_time')); diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 302d3186..844322bd 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -220,11 +220,13 @@ enrollmentApp.get('/period', (req, res, next) => { // Returns integral-time avaible enrollmentApp.get('/integral_time', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Disponível'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; + req.result = []; + for(let i = 0; i <= 2; ++i) { + req.result.push({ + id: i, + name: id2str.integralTime(i) + }); + } next(); }, response('integral_time')); diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index 1f2c22eb..ae1479d5 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -191,11 +191,13 @@ schoolApp.get('/arrangement', cache('15 day'), (req, res, next) => { }, response('arrangement')); schoolApp.get('/integral_time', cache('15 day'), (req, res, next) => { - req.result = [ - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'}, - {id: 2, name: 'Não se aplica - Semipresencial e EaD.'} - ]; + req.result = []; + for(let i = 0; i <= 2; ++i) { + req.result.push({ + id: i, + name: id2str.integralTime(i) + }); + } next(); }, response('integral_time')); -- GitLab From 7a73716ea6f64b3ad0d6169f289fd588786d92c3 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 30 Jun 2022 09:51:30 -0300 Subject: [PATCH 161/305] made some changes for auxiliar and class routes as required on issue 792 --- src/libs/routes/auxiliar.js | 4 ++-- src/libs/routes/class.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/auxiliar.js b/src/libs/routes/auxiliar.js index 51ff543e..ef538961 100644 --- a/src/libs/routes/auxiliar.js +++ b/src/libs/routes/auxiliar.js @@ -80,7 +80,7 @@ auxiliarApp.get('/education_type', (req, res, next) => { auxiliarApp.get('/adm_dependency_detailed', (req, res, next) => { req.result = []; - for(let i = 1; i <= 6; ++i) { + for(let i = 1; i <= 7; ++i) { req.result.push({ id: i, name: id2str.admDependencyPriv(i) @@ -120,7 +120,7 @@ auxiliarApp.get('/diff_location', (req, res, next) => { auxiliarApp.get('/education_level_mod', (req, res, next) => { req.result = []; - for(let i = 1; i <= 11; ++i) { + for(let i = 1; i <= 12; ++i) { req.result.push({ id: i, name: id2str.educationLevelMod(i) diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index 80e12a1c..2cb16084 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -134,7 +134,7 @@ classApp.get('/integral_time', (req, res, next) => { // Returns all educational levels avaible classApp.get('/education_level_mod', (req, res, next) => { req.result = []; - for(let i = 1; i <=11; ++i) { + for(let i = 1; i <=12; ++i) { req.result.push({ id: i, name: id2str.educationLevelMod(i) -- GitLab From de44db3e4c6fea2044bf834bdffde824c0ec5422 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Fri, 1 Jul 2022 11:11:13 -0300 Subject: [PATCH 162/305] change goverment to government --- .../{govermentAgreement.js => governmentAgreement.js} | 4 +++- src/libs/middlewares/id2str.js | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) rename src/libs/convert/{govermentAgreement.js => governmentAgreement.js} (92%) diff --git a/src/libs/convert/govermentAgreement.js b/src/libs/convert/governmentAgreement.js similarity index 92% rename from src/libs/convert/govermentAgreement.js rename to src/libs/convert/governmentAgreement.js index 106a3a72..2037b52a 100644 --- a/src/libs/convert/govermentAgreement.js +++ b/src/libs/convert/governmentAgreement.js @@ -18,8 +18,10 @@ 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 govermentAgreement(id) { +module.exports = function governmentAgreement(id) { switch (id) { + case null: + return "Não classificada" case 1: return 'Convênio com rede Municipal'; case 2: diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index 7b5ff18e..3a0cfe90 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -81,7 +81,7 @@ const teacherSchooling = require(`${libs}/convert/teacherSchooling`); const ethnicGroupTeacherIES = require(`${libs}/convert/ethnicGroupTeacherIES`); const genderIES = require(`${libs}/convert/genderIES`); const deficiency = require(`${libs}/convert/studentDeficiency`); -const govermentAgreement = require(`${libs}/convert/govermentAgreement`); +const governmentAgreement = require(`${libs}/convert/governmentAgreement`); const arrangement = require(`${libs}/convert/arrangement`); const nightTime = require(`${libs}/convert/nightTime`); const discipline = require(`${libs}/convert/discipline`); @@ -110,7 +110,7 @@ const ids = { ethnic_group_id: ethnicGroup, agreement_id: agreement, integral_time_id: integralTime, - government_agreement_id: govermentAgreement, + government_agreement_id: governmentAgreement, education_day_care_child_id: booleanVariable, education_preschool_child_id: booleanVariable, education_begin_elementary_school_id: booleanVariable, @@ -278,7 +278,7 @@ module.exports = { genderIES, deficiency, transport, - govermentAgreement, + governmentAgreement, arrangement, nightTime, discipline, -- GitLab From 0bd497b63153896100060f09a8618bf6a2c6dec1 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Fri, 1 Jul 2022 11:13:57 -0300 Subject: [PATCH 163/305] change goverment to government --- src/libs/routes/school.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index ae1479d5..fb112d9a 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -96,7 +96,7 @@ schoolApp.get('/government_agreement', cache('15 day'), (req, res, next) => { for(let i = 1; i <= 7; ++i) { req.result.push({ id: i, - name: id2str.govermentAgreement(i) + name: id2str.governmentAgreement(i) }); }; next(); -- GitLab From fc8e580540ad45822fd86637943c795d0cc2a19e Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Mon, 4 Jul 2022 09:13:15 -0300 Subject: [PATCH 164/305] modify case null --- src/libs/convert/governmentAgreement.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/convert/governmentAgreement.js b/src/libs/convert/governmentAgreement.js index 2037b52a..b3b502bf 100644 --- a/src/libs/convert/governmentAgreement.js +++ b/src/libs/convert/governmentAgreement.js @@ -20,8 +20,6 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function governmentAgreement(id) { switch (id) { - case null: - return "Não classificada" case 1: return 'Convênio com rede Municipal'; case 2: @@ -34,6 +32,7 @@ module.exports = function governmentAgreement(id) { return 'Privada sem detalhamento'; case 6: return 'Não se aplica (pública)'; + case null: default: return 'Não classificada'; } -- GitLab From 5091b4fccc2da9e5e26c0d0826140ee41ba15798 Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Tue, 5 Jul 2022 10:11:11 -0300 Subject: [PATCH 165/305] fix spacing in contract_type filter --- src/libs/convert/contractType.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/convert/contractType.js b/src/libs/convert/contractType.js index 98ffcb84..5a938a0b 100644 --- a/src/libs/convert/contractType.js +++ b/src/libs/convert/contractType.js @@ -21,7 +21,7 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function contractType(id) { switch (id) { case 1: - return 'Concursado/Efetivo/Estável'; + return 'Concursado/ Efetivo/ Estável'; case 2: return 'Contrato temporário'; case 3: -- GitLab From 82451e9aa123d3cf79ce1c9b447b6b477bd6fdfb Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Tue, 5 Jul 2022 10:12:38 -0300 Subject: [PATCH 166/305] fix spacing in contract_type filter --- src/libs/convert/contractType.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/convert/contractType.js b/src/libs/convert/contractType.js index 98ffcb84..5a938a0b 100644 --- a/src/libs/convert/contractType.js +++ b/src/libs/convert/contractType.js @@ -21,7 +21,7 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function contractType(id) { switch (id) { case 1: - return 'Concursado/Efetivo/Estável'; + return 'Concursado/ Efetivo/ Estável'; case 2: return 'Contrato temporário'; case 3: -- GitLab From 43a8c75ebf5ed8589345aff046d67995577cdaad Mon Sep 17 00:00:00 2001 From: Miguel Salerno <mans17@inf.ufpr.br> Date: Tue, 5 Jul 2022 10:13:20 -0300 Subject: [PATCH 167/305] fix spacing in contract_type filter --- src/libs/convert/contractType.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/convert/contractType.js b/src/libs/convert/contractType.js index 98ffcb84..5a938a0b 100644 --- a/src/libs/convert/contractType.js +++ b/src/libs/convert/contractType.js @@ -21,7 +21,7 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function contractType(id) { switch (id) { case 1: - return 'Concursado/Efetivo/Estável'; + return 'Concursado/ Efetivo/ Estável'; case 2: return 'Contrato temporário'; case 3: -- GitLab From 89d6c006d382a7cc1e9fa8dffe3f0b185b47ffe9 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Tue, 5 Jul 2022 10:51:46 -0300 Subject: [PATCH 168/305] testing database errors --- src/libs/routes/universityEnrollment.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index c938385c..6a223a34 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -819,7 +819,7 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') next() -}, rqf.build(), query, (req, res, 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); @@ -827,8 +827,10 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex res.trancado = Number(res.trancado); res.total = res.cursando + res.concluinte + res.evadido + res.trancado } + next(); }, id2str.transform(), response('enrollmentSituation')); + module.exports = universityEnrollmentApp; \ No newline at end of file -- GitLab From 1fef4aa6d5b6d80ed48af030f0e4fa077a857240 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 6 Jul 2022 11:29:34 -0300 Subject: [PATCH 169/305] always consider school integral time percentage --- src/libs/routes/classroomCount.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index b36b2fba..ef787ddd 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -713,7 +713,9 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } } - let currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, educationLevel.enrollment.integral_percentage); + let currentIntegralOfferGoal = educationLevel.enrollment.integral_percentage; + if (req.dims.school === undefined) currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, currentIntegralOfferGoal); + let currentNumberStudentClass = (enrollment.location_id == 1) ? enrollmentEducationLevel.numberStudentClass.urban : enrollmentEducationLevel.numberStudentClass.country; // Soma os totais de matrícula da etapa de ensino -- GitLab From e16fe9c6146933416e6482709d1772e4c9489919 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 6 Jul 2022 11:44:01 -0300 Subject: [PATCH 170/305] fix total and total_suitable calculations --- src/libs/routes/disciplines.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 0d491d79..05df70b6 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -644,10 +644,14 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { if (req.tmp_discipline){ Object.keys(r).forEach(k => { - if (/^total_suitable/.test(k)) // if k starts with total_suitable + if (/^total_suitable/.test(k)){ // if k starts with total_suitable + console.log("suitable", k, r[k]) obj.sum_suitable += parseInt(r[k]); - else if (/^total_/.test(k)) + } + else if (/^total_/.test(k)){ + console.log("total", k, r[k]) obj.sum_total += parseInt(r[k]); + } }) } else { delete obj.sum_total; -- GitLab From f49e261dda6e8c8d945ccfe0520ec417c1958def Mon Sep 17 00:00:00 2001 From: Pietro Cavassin <ppc19@inf.ufpr.br> Date: Thu, 7 Jul 2022 12:01:25 +0000 Subject: [PATCH 171/305] Remove console.log --- src/libs/routes/disciplines.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 05df70b6..0d491d79 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -644,14 +644,10 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { if (req.tmp_discipline){ Object.keys(r).forEach(k => { - if (/^total_suitable/.test(k)){ // if k starts with total_suitable - console.log("suitable", k, r[k]) + if (/^total_suitable/.test(k)) // if k starts with total_suitable obj.sum_suitable += parseInt(r[k]); - } - else if (/^total_/.test(k)){ - console.log("total", k, r[k]) + else if (/^total_/.test(k)) obj.sum_total += parseInt(r[k]); - } }) } else { delete obj.sum_total; -- GitLab From 5a0f6a6a3298ab4e032a3cf0dd4833a9d21eaad2 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 7 Jul 2022 09:37:02 -0300 Subject: [PATCH 172/305] Correct total calculations --- src/libs/routes/disciplines.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 0d491d79..223baa1d 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -644,9 +644,9 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { if (req.tmp_discipline){ Object.keys(r).forEach(k => { - if (/^total_suitable/.test(k)) // if k starts with total_suitable + if (/^total_suitable_/.test(k)) // if k starts with total_suitable obj.sum_suitable += parseInt(r[k]); - else if (/^total_/.test(k)) + else if (/^total_(?!suitable)/.test(k)) obj.sum_total += parseInt(r[k]); }) } else { -- GitLab From 50aa2968e26cdf3a07b891cfb491c484fe87f16b Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 7 Jul 2022 10:07:20 -0300 Subject: [PATCH 173/305] fix total and total suitable calculations --- src/libs/routes/disciplines.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 0d491d79..223baa1d 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -644,9 +644,9 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { if (req.tmp_discipline){ Object.keys(r).forEach(k => { - if (/^total_suitable/.test(k)) // if k starts with total_suitable + if (/^total_suitable_/.test(k)) // if k starts with total_suitable obj.sum_suitable += parseInt(r[k]); - else if (/^total_/.test(k)) + else if (/^total_(?!suitable)/.test(k)) obj.sum_total += parseInt(r[k]); }) } else { -- GitLab From 1db66865e96f8f8eba9cba0fe36466dda67ddde7 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 7 Jul 2022 10:22:38 -0300 Subject: [PATCH 174/305] all basdic education fixes are done --- src/libs/routes/classroomCount.js | 7 ++++++- src/libs/routes/disciplines.js | 4 ++-- src/libs/routes/universityEnrollment.js | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index b36b2fba..ccd09f79 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -713,7 +713,11 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } } - let currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, educationLevel.enrollment.integral_percentage); + let currentIntegralOfferGoal = educationLevel.enrollment.integral_percentage; + + if (req.dims.school === undefined) currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, currentIntegralOfferGoal); + console.log("dims school", req.dims, currentIntegralOfferGoal, enrollmentEducationLevel.integralTimeOfferGoal) + let currentNumberStudentClass = (enrollment.location_id == 1) ? enrollmentEducationLevel.numberStudentClass.urban : enrollmentEducationLevel.numberStudentClass.country; // Soma os totais de matrícula da etapa de ensino @@ -1233,3 +1237,4 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { }, response('classroom_count')); module.exports = classroomCountApp; + diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 0d491d79..223baa1d 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -644,9 +644,9 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { if (req.tmp_discipline){ Object.keys(r).forEach(k => { - if (/^total_suitable/.test(k)) // if k starts with total_suitable + if (/^total_suitable_/.test(k)) // if k starts with total_suitable obj.sum_suitable += parseInt(r[k]); - else if (/^total_/.test(k)) + else if (/^total_(?!suitable)/.test(k)) obj.sum_total += parseInt(r[k]); }) } else { diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 6a223a34..07e03e4b 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -819,7 +819,7 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex .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) => { +}, 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); @@ -833,4 +833,4 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex -module.exports = universityEnrollmentApp; \ No newline at end of file +module.exports = universityEnrollmentApp; -- GitLab From 01f633ce33389f51e9bc997e7ba8e6be5c84fc05 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Fri, 8 Jul 2022 09:23:15 -0300 Subject: [PATCH 175/305] change pqr choice criterion --- src/libs/routes/classroomCount.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index b36b2fba..ef787ddd 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -713,7 +713,9 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } } - let currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, educationLevel.enrollment.integral_percentage); + let currentIntegralOfferGoal = educationLevel.enrollment.integral_percentage; + if (req.dims.school === undefined) currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, currentIntegralOfferGoal); + let currentNumberStudentClass = (enrollment.location_id == 1) ? enrollmentEducationLevel.numberStudentClass.urban : enrollmentEducationLevel.numberStudentClass.country; // Soma os totais de matrícula da etapa de ensino -- GitLab From e498ba2aab1b19f694b9f5d4eec3c2964be3e97e Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Fri, 8 Jul 2022 11:12:15 -0300 Subject: [PATCH 176/305] fixing turn filter problem --- src/libs/convert/upperTurn.js | 4 +++- src/libs/routes/universityEnrollment.js | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libs/convert/upperTurn.js b/src/libs/convert/upperTurn.js index b5cac83f..d6212bfd 100644 --- a/src/libs/convert/upperTurn.js +++ b/src/libs/convert/upperTurn.js @@ -28,7 +28,9 @@ module.exports = function upperTurn(id) { return 'Noturno'; case 4: return 'Integral'; - default: + case 99: return 'Não aplicavel (Ead)'; + default: + return; } }; diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 07e03e4b..42dce542 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -199,12 +199,16 @@ universityEnrollmentApp.get('/upper_turn', (req, res, next) => { name: id2str.upperTurn(i) }); }; + req,result.push({ + id: 99, + name: id2str.uppeTurn(i) + }) next(); }, response('upper_turn')); universityEnrollmentApp.get('/student_deficiency', (req, res, next) => { req.result = []; - for(let i = 0; i <= 1; ++i) { + for(let i = 0; i <= 2; ++i) { req.result.push({ id: i, name: id2str.studentDeficiency(i) @@ -215,7 +219,7 @@ universityEnrollmentApp.get('/student_deficiency', (req, res, next) => { universityEnrollmentApp.get('/ethnic_group_ies', (req, res, next) => { req.result = []; - for(let i = 1; i <=5; ++i) { + for(let i = 0; i <=5; ++i) { req.result.push({ id: i, name: id2str.ethnicGroupIES(i) @@ -226,7 +230,7 @@ universityEnrollmentApp.get('/ethnic_group_ies', (req, res, next) => { universityEnrollmentApp.get('/school_type', (req, res, next) => { req.result = []; - for(let i = 1; i <= 2; ++i) { + for(let i = 0; i <= 2; ++i) { req.result.push({ id: i, name: id2str.schoolType(i) -- GitLab From 4c9ec40f567be66eff615ba2fffc8d622101d2f0 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 13 Jul 2022 09:13:17 -0300 Subject: [PATCH 177/305] add nao classificada to school --- src/libs/middlewares/reqQueryFields.js | 18 +++++++++++------- src/libs/routes/school.js | 11 +++++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/libs/middlewares/reqQueryFields.js b/src/libs/middlewares/reqQueryFields.js index 36c33d38..330e1709 100644 --- a/src/libs/middlewares/reqQueryFields.js +++ b/src/libs/middlewares/reqQueryFields.js @@ -12,6 +12,11 @@ const nullFields = [ ] function parseWhereValue(type, value, relation) { + if (value == null) + return null; + if (value.toString().toLowerCase() == "null") + return null; + if(type === 'integer') return parseInt(value, 10); if(type === 'double') return parseFloat(value); if(type === 'string' && relation === 'LIKE') return '%'+value+'%'; @@ -21,12 +26,8 @@ function parseWhereValue(type, value, relation) { return value; } if(typeof value === 'string') { - if(value.toLowerCase() === 'true' || value.toLowerCase() === '1') { + if(value.toLowerCase() === 'true' || value.toLowerCase() === '1') return true; - } - if(value.toLowerCase() === 'null') { - return null; - } } return false; } @@ -42,9 +43,12 @@ function getConvertName(whereField){ // TODO: mudar para regex } function isNull(curFilter, value){ + if (value == null) + return true; let convertName = getConvertName(curFilter) - if (id2str[convertName] !== undefined) + if (id2str[convertName] !== undefined){ return nullFields.indexOf(id2str[convertName](value)) > -1 + } return false; } @@ -328,7 +332,7 @@ class ReqQueryFields { for(let i = 0; i < whereValue.length; ++i) { let curRelation = value.where.relation; let curValue = parseWhereValue(value.where.type, whereValue[i],value.where.relation) - if (isNull(k, curValue) ) { + if (isNull(k, curValue)) { curValue = null; curRelation = "is"; } diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index fb112d9a..73b765e2 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -92,8 +92,11 @@ schoolApp.get('/adm_dependency_detailed', cache('15 day'), (req, res, next) => { }, response('adm_dependency_detailed')); schoolApp.get('/government_agreement', cache('15 day'), (req, res, next) => { - req.result = []; - for(let i = 1; i <= 7; ++i) { + req.result = [{ + id: "null", + name: id2str.governmentAgreement("null") + }]; + for(let i = 1; i <= 6; ++i) { req.result.push({ id: i, name: id2str.governmentAgreement(i) @@ -497,8 +500,8 @@ rqfCount.addField({ resultField: 'government_agreement_id', where: { relation: '=', - type: 'boolean', - field: 'conveniada_pp' + type: 'integer', + field: 'dependencia_convenio_publico' } }).addValue({ name: 'integral_time', -- GitLab From 790408ea67b344176058463bc818ab8b4756ed94 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 13 Jul 2022 09:13:51 -0300 Subject: [PATCH 178/305] [wip] handle null values --- src/libs/middlewares/reqQueryFields.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/middlewares/reqQueryFields.js b/src/libs/middlewares/reqQueryFields.js index 330e1709..3648f9cc 100644 --- a/src/libs/middlewares/reqQueryFields.js +++ b/src/libs/middlewares/reqQueryFields.js @@ -43,6 +43,7 @@ function getConvertName(whereField){ // TODO: mudar para regex } function isNull(curFilter, value){ + // TODO: Remove this function if (value == null) return true; let convertName = getConvertName(curFilter) -- GitLab From 741846fe5e4c79977b0d8d82f9799f69171b3ff0 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 13 Jul 2022 09:14:15 -0300 Subject: [PATCH 179/305] add case null --- src/libs/convert/governmentAgreement.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/convert/governmentAgreement.js b/src/libs/convert/governmentAgreement.js index b3b502bf..47576015 100644 --- a/src/libs/convert/governmentAgreement.js +++ b/src/libs/convert/governmentAgreement.js @@ -32,7 +32,7 @@ module.exports = function governmentAgreement(id) { return 'Privada sem detalhamento'; case 6: return 'Não se aplica (pública)'; - case null: + case "null": default: return 'Não classificada'; } -- GitLab From d03045bfbadb8b2f34dcb9c666ad9e114ff51abd Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Wed, 13 Jul 2022 10:02:38 -0300 Subject: [PATCH 180/305] final commit --- src/libs/convert/upperTurn.js | 2 +- src/libs/routes/universityEnrollment.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/convert/upperTurn.js b/src/libs/convert/upperTurn.js index d6212bfd..e5860ee3 100644 --- a/src/libs/convert/upperTurn.js +++ b/src/libs/convert/upperTurn.js @@ -31,6 +31,6 @@ module.exports = function upperTurn(id) { case 99: return 'Não aplicavel (Ead)'; default: - return; + return 'Não classificada'; } }; diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 42dce542..bd47d212 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -198,11 +198,11 @@ universityEnrollmentApp.get('/upper_turn', (req, res, next) => { id: i, name: id2str.upperTurn(i) }); - }; - req,result.push({ + } + req.result.push({ id: 99, - name: id2str.uppeTurn(i) - }) + name: id2str.upperTurn(99) + }); next(); }, response('upper_turn')); @@ -837,4 +837,4 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex -module.exports = universityEnrollmentApp; +module.exports = universityEnrollmentApp; \ No newline at end of file -- GitLab From ae24700ad15672766984370d775dc4666e9533d5 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 13 Jul 2022 10:26:08 -0300 Subject: [PATCH 181/305] remove console log --- src/libs/routes/universityEnrollment.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index bd47d212..58e13e0c 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -198,7 +198,7 @@ universityEnrollmentApp.get('/upper_turn', (req, res, next) => { id: i, name: id2str.upperTurn(i) }); - } + }; req.result.push({ id: 99, name: id2str.upperTurn(99) @@ -823,7 +823,7 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex .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) => { +}, rqf.build(),query, (req, res, next) => { for (var res of req.result){ res.cursando = Number(res.cursando); res.concluinte = Number(res.concluinte); @@ -837,4 +837,5 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex -module.exports = universityEnrollmentApp; \ No newline at end of file +module.exports = universityEnrollmentApp; + -- GitLab From d02048afa327023e7c2bf2656e776445e280c43a Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 13 Jul 2022 11:33:16 -0300 Subject: [PATCH 182/305] remove conflict --- src/libs/routes/classroomCount.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index d7f8a0ac..5d00a6d4 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -714,13 +714,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } let currentIntegralOfferGoal = educationLevel.enrollment.integral_percentage; -<<<<<<< HEAD - - if (req.dims.school === undefined) currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, currentIntegralOfferGoal); - console.log("dims school", req.dims, currentIntegralOfferGoal, enrollmentEducationLevel.integralTimeOfferGoal) -======= if (req.dims.school === undefined) currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, currentIntegralOfferGoal); ->>>>>>> 6a86cc4576e26b001222bf9a190be0e2665c2221 let currentNumberStudentClass = (enrollment.location_id == 1) ? enrollmentEducationLevel.numberStudentClass.urban : enrollmentEducationLevel.numberStudentClass.country; -- GitLab From a88d7e12d9c3ebf0cd210698d67ba89156cdda37 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 14 Jul 2022 09:41:29 -0300 Subject: [PATCH 183/305] hotfix integral percentage for schools --- src/libs/routes/classroomCount.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 5d00a6d4..0eb8c61d 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -626,10 +626,9 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { educationLevel = { education_level_short_id: enrollmentEducationLevel.id, education_level_short_name: enrollmentEducationLevel.name, - enrollment: { - integral_percentage: level_diagnosis, - integral_time: integral_time, + integral_percentage: req.dims.school ? level_diagnosis : Math.max(level_diagnosis, enrollmentEducationLevel.integralTimeOfferGoal), + integral_time: req.dims.school ? integral_time : Math.round(integral_time_total * Math.max(level_diagnosis, enrollmentEducationLevel.integralTimeOfferGoal)/100), integral_time_total: integral_time_total, total_enrollment_day: 0, total_enrollment_night: 0, @@ -714,7 +713,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } let currentIntegralOfferGoal = educationLevel.enrollment.integral_percentage; - if (req.dims.school === undefined) currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, currentIntegralOfferGoal); let currentNumberStudentClass = (enrollment.location_id == 1) ? enrollmentEducationLevel.numberStudentClass.urban : enrollmentEducationLevel.numberStudentClass.country; -- GitLab From 83fd9e4f376ebd7f8defdd777dde431b750c5a41 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 14 Jul 2022 09:44:10 -0300 Subject: [PATCH 184/305] hotfix integral time calculation --- src/libs/routes/classroomCount.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index ef787ddd..939459b7 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -626,10 +626,9 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { educationLevel = { education_level_short_id: enrollmentEducationLevel.id, education_level_short_name: enrollmentEducationLevel.name, - enrollment: { - integral_percentage: level_diagnosis, - integral_time: integral_time, + integral_percentage: req.dims.school ? level_diagnosis : Math.max(level_diagnosis, enrollmentEducationLevel.integralTimeOfferGoal), + integral_time: req.dims.school ? integral_time : Math.round(integral_time_total * Math.max(level_diagnosis, enrollmentEducationLevel.integralTimeOfferGoal)/100), integral_time_total: integral_time_total, total_enrollment_day: 0, total_enrollment_night: 0, @@ -714,7 +713,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { } let currentIntegralOfferGoal = educationLevel.enrollment.integral_percentage; - if (req.dims.school === undefined) currentIntegralOfferGoal = Math.max(enrollmentEducationLevel.integralTimeOfferGoal, currentIntegralOfferGoal); let currentNumberStudentClass = (enrollment.location_id == 1) ? enrollmentEducationLevel.numberStudentClass.urban : enrollmentEducationLevel.numberStudentClass.country; -- GitLab From a4acbbaba2bf353b781790e2573e15eb9b3b23e0 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 14 Jul 2022 11:13:38 -0300 Subject: [PATCH 185/305] add nao declarada name --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 844322bd..a229a3ea 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -194,7 +194,7 @@ enrollmentApp.get('/gender', (req, res, next) => { // Return ethnic group enrollmentApp.get('/ethnic_group', (req, res, next) => { req.result = []; - for(let i = 1; i <=5; ++i) { + for(let i = 0; i <=5; ++i) { req.result.push({ id: i, name: id2str.ethnicGroup(i) -- GitLab From a586e860692b475b9f18d817ef2841b810d1fb95 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 14 Jul 2022 11:50:54 -0300 Subject: [PATCH 186/305] correct cor_raca from matriculas ens superior and docentes ens superior --- src/libs/convert/ethnicGroupIES.js | 1 + src/libs/convert/ethnicGroupTeacherIES.js | 1 + src/libs/routes/universityEnrollment.js | 7 +++++-- src/libs/routes/universityTeacher.js | 5 ++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libs/convert/ethnicGroupIES.js b/src/libs/convert/ethnicGroupIES.js index a57150fc..0e6fbd20 100644 --- a/src/libs/convert/ethnicGroupIES.js +++ b/src/libs/convert/ethnicGroupIES.js @@ -32,6 +32,7 @@ module.exports = function ethnicGroupIES(id) { return 'Amarela'; case 5: return 'Indígena'; + case 9: default: return 'Não dispõe da informação (Não resposta)'; } diff --git a/src/libs/convert/ethnicGroupTeacherIES.js b/src/libs/convert/ethnicGroupTeacherIES.js index 7db2936c..40ce39d6 100644 --- a/src/libs/convert/ethnicGroupTeacherIES.js +++ b/src/libs/convert/ethnicGroupTeacherIES.js @@ -32,6 +32,7 @@ module.exports = function ethnicGroupTeacherIES(id) { return 'Amarela'; case 5: return 'Indígena'; + case 9: default: return 'Não dispõe da informação (Não resposta)'; } diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 6a223a34..b9757594 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -214,8 +214,11 @@ universityEnrollmentApp.get('/student_deficiency', (req, res, next) => { }, response('student_deficiency')); universityEnrollmentApp.get('/ethnic_group_ies', (req, res, next) => { - req.result = []; - for(let i = 1; i <=5; ++i) { + req.result = [{ + id: 9, + name: id2str.ethnicGroupIES(9) + }]; + for(let i = 0; i <=5; ++i) { req.result.push({ id: i, name: id2str.ethnicGroupIES(i) diff --git a/src/libs/routes/universityTeacher.js b/src/libs/routes/universityTeacher.js index 42851c2b..58e46f92 100644 --- a/src/libs/routes/universityTeacher.js +++ b/src/libs/routes/universityTeacher.js @@ -179,7 +179,10 @@ teacherEnrollmentApp.get('/deficiency', (req, res, next) => { }, response('deficiency')); teacherEnrollmentApp.get('/ethnic_group_teacher_ies', (req, res, next) => { - req.result = []; + req.result = [{ + id: 9, + name: id2str.ethnicGroupTeacherIES(9) + }]; for(let i = 0; i <= 5; ++i) { req.result.push({ id: i, -- GitLab From da6f510710889ab8fa96fbb72a789ef2019d1416 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Tue, 19 Jul 2022 11:35:56 -0300 Subject: [PATCH 187/305] =?UTF-8?q?fix=20n=C3=A3o=20declarado=20in=20stude?= =?UTF-8?q?ntDeficiency=20and=20schoolType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/convert/schoolType.js | 3 ++- src/libs/convert/studentDeficiency.js | 1 + src/libs/routes/universityEnrollment.js | 14 ++++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/libs/convert/schoolType.js b/src/libs/convert/schoolType.js index f485ecb9..665fc14c 100644 --- a/src/libs/convert/schoolType.js +++ b/src/libs/convert/schoolType.js @@ -18,12 +18,13 @@ 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 studentDeficiency(id) { +module.exports = function schoolType(id) { switch (id) { case 1: return 'Pública'; case 2: return 'Privada'; + case 9: default: return 'Não classificado'; } diff --git a/src/libs/convert/studentDeficiency.js b/src/libs/convert/studentDeficiency.js index c5ad0e01..500f1203 100644 --- a/src/libs/convert/studentDeficiency.js +++ b/src/libs/convert/studentDeficiency.js @@ -24,6 +24,7 @@ module.exports = function studentDeficiency(id) { return 'Não'; case 1: return 'Sim'; + case 9: default: return 'Não declarado' } diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 0cf2de4f..49707e2e 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -207,8 +207,11 @@ universityEnrollmentApp.get('/upper_turn', (req, res, next) => { }, response('upper_turn')); universityEnrollmentApp.get('/student_deficiency', (req, res, next) => { - req.result = []; - for(let i = 0; i <= 2; ++i) { + req.result = [{ + id: 9, + name: id2str.studentDeficiency(9) + }]; + for(let i = 0; i <= 1; ++i) { req.result.push({ id: i, name: id2str.studentDeficiency(i) @@ -232,8 +235,11 @@ universityEnrollmentApp.get('/ethnic_group_ies', (req, res, next) => { }, response('ethnic_group_ies')); universityEnrollmentApp.get('/school_type', (req, res, next) => { - req.result = []; - for(let i = 0; i <= 2; ++i) { + req.result = [{ + id: 9, + name: id2str.schoolType(9) + }]; + for(let i = 1; i <= 2; ++i) { req.result.push({ id: i, name: id2str.schoolType(i) -- GitLab From 369b2fcb579a3ed4ea4824e7a5e948809b93c803 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 21 Jul 2022 10:32:06 -0300 Subject: [PATCH 188/305] remove programas basicos from convert --- src/libs/convert/cineDetailed.js | 2 -- src/libs/convert/cineGeral.js | 2 -- src/libs/convert/cineSpecific.js | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/libs/convert/cineDetailed.js b/src/libs/convert/cineDetailed.js index e1211704..bf246f55 100644 --- a/src/libs/convert/cineDetailed.js +++ b/src/libs/convert/cineDetailed.js @@ -19,8 +19,6 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. */ module.exports = function cineDetailed(id) { switch (id) { - case 11: - return 'Programas básicos'; case 111: return 'Ciência da educação'; case 112: diff --git a/src/libs/convert/cineGeral.js b/src/libs/convert/cineGeral.js index 4f38e88a..ec274ce9 100644 --- a/src/libs/convert/cineGeral.js +++ b/src/libs/convert/cineGeral.js @@ -20,8 +20,6 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function cineGeral(id) { switch (id) { - case 0: - return 'Programas básicos'; case 1: return 'Educação'; case 2: diff --git a/src/libs/convert/cineSpecific.js b/src/libs/convert/cineSpecific.js index 8c900c35..50ca1437 100644 --- a/src/libs/convert/cineSpecific.js +++ b/src/libs/convert/cineSpecific.js @@ -21,8 +21,6 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function cineSpecific(id) { switch (id) { - case 1: - return 'Programas básicos'; case 11: return 'Educação'; case 18: -- GitLab From 110ab4385222e0f3a2cad89f10828330ab038f50 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 21 Jul 2022 10:34:37 -0300 Subject: [PATCH 189/305] remove Programas basicos from route --- src/libs/routes/courseCount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/courseCount.js b/src/libs/routes/courseCount.js index 4cc8974a..b11c39fb 100644 --- a/src/libs/routes/courseCount.js +++ b/src/libs/routes/courseCount.js @@ -132,7 +132,7 @@ courseCountApp.get('/ocde_detailed', (req, res, next) => { courseCountApp.get('/cine_geral', (req, res, next) => { req.result = []; - for(let i = 0; i <= 10; ++i) { + for(let i = 1; i <= 10; ++i) { req.result.push({ id: i, name: id2str.cineGeral(i) -- GitLab From ffb41e6e4f4ee569fcbdd5c8484c75d086b26f58 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 21 Jul 2022 11:16:54 -0300 Subject: [PATCH 190/305] Update enrollment - new filters Signed-off-by: Joao Kieras <jpko19@inf.ufpr.br> --- src/libs/routes/enrollment.js | 133 +++++++++++++++++++++++++++++++++- 1 file changed, 132 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 302d3186..01ccbc94 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -604,7 +604,138 @@ rqf.addField({ type: 'integer', field: 'turma_turno_id' } -}, 'filter'); +}, 'filter') +.addValue({ + name: 'low_vision', + table: 'matricula', + tableField: 'baixa_visao', + resultField: 'low_vision', + where: { + relation: '=', + type: 'boolean', + field: 'baixa_visao' + } +}).addValue({ + name: 'blindness', + table: 'matricula', + tableField: 'cegueira', + resultField: 'blindness', + where: { + relation: '=', + type: 'boolean', + field: 'cegueira' + } +}).addValue({ + name: 'deafness', + table: 'matricula', + tableField: 'surdez', + resultField: 'deafness', + where: { + relation: '=', + type: 'boolean', + field: 'surdez' + } +}).addValue({ + name: 'hearing_deficiency', + table: 'matricula', + tableField: 'deficiencia_auditiva', + resultField: 'hearing_deficiency', + where: { + relation: '=', + type: 'boolean', + field: 'deficiencia_auditiva' + } +}).addValue({ + name: 'deafblindness', + table: 'matricula', + tableField: 'surdo_cegueira', + resultField: 'deafblindness', + where: { + relation: '=', + type: 'boolean', + field: 'surdo_cegueira' + } +}).addValue({ + name: 'physical_disability', + table: 'matricula', + tableField: 'deficiencia_fisica', + resultField: 'physical_disability', + where: { + relation: '=', + type: 'boolean', + field: 'deficiencia_fisica' + } +}).addValue({ + name: 'intellectual_disability', + table: 'matricula', + tableField: 'deficiencia_intelectual', + resultField: 'intellectual_disability', + where: { + relation: '=', + type: 'boolean', + field: 'deficiencia_intelectual' + } +}).addValue({ + name: 'multiple_disabilities', + table: 'matricula', + tableField: 'deficiencia_multiplas', + resultField: 'multiple_disabilities', + where: { + relation: '=', + type: 'boolean', + field: 'deficiencia_multiplas' + } +}).addValue({ + name: 'autism', + table: 'matricula', + tableField: 'autismo', + resultField: 'autism', + where: { + relation: '=', + type: 'boolean', + field: 'autismo' + } +}).addValue({ + name: 'asperger_syndrom', + table: 'matricula', + tableField: 'sindrome_asperger', + resultField: 'asperger_syndrom', + where: { + relation: '=', + type: 'boolean', + field: 'sindrome_asperger' + } +}).addValue({ + name: 'rett_syndrom', + table: 'matricula', + tableField: 'sindrome_rett', + resultField: 'rett_syndrom', + where: { + relation: '=', + type: 'boolean', + field: 'sindrome_rett' + } +}).addValue({ + name: 'childhood_desintegrative_disorder', + table: 'matricula', + tableField: 'transtorno_desintegrativo_da_infancia', + resultField: 'childhood_desintegrative_disorder', + where: { + relation: '=', + type: 'boolean', + field: 'transtorno_desintegrativo_da_infancia' + } +}).addValue({ + name: 'supergifted', + table: 'matricula', + tableField: 'superdotado', + resultField: 'supergifted', + where: { + relation: '=', + type: 'boolean', + field: 'superdotado' + } +}); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { req.sql.field('COUNT(*)', 'total') -- GitLab From bc807a5f5bd2c3f4fa383d48596ce72ee1faef77 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 21 Jul 2022 11:22:53 -0300 Subject: [PATCH 191/305] add ead to nightTime --- src/libs/convert/nightTime.js | 1 + src/libs/routes/courseCount.js | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/libs/convert/nightTime.js b/src/libs/convert/nightTime.js index 1e840071..b7c833b5 100644 --- a/src/libs/convert/nightTime.js +++ b/src/libs/convert/nightTime.js @@ -26,6 +26,7 @@ module.exports = function nightTime(id) { return 'Não'; case 1: return 'Sim'; + case 9: default: return 'Curso a distância'; } diff --git a/src/libs/routes/courseCount.js b/src/libs/routes/courseCount.js index b11c39fb..2067b0bd 100644 --- a/src/libs/routes/courseCount.js +++ b/src/libs/routes/courseCount.js @@ -211,11 +211,16 @@ courseCountApp.get('/is_free', (req, res, next) => { }, response('is_free')); courseCountApp.get('/night_time', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Classificado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; + req.result = [{ + id: 9, + name: id2str.nightTime(9) + }]; + for(let i = 0; i <= 1; ++i) { + req.result.push({ + id: i, + name: id2str.nightTime(i) + }) + } next(); }, response('night_time')); @@ -659,7 +664,7 @@ rqf.addField({ resultField: 'night_time_id', where: { relation: '=', - type: 'boolean', + type: 'integer', field: 'noturno_curso_t' } }).addValue({ -- GitLab From b714639085b317222b7f523c7af56ac8c7bdd9cc Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 22 Jul 2022 10:35:02 -0300 Subject: [PATCH 192/305] Add new sub rout PEE Signed-off-by: Joao Kieras <jpko19@inf.ufpr.br> --- src/libs/routes/enrollment.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 844322bd..f3c2edaa 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -239,6 +239,21 @@ enrollmentApp.get('/special_class', (req, res, next) => { next(); }, response('special_class')); +enrollmentApp.get('/pee', (req, res, next) => { + req.result = [{ + id: null, + name: id2str.booleanVariable(null) + }]; + + for(let i = 0; i <= 1; ++i) { + req.result.push({ + id: i, + name: id2str.booleanVariable(i) + }); + } + next(); +}, response('pee')); + enrollmentApp.get('/age_range_all', (req, res, next) => { req.result = [ {id: 1, name: '0 a 3 anos'}, -- GitLab From 9448489d9d78179cb092c46bcd257dbdaaef5dac Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 22 Jul 2022 11:11:10 -0300 Subject: [PATCH 193/305] update enrollment PEE(2) Signed-off-by: Joao Kieras <jpko19@inf.ufpr.br> --- src/libs/routes/enrollment.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index a61b3fd7..6ef0399e 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -240,17 +240,11 @@ enrollmentApp.get('/special_class', (req, res, next) => { }, response('special_class')); enrollmentApp.get('/pee', (req, res, next) => { - req.result = [{ - id: null, - name: id2str.booleanVariable(null) - }]; - - for(let i = 0; i <= 1; ++i) { - req.result.push({ - id: i, - name: id2str.booleanVariable(i) - }); - } + req.result = [ + {id: null, name: 'Não Declarado'}, + {id: false, name: 'Não'}, + {id: true, name: 'Sim'} + ]; next(); }, response('pee')); -- GitLab From f85b649a802225c9e91d299553b6ef6601e92e1a Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 22 Jul 2022 11:25:42 -0300 Subject: [PATCH 194/305] update enrollment PEE(3) Signed-off-by: Joao Kieras <jpko19@inf.ufpr.br> --- src/libs/routes/enrollment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 6ef0399e..1333aa64 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -242,8 +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: 0, name: 'Não'}, + {id: 1, name: 'Sim'} ]; next(); }, response('pee')); -- GitLab From 1fa9f72ac38d6fcf9fa3f7774d315ba545d669eb Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 22 Jul 2022 11:52:42 -0300 Subject: [PATCH 195/305] update enrollment PEE(4) Signed-off-by: Joao Kieras <jpko19@inf.ufpr.br> --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 1333aa64..2e397a50 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -756,7 +756,7 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { .order('matricula.ano_censo') .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); next(); -}, rqf.build(), query, id2str.transform(false), response('enrollment')); +}, rqf.build(), (req, res, next) => {console.log(req.sql.toString()); next();}, query, id2str.transform(false), response('enrollment')); enrollmentApp.get('/diagnosis', rqf.parse(), (req, res, next) => { req.dims = {}; -- GitLab From 705d8f694b8916ada98892db8e0ecfb3091a1331 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Mon, 25 Jul 2022 09:48:32 -0300 Subject: [PATCH 196/305] Add new rout possui_necessidade_especial --- src/libs/routes/enrollment.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 2e397a50..319c1309 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -746,6 +746,16 @@ rqf.addField({ type: 'boolean', field: 'superdotado' } +}).addValue({ + name: 'pee', + table: 'matricula', + tableField: 'possui_necessidade_especial', + resultField: 'pee', + where: { + relation: '=', + type: 'boolean', + field: 'possui_necessidade_especial' + } }); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { -- GitLab From fa575b343e97102f0b8da0d9bd09633e6e397c52 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Mon, 25 Jul 2022 10:38:50 -0300 Subject: [PATCH 197/305] Add pee_por_categoria --- src/libs/routes/enrollment.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 319c1309..205f5401 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -246,7 +246,18 @@ enrollmentApp.get('/pee', (req, res, next) => { {id: 1, name: 'Sim'} ]; next(); -}, response('pee')); +}, response('pee')) + +enrollmentApp.get('/pee_por_categoria', (req, res, next) => { + req.result = []; + for(let i = 1; i <= 13; ++i) { + req.result.push({ + id: i, + name: id2str.peePorCategoria(i) + }); + } + next(); +}, response('pee_por_categoria')); enrollmentApp.get('/age_range_all', (req, res, next) => { req.result = [ -- GitLab From 105d384e9fb61523eb4e38c4e6c6b441e4250edd Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Mon, 25 Jul 2022 10:40:51 -0300 Subject: [PATCH 198/305] Add new convert --- src/libs/convert/peePorCategoria.js | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/libs/convert/peePorCategoria.js diff --git a/src/libs/convert/peePorCategoria.js b/src/libs/convert/peePorCategoria.js new file mode 100644 index 00000000..f95d5a16 --- /dev/null +++ b/src/libs/convert/peePorCategoria.js @@ -0,0 +1,50 @@ +/* +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 peeCategory(id) { + switch (id) { + case 1: + return 'cegueira'; + case 2: + return 'baixa_visao'; + case 3: + return 'surdez'; + case 4: + return 'deficiencia_auditiva'; + case 5: + return 'surdo_cegueira'; + case 6: + return 'deficiencia_fisica'; + case 7: + return 'deficiencia_intelectual'; + case 8: + return 'deficiencia_multiplas'; + case 9: + return 'autismo'; + case 10: + return 'sindrome_asperger'; + case 11: + return 'sindrome_rett'; + case 12: + return 'transtorno_desintegrativo_da_infancia'; + case 13: + return 'superdotado'; + } +}; -- GitLab From d2b6761778a4fd84f90ea454a8e184ef7495b51f Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Mon, 25 Jul 2022 10:41:19 -0300 Subject: [PATCH 199/305] Update id2str --- src/libs/middlewares/id2str.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index 3a0cfe90..08fb793c 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -93,6 +93,7 @@ const enrolledVacanciesFreshmen = require(`${libs}/convert/enrolledVacanciesFres 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 ids = { gender_id: gender, @@ -177,7 +178,8 @@ const ids = { enrolled_vacancies_freshmen: enrolledVacanciesFreshmen, enter_situation: enterSituation, enrollment_situation: enrollmentSituation, - diff_location_id: diffLocation + diff_location_id: diffLocation, + pee_por_categoria: peePorCategoria }; function transform(removeId=false) { @@ -289,5 +291,6 @@ module.exports = { enrolledVacanciesFreshmen, enterSituation, enrollmentSituation, - diffLocation + diffLocation, + peePorCategoria }; -- GitLab From 9c64e6732e6f0f72f07d137bc449156ccc1c5f78 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Mon, 25 Jul 2022 10:48:57 -0300 Subject: [PATCH 200/305] Update names --- src/libs/convert/peePorCategoria.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libs/convert/peePorCategoria.js b/src/libs/convert/peePorCategoria.js index f95d5a16..6656f8a1 100644 --- a/src/libs/convert/peePorCategoria.js +++ b/src/libs/convert/peePorCategoria.js @@ -21,30 +21,30 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function peeCategory(id) { switch (id) { case 1: - return 'cegueira'; + return 'Cegueira'; case 2: - return 'baixa_visao'; + return 'Baixa visão'; case 3: - return 'surdez'; + return 'Surdez'; case 4: - return 'deficiencia_auditiva'; + return 'Deficiência auditiva'; case 5: - return 'surdo_cegueira'; + return 'Surdocegueira'; case 6: - return 'deficiencia_fisica'; + return 'Deficiência física'; case 7: - return 'deficiencia_intelectual'; + return 'Deficiência intelectual'; case 8: - return 'deficiencia_multiplas'; + return 'Deficiências múltiplas'; case 9: - return 'autismo'; + return 'Autismo'; case 10: - return 'sindrome_asperger'; + return 'Síndrome de Asperger'; case 11: - return 'sindrome_rett'; + return 'Síncrome de Rett'; case 12: - return 'transtorno_desintegrativo_da_infancia'; + return 'Transtorno Desintegrativo da Infância'; case 13: - return 'superdotado'; + return 'Superdotado'; } }; -- GitLab From 5d53044c6f5dfae0f26c06959d701f652b7b14ba Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 27 Jul 2022 08:53:39 -0300 Subject: [PATCH 201/305] fix problem with missing teacher --- src/libs/routes/classroomCount.js | 109 +++++++----------------------- 1 file changed, 24 insertions(+), 85 deletions(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 939459b7..038c6e45 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -43,6 +43,8 @@ const cache = require('apicache').options({ debug: config.debug, statusCodes: {i let rqf = new ReqQueryFields(); +const fs = require('fs') + rqf.addField({ name: 'filter', field: false, @@ -285,20 +287,20 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { next(); }, rqf.build(), query, id2str.transform(), (req, res, next) => { req.enrollment = req.result; - + // Gera a relação etapa de ensino X ano escolar req.educationSchoolYear = {}; for(let i = 1; i < 15; ++i) { if(id2str.educationLevelSchoolYear(i) !== id2str.educationLevelSchoolYear(99)) { let educationLevelId = (i > 10) ? Math.floor(i/10) : i; - + let classSize = req.classSize.find((el) => {return el.id === educationLevelId || el.id === i}); let integralTime = req.integralTime.find((el) => {return el.id === educationLevelId}); - + let numberStudentClass = (typeof classSize !== 'undefined') ? classSize.numberStudentClass : null; // Usa o offerGoal que é passado como parâmetro (Brasil inteiro). Atenção para isso. let integralTimeOfferGoal = (typeof integralTime !== 'undefined') ? integralTime.offerGoal : null; - + let teacherByClass = (typeof classSize !== 'undefined') ? classSize.teacherByClass : null; req.educationSchoolYear[i] = { @@ -310,6 +312,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { }; } } + delete req.dims; delete req.filter; req.resetSql(); @@ -334,13 +337,14 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { next(); }, rqf.build(), query, id2str.transform(), (req, res, next) => { req.classroom = req.result; + delete req.dims; delete req.filter; req.resetSql(); next(); }, rqf.parse(), (req, res, next) => { if (req.body.teacher_journey !== undefined) { - req.teacherJourney = JSON.parse(req.body.teacher_journey) || null; + // req.teacherJourney = JSON.parse(req.body.teacher_journey) || null; let schoolDays = JSON.parse(req.body.school_days) || null; let teacherFormation = JSON.parse(req.body.teacher_formation) || null; @@ -364,6 +368,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { schoolYear.shifts = shifts teachingHoursParsed.push(schoolYear) } + req.schoolDays = schoolDaysParsed; req.teachingHours = teachingHoursParsed; @@ -372,7 +377,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { teacherFormationParsed.push(teacherFormation.find((el) => {return el.idFormationLevel === i})) } req.teacherFormation = teacherFormationParsed; - + req.teacherCalc = true; } @@ -389,6 +394,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { next(); }, rqf.build(), query, id2str.transform(), (req, res, next) => { req.teacher = req.result; + delete req.dims; delete req.filter; req.resetSql(); @@ -552,8 +558,18 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { currentClassroomObj = obj; var id_attribute = req.dims.school ? "school_id" : "city_id" - while (req.teacher[ti][id_attribute] !== classroom[id_attribute]) { // match da tabela de professores. + + var old_ti = ti; + while (ti < req.teacher.length && req.teacher[ti][id_attribute] !== classroom[id_attribute]) // match da tabela de professores. ti++; + + if (ti === req.teacher.length) { + console.log(classroom[id_attribute], "not found") + while (classroom[id_attribute] === enrollments[j][id_attribute]) + enrollments.splice(j, 1) + ti = old_ti; + i++; + continue; } } else { // Se a hash já existe, já temos a cidade nos resultados. Como está ordenado, é o último valor nos resultados @@ -1077,53 +1093,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { total_teacher_full_period : numberOfTeacherFullPeriod, total_teacher_partial : numberOfTeacherNight + numberOfTeacherDay } - - // schoolYear.teacherNumber.careerLevels = []; - // req.teacherFormation.forEach((formation, i) => { - // let totalTeacherFullPeriodCareer = Math.ceil(schoolYear.teacherNumber.total_teacher_full_period * teacherByFormation[i]); - // let totalTeacherPartialCareer = Math.ceil(schoolYear.teacherNumber.total_teacher_partial * teacherByFormation[i]); - - // schoolYear.teacherNumber.careerLevels.push({ - // sequence: formation.sequence, - // denomination: formation.denomination, - // formation_level_id: formation.idFormationLevel, - // total_teacher_career: totalTeacherFullPeriodCareer + totalTeacherPartialCareer, - // total_teacher_full_period_career: totalTeacherFullPeriodCareer, - // total_teacher_partial_career: totalTeacherPartialCareer, - // }) - // }) - - // // Garantimos que a soma das porcentagens deu 100% usando reduce, geralmente não ocorre devido à função teto. - // function reducer(key) { return (sum, elem) => sum + elem[key]}; - // let teacherDiffFullPeriod = schoolYear.teacherNumber.careerLevels.reduce(reducer('total_teacher_full_period_career'), 0) - schoolYear.teacherNumber.total_teacher_full_period; - // let teacherDiffPartial = schoolYear.teacherNumber.careerLevels.reduce(reducer('total_teacher_partial_career'), 0) - schoolYear.teacherNumber.total_teacher_partial; - - // // Remove primeiro do ensino superior, caso não tenha suficiente remove do nível médio. - // schoolYear.teacherNumber.careerLevels[1].total_teacher_full_period_career -= teacherDiffFullPeriod; - // if (schoolYear.teacherNumber.careerLevels[1].total_teacher_full_period_career < 0) { - // teacherDiffFullPeriod = (-1)*schoolYear.teacherNumber.careerLevels[1].total_teacher_full_period_career; - // schoolYear.teacherNumber.careerLevels[1].total_teacher_full_period_career = 0; - - // schoolYear.teacherNumber.careerLevels[0].total_teacher_full_period_career -= teacherDiffFullPeriod; - // if (schoolYear.teacherNumber.careerLevels[0].total_teacher_full_period_career < 0) - // schoolYear.teacherNumber.careerLevels[0].total_teacher_full_period_career = 0; - // } - - // // Repete calculos para parcial - // schoolYear.teacherNumber.careerLevels[1].total_teacher_partial_career -= teacherDiffPartial; - // if (schoolYear.teacherNumber.careerLevels[1].total_teacher_partial_career < 0) { - // teacherDiffPartial = (-1)*schoolYear.teacherNumber.careerLevels[1].total_teacher_partial_career; - // schoolYear.teacherNumber.careerLevels[1].total_teacher_partial_career = 0; - - // schoolYear.teacherNumber.careerLevels[0].total_teacher_partial_career -= teacherDiffPartial; - // if (schoolYear.teacherNumber.careerLevels[0].total_teacher_partial < 0) - // schoolYear.teacherNumber.careerLevels[0].total_teacher_partial_career = 0; - // } - - // // Atualiza os totais das carreiras - // schoolYear.teacherNumber.careerLevels[1].total_teacher_career = schoolYear.teacherNumber.careerLevels[1].total_teacher_full_period_career + schoolYear.teacherNumber.careerLevels[1].total_teacher_partial_career; - // schoolYear.teacherNumber.careerLevels[0].total_teacher_career = schoolYear.teacherNumber.careerLevels[0].total_teacher_full_period_career + schoolYear.teacherNumber.careerLevels[0].total_teacher_partial_career; - }) // Calculamos para o educationLevel usando reduce @@ -1193,37 +1162,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { }) }) - - // // Garantimos que a soma das porcentagens deu 100% usando reduce, geralmente não ocorre devido à função teto. - // function reducer(key) {return (sum, elem) => sum + elem[key]}; - // let teacherDiffFullPeriod = educationLevel.teacherNumber.careerLevels.reduce(reducer('total_teacher_full_period_career'), 0) - educationLevel.teacherNumber.total_teacher_full_period; - // let teacherDiffPartial = educationLevel.teacherNumber.careerLevels.reduce(reducer('total_teacher_partial_career'), 0) - educationLevel.teacherNumber.total_teacher_partial; - - // // Remove primeiro do ensino superior, caso não tenha suficiente remove do nível médio. - // educationLevel.teacherNumber.careerLevels[1].total_teacher_full_period_career -= teacherDiffFullPeriod; - // if (educationLevel.teacherNumber.careerLevels[1].total_teacher_full_period_career < 0) { - // teacherDiffFullPeriod = (-1)*educationLevel.teacherNumber.careerLevels[1].total_teacher_full_period_career; - // educationLevel.teacherNumber.careerLevels[1].total_teacher_full_period_career = 0; - - // educationLevel.teacherNumber.careerLevels[0].total_teacher_full_period_career -= teacherDiffFullPeriod; - // if (educationLevel.teacherNumber.careerLevels[0].total_teacher_full_period_career < 0) - // educationLevel.teacherNumber.careerLevels[0].total_teacher_full_period_career = 0; - // } - - // // Repete calculos para parcial - // educationLevel.teacherNumber.careerLevels[1].total_teacher_partial_career -= teacherDiffPartial; - // if (educationLevel.teacherNumber.careerLevels[1].total_teacher_partial_career < 0) { - // teacherDiffPartial = (-1)*educationLevel.teacherNumber.careerLevels[1].total_teacher_partial_career; - // educationLevel.teacherNumber.careerLevels[1].total_teacher_partial_career = 0; - - // educationLevel.teacherNumber.careerLevels[0].total_teacher_partial_career -= teacherDiffPartial; - // if (educationLevel.teacherNumber.careerLevels[0].total_teacher_partial < 0) - // educationLevel.teacherNumber.careerLevels[0].total_teacher_partial_career = 0; - // } - - // // Atualiza os totais das carreiras - // educationLevel.teacherNumber.careerLevels[1].total_teacher_career = educationLevel.teacherNumber.careerLevels[1].total_teacher_full_period_career + educationLevel.teacherNumber.careerLevels[1].total_teacher_partial_career; - // educationLevel.teacherNumber.careerLevels[0].total_teacher_career = educationLevel.teacherNumber.careerLevels[0].total_teacher_full_period_career + educationLevel.teacherNumber.careerLevels[0].total_teacher_partial_career; } }) }) @@ -1233,3 +1171,4 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { }, response('classroom_count')); module.exports = classroomCountApp; + -- GitLab From f143e932958896a2c28609ec8da72b282dca48d8 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 28 Jul 2022 09:02:33 -0300 Subject: [PATCH 202/305] fix classroom_count --- src/libs/routes/classroomCount.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 0eb8c61d..939459b7 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -1233,4 +1233,3 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { }, response('classroom_count')); module.exports = classroomCountApp; - -- GitLab From b927a01c855bd24cf51f0ab3e120ff2441049962 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 28 Jul 2022 09:37:25 -0300 Subject: [PATCH 203/305] =?UTF-8?q?remove=20n=C3=A3o=20classificada=20from?= =?UTF-8?q?=20modalidade=20de=20ensino?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/routes/courseCount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/courseCount.js b/src/libs/routes/courseCount.js index 2067b0bd..b72181c5 100644 --- a/src/libs/routes/courseCount.js +++ b/src/libs/routes/courseCount.js @@ -192,7 +192,7 @@ courseCountApp.get('/academic_level', (req, res, next) => { courseCountApp.get('/upper_education_mod', (req, res, next) => { req.result = []; - for(let i = 1; i <= 3; ++i) { + for(let i = 1; i <= 2; ++i) { req.result.push({ id: i, name: id2str.upperEducationMod(i) -- GitLab From 66e88d8ea75a52ceedf61496e51e01af86a8a33d Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 28 Jul 2022 09:37:46 -0300 Subject: [PATCH 204/305] add backtick --- src/libs/convert/nightTime.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/convert/nightTime.js b/src/libs/convert/nightTime.js index b7c833b5..99b9f078 100644 --- a/src/libs/convert/nightTime.js +++ b/src/libs/convert/nightTime.js @@ -28,6 +28,6 @@ module.exports = function nightTime(id) { return 'Sim'; case 9: default: - return 'Curso a distância'; + return 'Curso à distância'; } }; \ No newline at end of file -- GitLab From c4b7a89570bda23023265030d650074658209c61 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Thu, 28 Jul 2022 10:24:27 -0300 Subject: [PATCH 205/305] =?UTF-8?q?add=20n=C3=A3o=20declarado=20to=20boole?= =?UTF-8?q?an=20variables=20in=20docentes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/convert/booleanVariable.js | 2 +- src/libs/routes/universityTeacher.js | 30 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/libs/convert/booleanVariable.js b/src/libs/convert/booleanVariable.js index 64966010..4c78bc9c 100644 --- a/src/libs/convert/booleanVariable.js +++ b/src/libs/convert/booleanVariable.js @@ -19,7 +19,7 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. */ module.exports = function booleanVariable(id) { - if (id == null) + if (id == null || id == "null") return 'Não Declarado'; else if (id == false) return 'Não'; diff --git a/src/libs/routes/universityTeacher.js b/src/libs/routes/universityTeacher.js index 58e46f92..d8bf5504 100644 --- a/src/libs/routes/universityTeacher.js +++ b/src/libs/routes/universityTeacher.js @@ -102,7 +102,10 @@ teacherEnrollmentApp.get('/work_regime', (req, res, next) => { }, response('work_regime')); teacherEnrollmentApp.get('/substitute', (req, res, next) => { - req.result = []; + req.result = [{ + id: "null", + name: id2str.booleanVariable("null") + }]; for(let i = 0; i <= 1; ++i) { req.result.push({ id: i, @@ -113,7 +116,10 @@ teacherEnrollmentApp.get('/substitute', (req, res, next) => { }, response('substitute')); teacherEnrollmentApp.get('/visitor', (req, res, next) => { - req.result = []; + req.result = [{ + id: "null", + name: id2str.booleanVariable("null") + }]; for(let i = 0; i <= 1; ++i) { req.result.push({ id: i, @@ -124,7 +130,10 @@ teacherEnrollmentApp.get('/visitor', (req, res, next) => { }, response('visitor')); teacherEnrollmentApp.get('/ead_teacher', (req, res, next) => { - req.result = []; + req.result = [{ + id: "null", + name: id2str.booleanVariable("null") + }]; for(let i = 0; i <= 1; ++i) { req.result.push({ id: i, @@ -135,7 +144,10 @@ teacherEnrollmentApp.get('/ead_teacher', (req, res, next) => { }, response('ead_teacher')); teacherEnrollmentApp.get('/graduation_presential', (req, res, next) => { - req.result = []; + req.result = [{ + id: "null", + name: id2str.booleanVariable("null") + }]; for(let i = 0; i <= 1; ++i) { req.result.push({ id: i, @@ -146,7 +158,10 @@ teacherEnrollmentApp.get('/graduation_presential', (req, res, next) => { }, response('graduation_presential')); teacherEnrollmentApp.get('/postgraduate_ead_teacher', (req, res, next) => { - req.result = []; + req.result = [{ + id: "null", + name: id2str.booleanVariable("null") + }]; for(let i = 0; i <= 1; ++i) { req.result.push({ id: i, @@ -157,7 +172,10 @@ teacherEnrollmentApp.get('/postgraduate_ead_teacher', (req, res, next) => { }, response('postgraduate_ead_teacher')); teacherEnrollmentApp.get('/postgraduate_presential_teacher', (req, res, next) => { - req.result = []; + req.result = [{ + id: "null", + name: id2str.booleanVariable("null") + }]; for(let i = 0; i <= 1; ++i) { req.result.push({ id: i, -- GitLab From 97309420ca5ee5da8129f62d865ca149d77dc2b9 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Fri, 29 Jul 2022 09:15:10 -0300 Subject: [PATCH 206/305] finish all teacher corrections --- src/libs/convert/workRegime.js | 3 ++- src/libs/routes/universityTeacher.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/libs/convert/workRegime.js b/src/libs/convert/workRegime.js index f03d97a8..46f14afa 100644 --- a/src/libs/convert/workRegime.js +++ b/src/libs/convert/workRegime.js @@ -28,7 +28,8 @@ module.exports = function workRegime(id) { return 'Tempo Parcial'; case 4: return 'Horista'; + case "null": default: - return 'Não declarado'; + return 'Não Declarado'; } }; diff --git a/src/libs/routes/universityTeacher.js b/src/libs/routes/universityTeacher.js index d8bf5504..1f14942f 100644 --- a/src/libs/routes/universityTeacher.js +++ b/src/libs/routes/universityTeacher.js @@ -91,7 +91,10 @@ teacherEnrollmentApp.get('/teacher_situation', (req, res, next) => { }, response('teacher_situation')); teacherEnrollmentApp.get('/work_regime', (req, res, next) => { - req.result = []; + req.result = [{ + id: "null", + name: id2str.workRegime("null") + }]; for(let i = 1; i <= 4; ++i) { req.result.push({ id: i, @@ -186,11 +189,14 @@ teacherEnrollmentApp.get('/postgraduate_presential_teacher', (req, res, next) => }, response('postgraduate_presential_teacher')); teacherEnrollmentApp.get('/deficiency', (req, res, next) => { - req.result = []; + req.result = [{ + id: 9, + name: id2str.studentDeficiency(9) + }]; for(let i = 0; i <= 1; ++i) { req.result.push({ id: i, - name: id2str.booleanVariable(i) + name: id2str.studentDeficiency(i) }); }; next(); -- GitLab From 09cab6290bcd06bb28aad29913b632ac3c0087a0 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Fri, 29 Jul 2022 09:40:45 -0300 Subject: [PATCH 207/305] change from if to switch --- src/libs/convert/booleanVariable.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libs/convert/booleanVariable.js b/src/libs/convert/booleanVariable.js index 4c78bc9c..65d4ced9 100644 --- a/src/libs/convert/booleanVariable.js +++ b/src/libs/convert/booleanVariable.js @@ -19,10 +19,12 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. */ module.exports = function booleanVariable(id) { - if (id == null || id == "null") - return 'Não Declarado'; - else if (id == false) - return 'Não'; - else if (id == true) - return 'Sim'; + switch(id){ + case true: + return 'Sim'; + case false: + return 'Não'; + default: + return 'Não Declarado'; + } }; -- GitLab From b5e122ddd20369517056b5594bcb5e39358016e9 Mon Sep 17 00:00:00 2001 From: "Henrique V. Ehrenfried" <h.v.ehrenfried@hotmail.com> Date: Mon, 1 Aug 2022 11:01:10 -0300 Subject: [PATCH 208/305] Add new line to keep the standard fomatting Signed-off-by: Henrique V. Ehrenfried <h.v.ehrenfried@hotmail.com> --- src/libs/convert/educationLevelSchoolYear.js | 96 +++++++++++++------- 1 file changed, 64 insertions(+), 32 deletions(-) diff --git a/src/libs/convert/educationLevelSchoolYear.js b/src/libs/convert/educationLevelSchoolYear.js index 07cc64f7..1c17534e 100644 --- a/src/libs/convert/educationLevelSchoolYear.js +++ b/src/libs/convert/educationLevelSchoolYear.js @@ -20,37 +20,69 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function educationLevelSchoolYear(id) { switch(id) { - case 1: return 'Creche'; - case 11: return 'Creche - Menor de 1 ano'; - case 12: return 'Creche - 1 ano'; - case 13: return 'Creche - 2 anos'; - case 14: return 'Creche - 3 anos'; - case 2: return 'Pré-Escola'; - case 21: return 'Pré-Escola - 4 anos'; - case 22: return 'Pré-Escola - 5 anos'; - case 3: return 'Ensino Fundamental - anos iniciais'; - case 31: return 'Ens. Fundamental - 1º Ano'; - case 32: return 'Ens. Fundamental - 1ª série/2º ano'; - case 33: return 'Ens. Fundamental - 2ª série/3º ano'; - case 34: return 'Ens. Fundamental - 3ª série/4º ano'; - case 35: return 'Ens. Fundamental - 4ª série/5º Ano'; - case 4: return 'Ensino Fundamental - anos finais'; - case 41: return 'Ens. Fundamental - 5ª série/6º ano'; - case 42: return 'Ens. Fundamental - 6ª série/7º ano'; - case 43: return 'Ens. Fundamental - 7ª série/8º ano'; - case 44: return 'Ens. Fundamental - 8ª serie/9º ano'; - case 5: return 'Ensino Médio'; - case 51: return 'Ens. Médio - 1ª série'; - case 52: return 'Ens. Médio - 2ª série'; - case 53: return 'Ens. Médio - 3ª série'; - case 54: return 'Ens. Médio - 4ª série'; - case 6: return 'EJA'; - case 61: return 'EJA - anos iniciais do Ens. Fundamental'; - case 62: return 'EJA - anos finais do Ens. Fundamental'; - case 63: return 'EJA - Ensino Médio'; - case 64: return 'EJA semi-presencial'; - case 7: return 'EE exclusiva'; - case 71: return 'Educação Profissional'; - default: return 'Não classificada'; + case 1: + return 'Creche'; + case 11: + return 'Creche - Menor de 1 ano'; + case 12: + return 'Creche - 1 ano'; + case 13: + return 'Creche - 2 anos'; + case 14: + return 'Creche - 3 anos'; + case 2: + return 'Pré-Escola'; + case 21: + return 'Pré-Escola - 4 anos'; + case 22: + return 'Pré-Escola - 5 anos'; + case 3: + return 'Ensino Fundamental - anos iniciais'; + case 31: + return 'Ens. Fundamental - 1º Ano'; + case 32: + return 'Ens. Fundamental - 1ª série/2º ano'; + case 33: + return 'Ens. Fundamental - 2ª série/3º ano'; + case 34: + return 'Ens. Fundamental - 3ª série/4º ano'; + case 35: + return 'Ens. Fundamental - 4ª série/5º Ano'; + case 4: + return 'Ensino Fundamental - anos finais'; + case 41: + return 'Ens. Fundamental - 5ª série/6º ano'; + case 42: + return 'Ens. Fundamental - 6ª série/7º ano'; + case 43: + return 'Ens. Fundamental - 7ª série/8º ano'; + case 44: + return 'Ens. Fundamental - 8ª serie/9º ano'; + case 5: + return 'Ensino Médio'; + case 51: + return 'Ens. Médio - 1ª série'; + case 52: + return 'Ens. Médio - 2ª série'; + case 53: + return 'Ens. Médio - 3ª série'; + case 54: + return 'Ens. Médio - 4ª série'; + case 6: + return 'EJA'; + case 61: + return 'EJA - anos iniciais do Ens. Fundamental'; + case 62: + return 'EJA - anos finais do Ens. Fundamental'; + case 63: + return 'EJA - Ensino Médio'; + case 64: + return 'EJA semi-presencial'; + case 7: + return 'EE exclusiva'; + case 71: + return 'Educação Profissional'; + default: + return 'Não classificada'; } } \ No newline at end of file -- GitLab From 984c89125691f175a98077ef3432338cd3dedf51 Mon Sep 17 00:00:00 2001 From: "Henrique V. Ehrenfried" <h.v.ehrenfried@hotmail.com> Date: Mon, 1 Aug 2022 11:04:29 -0300 Subject: [PATCH 209/305] Add new line to keep the standard fomatting Signed-off-by: Henrique V. Ehrenfried <h.v.ehrenfried@hotmail.com> --- src/libs/convert/pfe.js | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/libs/convert/pfe.js b/src/libs/convert/pfe.js index c67a7141..ca71b98b 100644 --- a/src/libs/convert/pfe.js +++ b/src/libs/convert/pfe.js @@ -20,18 +20,31 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function pfeName(id) { switch(id) { - case 1: return 'População fora da escola menor de 1 ano'; - case 2: return 'População fora da escola 1 ano'; - case 3: return 'População fora da escola 2 anos'; - case 4: return 'População fora da escola 3 anos'; - case 5: return 'População fora da escola 4 anos'; - case 6: return 'População fora da escola 5 anos'; - case 7: return 'População fora da escola 6 e 10 anos sem instrução ou com EF incompleto'; - case 8: return 'População fora da escola 11 a 14 anos sem instrução'; - case 9: return 'População fora da escola 11 a 14 anos com EF incompleto'; - case 10: return 'População fora da escola 15 a 24 anos com e EF completo EM incompleto'; - case 11: return 'População fora da escola 15 anos mais sem instrução'; - case 12: return 'População fora da escola 15 anos mais com EF incompleto'; - case 13: return 'População fora da escola 25 anos mais com EF completo e EM incompleto'; + case 1: + return 'População fora da escola menor de 1 ano'; + case 2: + return 'População fora da escola 1 ano'; + case 3: + return 'População fora da escola 2 anos'; + case 4: + return 'População fora da escola 3 anos'; + case 5: + return 'População fora da escola 4 anos'; + case 6: + return 'População fora da escola 5 anos'; + case 7: + return 'População fora da escola 6 e 10 anos sem instrução ou com EF incompleto'; + case 8: + return 'População fora da escola 11 a 14 anos sem instrução'; + case 9: + return 'População fora da escola 11 a 14 anos com EF incompleto'; + case 10: + return 'População fora da escola 15 a 24 anos com e EF completo EM incompleto'; + case 11: + return 'População fora da escola 15 anos mais sem instrução'; + case 12: + return 'População fora da escola 15 anos mais com EF incompleto'; + case 13: + return 'População fora da escola 25 anos mais com EF completo e EM incompleto'; } }; -- GitLab From 9db24d2608561d5e57ddb3b956392d0959ae695d Mon Sep 17 00:00:00 2001 From: "Henrique V. Ehrenfried" <h.v.ehrenfried@hotmail.com> Date: Tue, 2 Aug 2022 09:02:34 -0300 Subject: [PATCH 210/305] Add missing semicolons Signed-off-by: Henrique V. Ehrenfried <h.v.ehrenfried@hotmail.com> --- src/libs/convert/academicLevel.js | 2 +- src/libs/convert/diffLocation.js | 2 +- src/libs/convert/discipline.js | 38 +++++++++++++-------------- src/libs/convert/educationLevelMod.js | 2 +- src/libs/convert/peePorCategoria.js | 2 +- src/libs/convert/studentDeficiency.js | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/libs/convert/academicLevel.js b/src/libs/convert/academicLevel.js index d04079de..c2c81a93 100644 --- a/src/libs/convert/academicLevel.js +++ b/src/libs/convert/academicLevel.js @@ -27,7 +27,7 @@ module.exports = function academicLevel(id) { case 3: return 'Tecnológico'; case 4: - return 'Bacharelado e Licenciatura' + return 'Bacharelado e Licenciatura'; default: return 'Não classificada'; } diff --git a/src/libs/convert/diffLocation.js b/src/libs/convert/diffLocation.js index a25d6983..f239f004 100644 --- a/src/libs/convert/diffLocation.js +++ b/src/libs/convert/diffLocation.js @@ -27,6 +27,6 @@ module.exports = function location(id) { case 2: return 'Terra indígena'; case 3: - return 'Área remanescente de quilombos' + return 'Área remanescente de quilombos'; } }; diff --git a/src/libs/convert/discipline.js b/src/libs/convert/discipline.js index 6cf57154..3bf4aaf7 100644 --- a/src/libs/convert/discipline.js +++ b/src/libs/convert/discipline.js @@ -21,42 +21,42 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function discipline(id) { switch (id) { case 1: - return 'Química' + return 'Química'; case 2: - return 'Física' + return 'Física'; case 3: - return 'Matemática' + return 'Matemática'; case 4: - return 'Biologia' + return 'Biologia'; case 5: - return 'Ciências' + return 'Ciências'; case 6: - return 'Língua Portuguesa' + return 'Língua Portuguesa'; case 7: - return 'Língua Estrangeira – Inglês' + return 'Língua Estrangeira – Inglês'; case 8: - return 'Língua Estrangeira - Espanhol' + return 'Língua Estrangeira - Espanhol'; case 9: - return 'Língua Estrangeira - Francês' + return 'Língua Estrangeira - Francês'; case 10: - return 'Língua Estrangeira - Outras' + return 'Língua Estrangeira - Outras'; case 11: - return 'Língua Indígena' + return 'Língua Indígena'; case 12: - return 'Arte' + return 'Arte'; case 13: - return 'Educação Física' + return 'Educação Física'; case 14: - return 'História' + return 'História'; case 15: - return 'Geografia' + return 'Geografia'; case 16: - return 'Filosofia' + return 'Filosofia'; case 17: - return 'Ensino religioso' + return 'Ensino religioso'; case 18: - return 'Estudos Sociais' + return 'Estudos Sociais'; case 19: - return 'Sociologia' + return 'Sociologia'; } }; diff --git a/src/libs/convert/educationLevelMod.js b/src/libs/convert/educationLevelMod.js index 5add8f1e..7c6f2cdf 100644 --- a/src/libs/convert/educationLevelMod.js +++ b/src/libs/convert/educationLevelMod.js @@ -43,7 +43,7 @@ module.exports = function educationLevelMod(id) { case 11: return 'EJA - EF e EM Integrado - tecnico'; case 12: - return 'Educacao Profissional - concomitante e subsequente' + return 'Educacao Profissional - concomitante e subsequente'; default: return 'Não classificada'; } diff --git a/src/libs/convert/peePorCategoria.js b/src/libs/convert/peePorCategoria.js index 6656f8a1..6249ae31 100644 --- a/src/libs/convert/peePorCategoria.js +++ b/src/libs/convert/peePorCategoria.js @@ -41,7 +41,7 @@ module.exports = function peeCategory(id) { case 10: return 'Síndrome de Asperger'; case 11: - return 'Síncrome de Rett'; + return 'Síndrome de Rett'; case 12: return 'Transtorno Desintegrativo da Infância'; case 13: diff --git a/src/libs/convert/studentDeficiency.js b/src/libs/convert/studentDeficiency.js index 500f1203..a9c648c8 100644 --- a/src/libs/convert/studentDeficiency.js +++ b/src/libs/convert/studentDeficiency.js @@ -26,6 +26,6 @@ module.exports = function studentDeficiency(id) { return 'Sim'; case 9: default: - return 'Não declarado' + return 'Não declarado'; } }; -- GitLab From d98f9f19c009efe7c310b816ccdcafec3c7792db Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Mon, 1 Aug 2022 10:33:59 -0300 Subject: [PATCH 211/305] update booleanVariable to convert pattern remove isnull function change type to boolean --- src/libs/convert/booleanVariable.js | 4 ++++ src/libs/middlewares/reqQueryFields.js | 32 ++------------------------ src/libs/routes/universityTeacher.js | 12 +++++----- 3 files changed, 12 insertions(+), 36 deletions(-) diff --git a/src/libs/convert/booleanVariable.js b/src/libs/convert/booleanVariable.js index 65d4ced9..fac47d76 100644 --- a/src/libs/convert/booleanVariable.js +++ b/src/libs/convert/booleanVariable.js @@ -20,8 +20,12 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. module.exports = function booleanVariable(id) { switch(id){ + case 1: + return 'Sim'; case true: return 'Sim'; + case 0: + return 'Não'; case false: return 'Não'; default: diff --git a/src/libs/middlewares/reqQueryFields.js b/src/libs/middlewares/reqQueryFields.js index 3648f9cc..cb93bd82 100644 --- a/src/libs/middlewares/reqQueryFields.js +++ b/src/libs/middlewares/reqQueryFields.js @@ -6,10 +6,6 @@ const id2str = require(`${libs}/middlewares/id2str`); const _ = require('lodash'); -const nullFields = [ - "Não classificado", - "Não classificada" -] function parseWhereValue(type, value, relation) { if (value == null) @@ -33,26 +29,6 @@ function parseWhereValue(type, value, relation) { } } -function getConvertName(whereField){ // TODO: mudar para regex - // Pega nome no formato "exemplo_de_nome" e transforma em "exemploDeNome" - for (var i = 1; i < whereField.length; ++i){ - if (whereField[i] == "_" && i < whereField.length-1) - whereField = whereField.slice(0,i) + whereField[i+1].toUpperCase() + whereField.slice(i+2, whereField.length); - } - return whereField; -} - -function isNull(curFilter, value){ - // TODO: Remove this function - if (value == null) - return true; - let convertName = getConvertName(curFilter) - if (id2str[convertName] !== undefined){ - return nullFields.indexOf(id2str[convertName](value)) > -1 - } - return false; -} - class ReqQueryFields { constructor(fields = {}, fieldValues = {}) { // Exemplo de requisição: `/api/v1/enrollments?dims=state,region,location` @@ -333,10 +309,8 @@ class ReqQueryFields { for(let i = 0; i < whereValue.length; ++i) { let curRelation = value.where.relation; let curValue = parseWhereValue(value.where.type, whereValue[i],value.where.relation) - if (isNull(k, curValue)) { - curValue = null; + if (curValue === null) curRelation = "is"; - } whereString += whereField + ' ' + curRelation + lower; arrayWhereValues.push(curValue); @@ -350,10 +324,8 @@ class ReqQueryFields { let curValue = parseWhereValue(value.where.type, whereValue, value.where.relation) let curRelation = value.where.relation; - if (isNull(k, curValue) ) { - curValue = null; + if (curValue === null ) curRelation = "is"; - } sql.where(whereField + ' ' + curRelation + lower, curValue); } diff --git a/src/libs/routes/universityTeacher.js b/src/libs/routes/universityTeacher.js index 1f14942f..f65a29b2 100644 --- a/src/libs/routes/universityTeacher.js +++ b/src/libs/routes/universityTeacher.js @@ -395,7 +395,7 @@ rqf.addField({ resultField: 'substitute_id', where: { relation: '=', - type: 'integer', + type: 'boolean', field: 'docente_substituto' } }).addValue({ @@ -405,7 +405,7 @@ rqf.addField({ resultField: 'visitor_id', where: { relation: '=', - type: 'integer', + type: 'boolean', field: 'docente_visitante' } }).addValue({ @@ -415,7 +415,7 @@ rqf.addField({ resultField: 'ead_teacher_id', where: { relation: '=', - type: 'integer', + type: 'boolean', field: 'ministra_aula_ead' } }).addValue({ @@ -425,7 +425,7 @@ rqf.addField({ resultField: 'graduation_presential_id', where: { relation: '=', - type: 'integer', + type: 'boolean', field: 'atua_atividade_graduacao_presencial' } }).addValue({ @@ -435,7 +435,7 @@ rqf.addField({ resultField: 'postgraduate_ead_teacher_id', where: { relation: '=', - type: 'integer', + type: 'boolean', field: 'atua_atividade_posgraduacao_distancia' } }).addValue({ @@ -445,7 +445,7 @@ rqf.addField({ resultField: 'postgraduate_presential_teacher_id', where: { relation: '=', - type: 'integer', + type: 'boolean', field: 'atua_atividade_posgraduacao_presencial' } }).addValue({ -- GitLab From 2dfb95839e9cc79bc3a04d0e32bd5f9528859db0 Mon Sep 17 00:00:00 2001 From: "Henrique V. Ehrenfried" <h.v.ehrenfried@hotmail.com> Date: Tue, 2 Aug 2022 11:46:48 -0300 Subject: [PATCH 212/305] Fix missing space Signed-off-by: Henrique V. Ehrenfried <h.v.ehrenfried@hotmail.com> --- src/libs/convert/stateName.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/convert/stateName.js b/src/libs/convert/stateName.js index 7b526379..092969fa 100644 --- a/src/libs/convert/stateName.js +++ b/src/libs/convert/stateName.js @@ -37,7 +37,7 @@ module.exports = function stateName(id) { case 21: return 'Maranhão'; case 22: - return'Piauí'; + return 'Piauí'; case 23: return 'Ceará'; case 24: -- GitLab From c0a4f412d4ffd79b73ff631000106da23269ca46 Mon Sep 17 00:00:00 2001 From: Pietro <ppc19@inf.ufpr.br> Date: Wed, 3 Aug 2022 09:50:36 -0300 Subject: [PATCH 213/305] remove console.log --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 205f5401..d08ae08e 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -777,7 +777,7 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { .order('matricula.ano_censo') .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); next(); -}, rqf.build(), (req, res, next) => {console.log(req.sql.toString()); next();}, query, id2str.transform(false), response('enrollment')); +}, rqf.build(), query, id2str.transform(false), response('enrollment')); enrollmentApp.get('/diagnosis', rqf.parse(), (req, res, next) => { req.dims = {}; -- GitLab From fb77609b5092380e60af4c8ad120e4cc57139d00 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Wed, 3 Aug 2022 10:18:26 -0300 Subject: [PATCH 214/305] Add pee_por_categoria --- src/libs/middlewares/reqQueryFields.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/middlewares/reqQueryFields.js b/src/libs/middlewares/reqQueryFields.js index 3648f9cc..fa679e35 100644 --- a/src/libs/middlewares/reqQueryFields.js +++ b/src/libs/middlewares/reqQueryFields.js @@ -196,6 +196,14 @@ class ReqQueryFields { // No exemplo `{'state': 41}` } + let categorias = ['', 'blindness', 'low_vision', 'deafness', 'hearing_deficiency', 'deafblindness', 'physical_disability', 'intellectual_disability', + 'multiple_disabilities', 'autism', 'asperger_syndrom', 'rett_syndrom', 'childhood_desintegrative_disorder', 'supergifted']; + + if(obj.pee_por_categoria !== 'undefined') + for(var cat of obj.pee_por_categoria) + obj[categorias[cat]] = true; + + // Se o array existe e não está vazio fazemos a interseção if (typeof arrayOfParams !== 'undefined' && arrayOfParams.length > 0) { // Fazemos a interseção das chaves de `obj` com o array `arrayOfParams`. -- GitLab From 5ba8011a6384727ed9dec63c7e66deef2d008ef5 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Wed, 3 Aug 2022 11:29:04 -0300 Subject: [PATCH 215/305] Fix bug in pee_por_categoria --- src/libs/middlewares/reqQueryFields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/middlewares/reqQueryFields.js b/src/libs/middlewares/reqQueryFields.js index eea79074..6e36158c 100644 --- a/src/libs/middlewares/reqQueryFields.js +++ b/src/libs/middlewares/reqQueryFields.js @@ -175,7 +175,7 @@ class ReqQueryFields { let categorias = ['', 'blindness', 'low_vision', 'deafness', 'hearing_deficiency', 'deafblindness', 'physical_disability', 'intellectual_disability', 'multiple_disabilities', 'autism', 'asperger_syndrom', 'rett_syndrom', 'childhood_desintegrative_disorder', 'supergifted']; - if(obj.pee_por_categoria !== 'undefined') + if(obj.pee_por_categoria != 'undefined') for(var cat of obj.pee_por_categoria) obj[categorias[cat]] = true; -- GitLab From 6cac0455ab60f9ab27b942c2dc7a69e1782edc2a Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Wed, 3 Aug 2022 11:34:16 -0300 Subject: [PATCH 216/305] Fix bug in pee_por_categoria(2) --- src/libs/middlewares/reqQueryFields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/middlewares/reqQueryFields.js b/src/libs/middlewares/reqQueryFields.js index 6e36158c..d246240a 100644 --- a/src/libs/middlewares/reqQueryFields.js +++ b/src/libs/middlewares/reqQueryFields.js @@ -175,7 +175,7 @@ class ReqQueryFields { let categorias = ['', 'blindness', 'low_vision', 'deafness', 'hearing_deficiency', 'deafblindness', 'physical_disability', 'intellectual_disability', 'multiple_disabilities', 'autism', 'asperger_syndrom', 'rett_syndrom', 'childhood_desintegrative_disorder', 'supergifted']; - if(obj.pee_por_categoria != 'undefined') + if(obj.pee_por_categoria !== undefined) for(var cat of obj.pee_por_categoria) obj[categorias[cat]] = true; -- GitLab From e398b60ad512fba281f7a4809e05f7bd219b64f2 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 4 Aug 2022 10:54:30 -0300 Subject: [PATCH 217/305] Update filters --- src/libs/routes/disciplines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 223baa1d..859fde88 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -571,7 +571,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente.ano_censo') .order('docente.ano_censo') - .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); -- GitLab From 8f974b1e3dc29f5b2d3f5e83411113fb9ae2a693 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 4 Aug 2022 11:34:33 -0300 Subject: [PATCH 218/305] Update filters(2) --- src/libs/routes/disciplines.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 859fde88..b0398f12 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -572,9 +572,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .group('docente.ano_censo') .order('docente.ano_censo') .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ - OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ - etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); + (etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12)'); } next(); -- GitLab From 5aad998e1cd428bc0c17bf063bb0835914214bce Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 4 Aug 2022 11:40:00 -0300 Subject: [PATCH 219/305] Update filters(3) --- src/libs/routes/disciplines.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index b0398f12..8a285610 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -527,10 +527,8 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .from('docente') .group('docente.ano_censo') .order('docente.ano_censo') - .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ - OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ - etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); + .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + (etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12)'); } else if ('discipline' in req.filter) { const disciplines = ['quimica', 'fisica', 'matematica', 'biologia', 'ciencias', 'lingua_portuguesa', 'lingua_inglesa', 'lingua_espanhola', 'lingua_francesa', 'lingua_outra', 'lingua_indigena', 'artes', 'educacao_fisica', 'historia', 'geografia', 'filosofia', 'ensino_religioso', 'estudos_sociais', 'sociologia'] @@ -557,10 +555,8 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente.ano_censo') .order('docente.ano_censo') - .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ - OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ - etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); + .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + (etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12)'); } else { req.sql.field('SUM(n_disc)', 'total') -- GitLab From 55c7a8f66bd0ec4b666b650244f4ff2c6b5ccf8a Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 4 Aug 2022 11:44:59 -0300 Subject: [PATCH 220/305] Update filters(4) --- src/libs/routes/disciplines.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 8a285610..20ca5885 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -528,7 +528,9 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .group('docente.ano_censo') .order('docente.ano_censo') .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - (etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12)'); + ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ + OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ + etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); } else if ('discipline' in req.filter) { const disciplines = ['quimica', 'fisica', 'matematica', 'biologia', 'ciencias', 'lingua_portuguesa', 'lingua_inglesa', 'lingua_espanhola', 'lingua_francesa', 'lingua_outra', 'lingua_indigena', 'artes', 'educacao_fisica', 'historia', 'geografia', 'filosofia', 'ensino_religioso', 'estudos_sociais', 'sociologia'] @@ -556,7 +558,9 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .group('docente.ano_censo') .order('docente.ano_censo') .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - (etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12)'); + ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ + OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ + etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); } else { req.sql.field('SUM(n_disc)', 'total') @@ -568,7 +572,9 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .group('docente.ano_censo') .order('docente.ano_censo') .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - (etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12)'); + ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ + OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ + etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); } next(); -- GitLab From ab8d1f4c77d81b19aea89b26b83f2c70051d319f Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 5 Aug 2022 11:09:07 -0300 Subject: [PATCH 221/305] Update filters disciplines --- src/libs/routes/disciplines.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 20ca5885..a6cde953 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -571,10 +571,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente.ano_censo') .order('docente.ano_censo') - .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ - OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ - etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); + .where('etapas_mod_ensino_segmento_id<=3 AND ((situacao_curso_1=1 AND (cod_curso_escolaridade_sup_1="142P01" OR (cod_curso_escolaridade_sup_1="142C01" AND (cod_area_complementacao_pedagogica_1=25 OR cod_area_complementacao_pedagogica_2=25 OR cod_area_complementacao_pedagogica_3=25)) OR (cod_curso_escolaridade_sup_1="144N01"))) OR (situacao_curso_2=1 AND (cod_curso_escolaridade_sup_2="142P01" OR (cod_curso_escolaridade_sup_2="142C01" AND (cod_area_complementacao_pedagogica_1=25 OR cod_area_complementacao_pedagogica_2=25 OR cod_area_complementacao_pedagogica_3=25)) OR (cod_curso_escolaridade_sup_2="144N01"))) OR (situacao_curso_3=1 AND (cod_curso_escolaridade_sup_3="142P01" OR (cod_curso_escolaridade_sup_3="142C01" AND (cod_area_complementacao_pedagogica_1=25 OR cod_area_complementacao_pedagogica_2=25 OR cod_area_complementacao_pedagogica_3=25)) OR (cod_curso_escolaridade_sup_3="144N01"))))'); } next(); -- GitLab From 39026a4cf43ec908e2ce4af1507a47622eb21871 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Fri, 5 Aug 2022 11:37:56 -0300 Subject: [PATCH 222/305] Fixed the email issue --- src/libs/routes/message.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/message.js b/src/libs/routes/message.js index 56427865..f9e0e330 100644 --- a/src/libs/routes/message.js +++ b/src/libs/routes/message.js @@ -34,8 +34,9 @@ messageApp.post('/', (req, res, next) => { var sub = "Contato " + reqOrigin let mailOptions = { - from: `\"${reqName}\" <${reqEmail}>`, - text: reqContents, + to: ["dadoseducacionais@ufpr.br", reqEmail], + from: `\"${reqName}\" <dadoseducacionais@ufpr.br>`, + text: reqContents, subject: sub } @@ -51,5 +52,4 @@ messageApp.post('/', (req, res, next) => { }); }) -module.exports = messageApp; - +module.exports = messageApp; \ No newline at end of file -- GitLab From 7b040277158cbb62bb9a4a07a9d17e31b721ed67 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Mon, 8 Aug 2022 09:40:39 -0300 Subject: [PATCH 223/305] Update disciplines - filters --- src/libs/routes/disciplines.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index a6cde953..915608a3 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -528,9 +528,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .group('docente.ano_censo') .order('docente.ano_censo') .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ - OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ - etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); + (etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12)'); } else if ('discipline' in req.filter) { const disciplines = ['quimica', 'fisica', 'matematica', 'biologia', 'ciencias', 'lingua_portuguesa', 'lingua_inglesa', 'lingua_espanhola', 'lingua_francesa', 'lingua_outra', 'lingua_indigena', 'artes', 'educacao_fisica', 'historia', 'geografia', 'filosofia', 'ensino_religioso', 'estudos_sociais', 'sociologia'] -- GitLab From 080fb67c6ca28c6af153ffad18388b599dfbfda5 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Mon, 8 Aug 2022 09:48:48 -0300 Subject: [PATCH 224/305] Update disciplines - filters(2) --- src/libs/routes/disciplines.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 915608a3..3ed46b79 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -569,7 +569,8 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente.ano_censo') .order('docente.ano_censo') - .where('etapas_mod_ensino_segmento_id<=3 AND ((situacao_curso_1=1 AND (cod_curso_escolaridade_sup_1="142P01" OR (cod_curso_escolaridade_sup_1="142C01" AND (cod_area_complementacao_pedagogica_1=25 OR cod_area_complementacao_pedagogica_2=25 OR cod_area_complementacao_pedagogica_3=25)) OR (cod_curso_escolaridade_sup_1="144N01"))) OR (situacao_curso_2=1 AND (cod_curso_escolaridade_sup_2="142P01" OR (cod_curso_escolaridade_sup_2="142C01" AND (cod_area_complementacao_pedagogica_1=25 OR cod_area_complementacao_pedagogica_2=25 OR cod_area_complementacao_pedagogica_3=25)) OR (cod_curso_escolaridade_sup_2="144N01"))) OR (situacao_curso_3=1 AND (cod_curso_escolaridade_sup_3="142P01" OR (cod_curso_escolaridade_sup_3="142C01" AND (cod_area_complementacao_pedagogica_1=25 OR cod_area_complementacao_pedagogica_2=25 OR cod_area_complementacao_pedagogica_3=25)) OR (cod_curso_escolaridade_sup_3="144N01"))))'); + .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + (etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12)'); } next(); -- GitLab From 6c2c2fd0b1b9f67593e8b1aaa9bd209a5da3c0b7 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Tue, 9 Aug 2022 09:13:24 -0300 Subject: [PATCH 225/305] Fix pee indicator --- src/libs/routes/enrollment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index d08ae08e..e8ce942e 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -242,8 +242,8 @@ enrollmentApp.get('/special_class', (req, res, next) => { enrollmentApp.get('/pee', (req, res, next) => { req.result = [ {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} + {id: false, name: 'Não'}, + {id: true, name: 'Sim'} ]; next(); }, response('pee')) -- GitLab From 0cc7316c15ee5769e9c6fd56dbeefb435e9891b9 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Tue, 9 Aug 2022 09:46:30 -0300 Subject: [PATCH 226/305] Fix enrollment - pee --- src/libs/routes/enrollment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index e8ce942e..d08ae08e 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -242,8 +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: 0, name: 'Não'}, + {id: 1, name: 'Sim'} ]; next(); }, response('pee')) -- GitLab From b2d70daf63b3150bddd4359edc1176a8ae620ac5 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Tue, 9 Aug 2022 10:06:41 -0300 Subject: [PATCH 227/305] Fix enrollment - pee(2) --- src/libs/routes/enrollment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index d08ae08e..e8ce942e 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -242,8 +242,8 @@ enrollmentApp.get('/special_class', (req, res, next) => { enrollmentApp.get('/pee', (req, res, next) => { req.result = [ {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} + {id: false, name: 'Não'}, + {id: true, name: 'Sim'} ]; next(); }, response('pee')) -- GitLab From ea3ce29ed1092d5a5f89be2ebbcbc9ca314d9bb6 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Wed, 10 Aug 2022 11:09:26 -0300 Subject: [PATCH 228/305] Update pee_por_categoria --- src/libs/routes/enrollment.js | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index e8ce942e..1a2eaf39 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -770,12 +770,34 @@ rqf.addField({ }); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { - req.sql.field('COUNT(*)', 'total') - .field('matricula.ano_censo', 'year') - .from('matricula') - .group('matricula.ano_censo') - .order('matricula.ano_censo') - .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); + if('pee_por_categotria' in req.field){ + req.sql.field('SUM(SUM(CASE WHEN cegueira = true THEN 1 ELSE 0)', 'total_cegueira') + .field('SUM(CASE WHEN baixa_visao = true THEN 1 ELSE 0)', 'total_baixa_visao') + .field('SUM(CASE WHEN surdez = true THEN 1 ELSE 0)', 'total_surdez') + .field('SUM(CASE WHEN deficiencia_auditiva = true THEN 1 ELSE 0)', 'total_deficiencia_auditiva') + .field('SUM(CASE WHEN surdo_cegueira = true THEN 1 ELSE 0)', 'total_surdo_cegueira') + .field('SUM(CASE WHEN deficiencia_fisica = true THEN 1 ELSE 0)', 'total_deficiencia_fisica') + .field('SUM(CASE WHEN deficiencia_intelectual = true THEN 1 ELSE 0)', 'total_deficiencia_intelectual') + .field('SUM(CASE WHEN deficiencia_multiplas = true THEN 1 ELSE 0)', 'total_deficiencia_multiplas') + .field('SUM(CASE WHEN autismo = true THEN 1 ELSE 0)', 'total_autismo') + .field('SUM(CASE WHEN sindrome_asperger = true THEN 1 ELSE 0)', 'total_sindrome_asperger') + .field('SUM(CASE WHEN sindrome_rett = true THEN 1 ELSE 0)', 'total_sindrome_rett') + .field('SUM(CASE WHEN transtorno_desintegrativo_da_infancia = true THEN 1 ELSE 0)', 'total_transtorno_desintegrativo_da_infancia') + .field('SUM(CASE WHEN superdotado = true THEN 1 ELSE 0)', 'total_superdotado') + .field('matricula.ano_censo', 'year') + .from('matricula') + .group('matricula.ano_censo') + .order('matricula.ano_censo') + .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); + } + else{ + req.sql.field('COUNT(*)', 'total') + .field('matricula.ano_censo', 'year') + .from('matricula') + .group('matricula.ano_censo') + .order('matricula.ano_censo') + .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); + } next(); }, rqf.build(), query, id2str.transform(false), response('enrollment')); -- GitLab From 9f3cccbab02295a74285f83d0dfa432b29e6e33c Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Wed, 10 Aug 2022 11:15:15 -0300 Subject: [PATCH 229/305] Fix pee_por_categoria --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 1a2eaf39..dab001dd 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -770,7 +770,7 @@ rqf.addField({ }); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { - if('pee_por_categotria' in req.field){ + if('pee_por_categotria' in req.dims){ req.sql.field('SUM(SUM(CASE WHEN cegueira = true THEN 1 ELSE 0)', 'total_cegueira') .field('SUM(CASE WHEN baixa_visao = true THEN 1 ELSE 0)', 'total_baixa_visao') .field('SUM(CASE WHEN surdez = true THEN 1 ELSE 0)', 'total_surdez') -- GitLab From ea8236e754941e338124e17a8ae2f018aa5662ed Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Wed, 10 Aug 2022 11:19:00 -0300 Subject: [PATCH 230/305] fix convert files --- src/libs/convert/integralTime.js | 2 +- src/libs/convert/upperTurn.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/convert/integralTime.js b/src/libs/convert/integralTime.js index 44f2abdb..c780342b 100644 --- a/src/libs/convert/integralTime.js +++ b/src/libs/convert/integralTime.js @@ -25,6 +25,6 @@ module.exports = function integralTime(id) { case 1: return 'Sim'; case 2: - return 'Não se aplica - Semi presencial e EaD'; + return 'Não se aplica - Semipresencial e EaD'; } }; diff --git a/src/libs/convert/upperTurn.js b/src/libs/convert/upperTurn.js index e5860ee3..3a751dd4 100644 --- a/src/libs/convert/upperTurn.js +++ b/src/libs/convert/upperTurn.js @@ -28,7 +28,7 @@ module.exports = function upperTurn(id) { return 'Noturno'; case 4: return 'Integral'; - case 99: + case "null": return 'Não aplicavel (Ead)'; default: return 'Não classificada'; -- GitLab From 07e3399b179a02c3731e2f8110f367ca8bba07fd Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Wed, 10 Aug 2022 11:25:39 -0300 Subject: [PATCH 231/305] Fix pee_por_categoria(2) --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index dab001dd..41317d6d 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -771,7 +771,7 @@ rqf.addField({ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { if('pee_por_categotria' in req.dims){ - req.sql.field('SUM(SUM(CASE WHEN cegueira = true THEN 1 ELSE 0)', 'total_cegueira') + req.sql.field('SUM(CASE WHEN cegueira = true THEN 1 ELSE 0)', 'total_cegueira') .field('SUM(CASE WHEN baixa_visao = true THEN 1 ELSE 0)', 'total_baixa_visao') .field('SUM(CASE WHEN surdez = true THEN 1 ELSE 0)', 'total_surdez') .field('SUM(CASE WHEN deficiencia_auditiva = true THEN 1 ELSE 0)', 'total_deficiencia_auditiva') -- GitLab From 48441f1f171b6429f049a3b0094a6e63449f696a Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Wed, 10 Aug 2022 11:33:35 -0300 Subject: [PATCH 232/305] Fix pee_por_categoria(3) --- src/libs/middlewares/reqQueryFields.js | 2 +- src/libs/routes/enrollment.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/middlewares/reqQueryFields.js b/src/libs/middlewares/reqQueryFields.js index d246240a..720e84aa 100644 --- a/src/libs/middlewares/reqQueryFields.js +++ b/src/libs/middlewares/reqQueryFields.js @@ -175,7 +175,7 @@ class ReqQueryFields { let categorias = ['', 'blindness', 'low_vision', 'deafness', 'hearing_deficiency', 'deafblindness', 'physical_disability', 'intellectual_disability', 'multiple_disabilities', 'autism', 'asperger_syndrom', 'rett_syndrom', 'childhood_desintegrative_disorder', 'supergifted']; - if(obj.pee_por_categoria !== undefined) + if(obj.pee_por_categoria !== undefined && queryField === 'filter') for(var cat of obj.pee_por_categoria) obj[categorias[cat]] = true; diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 41317d6d..26c2bd88 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -770,7 +770,8 @@ rqf.addField({ }); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { - if('pee_por_categotria' in req.dims){ + console.log(req.dims) + if('pee_por_categoria' in req.dims){ req.sql.field('SUM(CASE WHEN cegueira = true THEN 1 ELSE 0)', 'total_cegueira') .field('SUM(CASE WHEN baixa_visao = true THEN 1 ELSE 0)', 'total_baixa_visao') .field('SUM(CASE WHEN surdez = true THEN 1 ELSE 0)', 'total_surdez') -- GitLab From 47e5d250475e9f7344aecc1d29eeee9469779fa7 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Wed, 10 Aug 2022 11:47:19 -0300 Subject: [PATCH 233/305] Fix pee_por_categoria(4) --- src/libs/routes/enrollment.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 26c2bd88..8abb06bf 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -767,11 +767,22 @@ rqf.addField({ type: 'boolean', field: 'possui_necessidade_especial' } +}).addValueToField({ + name: 'pee_por_categoria', + table: 'matricula', + tableField: '', + resultField: 'pee_por_categoria', + where: { + relation: '=', + type: 'boolean', + field: '' + } }); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { console.log(req.dims) if('pee_por_categoria' in req.dims){ + delete req.dims.pee_por_categoria req.sql.field('SUM(CASE WHEN cegueira = true THEN 1 ELSE 0)', 'total_cegueira') .field('SUM(CASE WHEN baixa_visao = true THEN 1 ELSE 0)', 'total_baixa_visao') .field('SUM(CASE WHEN surdez = true THEN 1 ELSE 0)', 'total_surdez') -- GitLab From c5720582b8e1e57e6d4ca65389bc8539630ae766 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 11 Aug 2022 09:13:26 -0300 Subject: [PATCH 234/305] Fix pee_por_categoria - dims --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 8abb06bf..6f1b10c1 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -777,7 +777,7 @@ rqf.addField({ type: 'boolean', field: '' } -}); +}, 'dims'); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { console.log(req.dims) -- GitLab From ab319ffb64309c8b2ccbfa6d85edf637a267ed0e Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 11 Aug 2022 09:19:22 -0300 Subject: [PATCH 235/305] Fix pee_por_categoria - dims(2) --- src/libs/routes/enrollment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 6f1b10c1..58cfe921 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -770,12 +770,12 @@ rqf.addField({ }).addValueToField({ name: 'pee_por_categoria', table: 'matricula', - tableField: '', + tableField: 'possui_necessidade_especial', resultField: 'pee_por_categoria', where: { relation: '=', type: 'boolean', - field: '' + field: 'possui_necessidade_especial' } }, 'dims'); -- GitLab From bf46d199a60a29a922641fb90b752071351b3a5b Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 11 Aug 2022 09:27:02 -0300 Subject: [PATCH 236/305] Fix pee_por_categoria - dims(3) --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 58cfe921..f58cec35 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -777,7 +777,7 @@ rqf.addField({ type: 'boolean', field: 'possui_necessidade_especial' } -}, 'dims'); +}); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { console.log(req.dims) -- GitLab From 2df7fc2bda8fc4dd915c8ae1912268134e02de95 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 11 Aug 2022 09:31:03 -0300 Subject: [PATCH 237/305] Fix pee_por_categoria - dims(2) --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index f58cec35..58cfe921 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -777,7 +777,7 @@ rqf.addField({ type: 'boolean', field: 'possui_necessidade_especial' } -}); +}, 'dims'); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { console.log(req.dims) -- GitLab From 8cb4bf2060dad1cdff094d1ae6d89974a906f8c7 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 11 Aug 2022 09:43:08 -0300 Subject: [PATCH 238/305] Fix query in pee_por_categoria --- src/libs/routes/enrollment.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 58cfe921..26e1cb30 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -783,19 +783,19 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { console.log(req.dims) if('pee_por_categoria' in req.dims){ delete req.dims.pee_por_categoria - req.sql.field('SUM(CASE WHEN cegueira = true THEN 1 ELSE 0)', 'total_cegueira') - .field('SUM(CASE WHEN baixa_visao = true THEN 1 ELSE 0)', 'total_baixa_visao') - .field('SUM(CASE WHEN surdez = true THEN 1 ELSE 0)', 'total_surdez') - .field('SUM(CASE WHEN deficiencia_auditiva = true THEN 1 ELSE 0)', 'total_deficiencia_auditiva') - .field('SUM(CASE WHEN surdo_cegueira = true THEN 1 ELSE 0)', 'total_surdo_cegueira') - .field('SUM(CASE WHEN deficiencia_fisica = true THEN 1 ELSE 0)', 'total_deficiencia_fisica') - .field('SUM(CASE WHEN deficiencia_intelectual = true THEN 1 ELSE 0)', 'total_deficiencia_intelectual') - .field('SUM(CASE WHEN deficiencia_multiplas = true THEN 1 ELSE 0)', 'total_deficiencia_multiplas') - .field('SUM(CASE WHEN autismo = true THEN 1 ELSE 0)', 'total_autismo') - .field('SUM(CASE WHEN sindrome_asperger = true THEN 1 ELSE 0)', 'total_sindrome_asperger') - .field('SUM(CASE WHEN sindrome_rett = true THEN 1 ELSE 0)', 'total_sindrome_rett') - .field('SUM(CASE WHEN transtorno_desintegrativo_da_infancia = true THEN 1 ELSE 0)', 'total_transtorno_desintegrativo_da_infancia') - .field('SUM(CASE WHEN superdotado = true THEN 1 ELSE 0)', 'total_superdotado') + 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') .field('matricula.ano_censo', 'year') .from('matricula') .group('matricula.ano_censo') -- GitLab From 6da00ebfee589058e279aa8c2235c3b5f3c00629 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Thu, 11 Aug 2022 11:07:25 -0300 Subject: [PATCH 239/305] add city subroutes and filters --- src/libs/routes/city.js | 43 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/city.js b/src/libs/routes/city.js index ef28500f..2ebc44d2 100644 --- a/src/libs/routes/city.js +++ b/src/libs/routes/city.js @@ -82,7 +82,25 @@ rqf.addField({ type: 'string', field: 'nome' } -}, 'search');; +}, 'search').addValue({ + name: 'mesoregion', + table: 'municipio', + tableField: 'mesorregiao_id', + where: { + relation: '=', + type: 'integer', + field: 'mesorregiao_id' + } +}).addValue({ + name: 'microregion', + table: 'municipio', + tableField: 'microrregiao_id', + where: { + relation: '=', + type: 'integer', + field: 'microrregiao_id' + } +}); // Return all cities cityApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { @@ -97,4 +115,27 @@ cityApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { next(); }, query, response('city')); +cityApp.get('/microregion', rqf.parse(), rqf.build(), (req, res, next) => { + req.sql.from('municipio') + .field('municipio.estado_id', 'state_id') + .field('municipio.microrregiao_id', 'microregion_id') + .field('municipio.nome_microrregiao', 'microregion_name') + .group('municipio.estado_id') + .group('municipio.microrregiao_id') + .group('municipio.nome_microrregiao') + next(); +}, query, response('city/microregion')); + +cityApp.get('/mesoregion', rqf.parse(), rqf.build(), (req, res, next) => { + req.sql.from('municipio') + .field('municipio.estado_id', 'state_id') + .field('municipio.mesorregiao_id', 'mesoregion_id') + .field('municipio.nome_mesorregiao', 'mesoregion_name') + .group('municipio.nome_mesorregiao') + .group('municipio.mesorregiao_id') + .group('municipio.estado_id') + next(); +}, query, response('city/mesoregion')); + + module.exports = cityApp; -- GitLab From e8ce12e01221fa033bd288b9f549ec9c2c56a3bc Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 11 Aug 2022 11:45:58 -0300 Subject: [PATCH 240/305] Update dims pee_por_categoria --- src/libs/routes/enrollment.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 26e1cb30..52788490 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -19,6 +19,7 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. */ const express = require('express'); +const { result } = require('lodash'); const enrollmentApp = express.Router(); @@ -811,7 +812,29 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); } next(); -}, rqf.build(), query, id2str.transform(false), response('enrollment')); +}, rqf.build(), query, id2str.transform(false), (req, res, next) => { + if('pee_por_categoria' in req.dims){ + let result_total = []; + for (var j = 0;j < result.result.length;j++){ + let result_parcial = result.result[j]; + for (var i in result_parcial){ + if(i !== 'year'){ + let obj = { + category_name: '', + year: 0, + total: 0 + }; + obj.category_name = i; + obj.total = result_parcial[i]; + obj.year = result_parcial.year; + result_total.push(obj); + } + } + } + req.result = result_total; + } + next(); +}, response('enrollment')); enrollmentApp.get('/diagnosis', rqf.parse(), (req, res, next) => { req.dims = {}; -- GitLab From 4e4691d86c1001ccbcc579160cf951226310b408 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 11 Aug 2022 11:54:52 -0300 Subject: [PATCH 241/305] Update dims pee_por_categoria(2) --- src/libs/routes/enrollment.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 52788490..4ecf62be 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -814,6 +814,7 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { next(); }, rqf.build(), query, id2str.transform(false), (req, res, next) => { if('pee_por_categoria' in req.dims){ + result = req.result; let result_total = []; for (var j = 0;j < result.result.length;j++){ let result_parcial = result.result[j]; -- GitLab From d2e860a456d15693e5dda3d46632db210a7b7900 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 11 Aug 2022 11:57:55 -0300 Subject: [PATCH 242/305] Fix dims pee_por_categoria(2) --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 4ecf62be..71eeeba5 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -814,7 +814,7 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { next(); }, rqf.build(), query, id2str.transform(false), (req, res, next) => { if('pee_por_categoria' in req.dims){ - result = req.result; + let result = req.result; let result_total = []; for (var j = 0;j < result.result.length;j++){ let result_parcial = result.result[j]; -- GitLab From 6f9471a3d72250b6117464386fe4014d21ee3655 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Fri, 12 Aug 2022 08:52:22 -0300 Subject: [PATCH 243/305] hotfix converts --- src/libs/convert/integralTime.js | 2 +- src/libs/convert/upperTurn.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/convert/integralTime.js b/src/libs/convert/integralTime.js index 44f2abdb..c780342b 100644 --- a/src/libs/convert/integralTime.js +++ b/src/libs/convert/integralTime.js @@ -25,6 +25,6 @@ module.exports = function integralTime(id) { case 1: return 'Sim'; case 2: - return 'Não se aplica - Semi presencial e EaD'; + return 'Não se aplica - Semipresencial e EaD'; } }; diff --git a/src/libs/convert/upperTurn.js b/src/libs/convert/upperTurn.js index e5860ee3..9c79f472 100644 --- a/src/libs/convert/upperTurn.js +++ b/src/libs/convert/upperTurn.js @@ -29,6 +29,7 @@ module.exports = function upperTurn(id) { case 4: return 'Integral'; case 99: + case "null": return 'Não aplicavel (Ead)'; default: return 'Não classificada'; -- GitLab From 35374464b4cfc44ad8d84e4f94ec5835157175a9 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 12 Aug 2022 10:34:06 -0300 Subject: [PATCH 244/305] Update enrollment - test --- src/libs/routes/enrollment.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 71eeeba5..6b67f302 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -833,6 +833,8 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { } } req.result = result_total; + console.log(req.result); + console.log(result_total); } next(); }, response('enrollment')); -- GitLab From 7ef3aa8b544798d5dc509f2e5467e15fc9341ac5 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 12 Aug 2022 11:09:20 -0300 Subject: [PATCH 245/305] Update enrollment - test(2) --- src/libs/routes/enrollment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 6b67f302..86449bc0 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -833,8 +833,8 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { } } req.result = result_total; - console.log(req.result); - console.log(result_total); + console.log('bruto ' + req.result); + console.log('filtrado ' + result_total); } next(); }, response('enrollment')); -- GitLab From 0deb537116b88caa449f39448b82187bb0524d24 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 12 Aug 2022 11:18:16 -0300 Subject: [PATCH 246/305] Update enrollment - test(3) --- src/libs/routes/enrollment.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 86449bc0..b085651a 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -784,6 +784,7 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { console.log(req.dims) 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') @@ -813,7 +814,7 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { } next(); }, rqf.build(), query, id2str.transform(false), (req, res, next) => { - if('pee_por_categoria' in req.dims){ + if(req.pee_por_categoria === true){ let result = req.result; let result_total = []; for (var j = 0;j < result.result.length;j++){ -- GitLab From 73721ff5f1a0fcc726df84bcc43b340ac56b0433 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 12 Aug 2022 11:23:41 -0300 Subject: [PATCH 247/305] Update enrollment - test(4) --- src/libs/routes/enrollment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index b085651a..5ff51430 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -817,8 +817,8 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { if(req.pee_por_categoria === true){ let result = req.result; let result_total = []; - for (var j = 0;j < result.result.length;j++){ - let result_parcial = result.result[j]; + for (var j = 0;j < result.length;j++){ + let result_parcial = result[j]; for (var i in result_parcial){ if(i !== 'year'){ let obj = { -- GitLab From 33c25bee7ebedb06ba281f8fe8b45e956a4e10fa Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Fri, 12 Aug 2022 11:45:50 -0300 Subject: [PATCH 248/305] add mesoregion and microregion filters --- src/libs/routes/city.js | 22 ---------------------- src/libs/routes/mesoregion.js | 12 +++++++++++- src/libs/routes/microregion.js | 21 ++++++++++++++++++++- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/libs/routes/city.js b/src/libs/routes/city.js index 2ebc44d2..1686c850 100644 --- a/src/libs/routes/city.js +++ b/src/libs/routes/city.js @@ -115,27 +115,5 @@ cityApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { next(); }, query, response('city')); -cityApp.get('/microregion', rqf.parse(), rqf.build(), (req, res, next) => { - req.sql.from('municipio') - .field('municipio.estado_id', 'state_id') - .field('municipio.microrregiao_id', 'microregion_id') - .field('municipio.nome_microrregiao', 'microregion_name') - .group('municipio.estado_id') - .group('municipio.microrregiao_id') - .group('municipio.nome_microrregiao') - next(); -}, query, response('city/microregion')); - -cityApp.get('/mesoregion', rqf.parse(), rqf.build(), (req, res, next) => { - req.sql.from('municipio') - .field('municipio.estado_id', 'state_id') - .field('municipio.mesorregiao_id', 'mesoregion_id') - .field('municipio.nome_mesorregiao', 'mesoregion_name') - .group('municipio.nome_mesorregiao') - .group('municipio.mesorregiao_id') - .group('municipio.estado_id') - next(); -}, query, response('city/mesoregion')); - module.exports = cityApp; diff --git a/src/libs/routes/mesoregion.js b/src/libs/routes/mesoregion.js index 0feb7627..001976f2 100644 --- a/src/libs/routes/mesoregion.js +++ b/src/libs/routes/mesoregion.js @@ -60,6 +60,15 @@ rqf.addField({ foreign: 'estado_id', foreignTable: 'municipio' } +}).addValue({ + name: 'mesoregion', + table: 'municipio', + tableField: 'mesorregiao_id', + where: { + relation: '=', + type: 'integer', + field: 'mesorregiao_id' + } }); mesoregionApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { @@ -69,7 +78,8 @@ mesoregionApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { .field('municipio.estado_id', 'state_id') .group('municipio.nome_mesorregiao') .group('municipio.mesorregiao_id') - .group('municipio.estado_id'); + .group('municipio.estado_id') + .order('municipio.mesorregiao_id'); next(); }, query, response('mesoregion')); diff --git a/src/libs/routes/microregion.js b/src/libs/routes/microregion.js index 0b9b0e1a..c4aba0fe 100644 --- a/src/libs/routes/microregion.js +++ b/src/libs/routes/microregion.js @@ -60,6 +60,24 @@ rqf.addField({ foreign: 'estado_id', foreignTable: 'municipio' } +}).addValue({ + name: 'mesoregion', + table: 'municipio', + tableField: 'mesorregiao_id', + where: { + relation: '=', + type: 'integer', + field: 'mesorregiao_id' + } +}).addValue({ + name: 'microregion', + table: 'municipio', + tableField: 'microrregiao_id', + where: { + relation: '=', + type: 'integer', + field: 'microrregiao_id' + } }); microregionApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { @@ -73,7 +91,8 @@ microregionApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { .group('municipio.microrregiao_id') .group('municipio.nome_mesorregiao') .group('municipio.mesorregiao_id') - .group('municipio.estado_id'); + .group('municipio.estado_id') + .order('municipio.microrregiao_id'); next(); }, query, response('microregion')); -- GitLab From bf294db313570424efb4f0192c927bf0b95cdca5 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 12 Aug 2022 11:49:06 -0300 Subject: [PATCH 249/305] Update enrollment - test(5) --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 5ff51430..769f18b2 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -833,7 +833,7 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { } } } - req.result = result_total; + req.result.result = result_total; console.log('bruto ' + req.result); console.log('filtrado ' + result_total); } -- GitLab From 079e171fc19227752e2a964cd3a5f9009ef0deef Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 12 Aug 2022 11:52:16 -0300 Subject: [PATCH 250/305] Update enrollment - test(6) --- src/libs/routes/enrollment.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 769f18b2..972295f6 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -833,9 +833,9 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { } } } - req.result.result = result_total; - console.log('bruto ' + req.result); - console.log('filtrado ' + result_total); + req.result= result_total; + console.log('bruto ' + JSON.stringify(req.result)); + console.log('filtrado ' + JSON.stringify(result_total)); } next(); }, response('enrollment')); -- GitLab From 651db4da29cbf24e13b01f321a392d45caa2d1be Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Mon, 15 Aug 2022 09:43:53 -0300 Subject: [PATCH 251/305] Update filters (add docente.) --- src/libs/routes/disciplines.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 3ed46b79..1b8e456c 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -527,8 +527,8 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .from('docente') .group('docente.ano_censo') .order('docente.ano_censo') - .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - (etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12)'); + .where('docente.tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + (docente.etapas_mod_ensino_segmento_id <> 6 AND docente.etapas_mod_ensino_segmento_id <> 12)'); } else if ('discipline' in req.filter) { const disciplines = ['quimica', 'fisica', 'matematica', 'biologia', 'ciencias', 'lingua_portuguesa', 'lingua_inglesa', 'lingua_espanhola', 'lingua_francesa', 'lingua_outra', 'lingua_indigena', 'artes', 'educacao_fisica', 'historia', 'geografia', 'filosofia', 'ensino_religioso', 'estudos_sociais', 'sociologia'] @@ -555,10 +555,10 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente.ano_censo') .order('docente.ano_censo') - .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + .where('docente.tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ - etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12'); + docente.etapas_mod_ensino_segmento_id <> 6 AND docente.etapas_mod_ensino_segmento_id <> 12'); } else { req.sql.field('SUM(n_disc)', 'total') @@ -569,8 +569,8 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente.ano_censo') .order('docente.ano_censo') - .where('tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - (etapas_mod_ensino_segmento_id <> 6 AND etapas_mod_ensino_segmento_id <> 12)'); + .where('docente.tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + (docente.etapas_mod_ensino_segmento_id <> 6 AND docente.etapas_mod_ensino_segmento_id <> 12)'); } next(); -- GitLab From 83222e48ccd8db75bfb184153e38c995e306b9a5 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Mon, 15 Aug 2022 09:52:55 -0300 Subject: [PATCH 252/305] Update filters (add docente. 2) --- src/libs/routes/disciplines.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 1b8e456c..472c360c 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -528,7 +528,9 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .group('docente.ano_censo') .order('docente.ano_censo') .where('docente.tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - (docente.etapas_mod_ensino_segmento_id <> 6 AND docente.etapas_mod_ensino_segmento_id <> 12)'); + ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ + OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ + docente.etapas_mod_ensino_segmento_id <> 6 AND docente.etapas_mod_ensino_segmento_id <> 12'); } else if ('discipline' in req.filter) { const disciplines = ['quimica', 'fisica', 'matematica', 'biologia', 'ciencias', 'lingua_portuguesa', 'lingua_inglesa', 'lingua_espanhola', 'lingua_francesa', 'lingua_outra', 'lingua_indigena', 'artes', 'educacao_fisica', 'historia', 'geografia', 'filosofia', 'ensino_religioso', 'estudos_sociais', 'sociologia'] @@ -570,7 +572,9 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .group('docente.ano_censo') .order('docente.ano_censo') .where('docente.tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ - (docente.etapas_mod_ensino_segmento_id <> 6 AND docente.etapas_mod_ensino_segmento_id <> 12)'); + ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ + OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ + docente.etapas_mod_ensino_segmento_id <> 6 AND docente.etapas_mod_ensino_segmento_id <> 12'); } next(); -- GitLab From 2fb663a073bf3c68b7f87b017ff4679ce7f61857 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Wed, 17 Aug 2022 11:21:10 -0300 Subject: [PATCH 253/305] add null value --- src/libs/routes/disciplines.js | 7 +++++-- src/libs/routes/teacher.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 3ed46b79..fcdc977f 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -162,8 +162,11 @@ disciplinesApp.get('/gender', (req, res, next) => { disciplinesApp.get('/contract_type', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 5; ++i) { + req.result = [ + id: "null", + name: id2str.contractType("null") + ]; + for(let i = 1; i <= 4; ++i) { req.result.push({ id: i, name: id2str.contractType(i) diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 86bcf184..b35d9987 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -158,8 +158,11 @@ teacherApp.get('/gender', (req, res, next) => { teacherApp.get('/contract_type', (req, res, next) => { - req.result = []; - for(let i = 1; i <= 5; ++i) { + req.result = [ + id: "null", + contractType: id2str.contractType("null") + ]; + for(let i = 1; i <= 4; ++i) { req.result.push({ id: i, name: id2str.contractType(i) -- GitLab From 473e72b15f881337311a85ab492873adbd0efcc4 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Wed, 17 Aug 2022 11:30:02 -0300 Subject: [PATCH 254/305] hotfix null object --- src/libs/routes/disciplines.js | 4 ++-- src/libs/routes/teacher.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 18b4d71a..2a7be226 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -162,10 +162,10 @@ disciplinesApp.get('/gender', (req, res, next) => { disciplinesApp.get('/contract_type', (req, res, next) => { - req.result = [ + req.result = [{ id: "null", name: id2str.contractType("null") - ]; + }]; for(let i = 1; i <= 4; ++i) { req.result.push({ id: i, diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index b35d9987..94e6d86c 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -158,10 +158,10 @@ teacherApp.get('/gender', (req, res, next) => { teacherApp.get('/contract_type', (req, res, next) => { - req.result = [ + req.result = [{ id: "null", contractType: id2str.contractType("null") - ]; + }]; for(let i = 1; i <= 4; ++i) { req.result.push({ id: i, -- GitLab From b9afc5f4a0cf2c566136b394862b21977b37e83f Mon Sep 17 00:00:00 2001 From: Pietro Cavassin <ppc19@inf.ufpr.br> Date: Wed, 17 Aug 2022 14:55:34 +0000 Subject: [PATCH 255/305] Remove tipo_turma_atendimento_id from filter - disciplines.js --- src/libs/routes/disciplines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 2a7be226..096ec582 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -530,7 +530,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { .from('docente') .group('docente.ano_censo') .order('docente.ano_censo') - .where('docente.tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ docente.etapas_mod_ensino_segmento_id <> 6 AND docente.etapas_mod_ensino_segmento_id <> 12'); -- GitLab From f72652f6fe010b9fdce490b9370f2a09b9048fb6 Mon Sep 17 00:00:00 2001 From: Pietro Cavassin <ppc19@inf.ufpr.br> Date: Thu, 18 Aug 2022 13:14:45 +0000 Subject: [PATCH 256/305] Remove filter from disciplines.js --- src/libs/routes/disciplines.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/disciplines.js b/src/libs/routes/disciplines.js index 096ec582..63b05f32 100644 --- a/src/libs/routes/disciplines.js +++ b/src/libs/routes/disciplines.js @@ -560,7 +560,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente.ano_censo') .order('docente.ano_censo') - .where('docente.tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ docente.etapas_mod_ensino_segmento_id <> 6 AND docente.etapas_mod_ensino_segmento_id <> 12'); @@ -574,7 +574,7 @@ disciplinesApp.get('/', rqf.parse(), (req, res, next) => { // .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo') .group('docente.ano_censo') .order('docente.ano_censo') - .where('docente.tipo_turma_atendimento_id <= 2 AND (docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) AND \ docente.etapas_mod_ensino_segmento_id <> 6 AND docente.etapas_mod_ensino_segmento_id <> 12'); -- GitLab From 7b437be2f1fa676426be34392bdb4c8b3e06ff28 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Thu, 18 Aug 2022 11:10:14 -0300 Subject: [PATCH 257/305] remove console.log --- src/libs/routes/enrollment.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 972295f6..4c6a840a 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -781,7 +781,6 @@ rqf.addField({ }, 'dims'); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { - console.log(req.dims) if('pee_por_categoria' in req.dims){ delete req.dims.pee_por_categoria req.pee_por_categoria = true @@ -821,11 +820,7 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { let result_parcial = result[j]; for (var i in result_parcial){ if(i !== 'year'){ - let obj = { - category_name: '', - year: 0, - total: 0 - }; + let obj = {}; obj.category_name = i; obj.total = result_parcial[i]; obj.year = result_parcial.year; @@ -834,8 +829,6 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { } } req.result= result_total; - console.log('bruto ' + JSON.stringify(req.result)); - console.log('filtrado ' + JSON.stringify(result_total)); } next(); }, response('enrollment')); -- GitLab From 552a630698da8267045a869b4cf073a4c5ce5531 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Mon, 22 Aug 2022 09:28:57 -0300 Subject: [PATCH 258/305] fix upper turn convert call --- src/libs/routes/universityEnrollment.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 49707e2e..619bcf8f 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -192,17 +192,16 @@ universityEnrollmentApp.get('/cine_detailed', (req, res, next) => { }, response('cine_detailed')); universityEnrollmentApp.get('/upper_turn', (req, res, next) => { - req.result = []; + req.result = [{ + id: "null", + name: id2str.upperTurn("null") + }]; for(let i = 1; i <= 4; ++i) { req.result.push({ id: i, name: id2str.upperTurn(i) }); }; - req.result.push({ - id: 99, - name: id2str.upperTurn(99) - }); next(); }, response('upper_turn')); -- GitLab From e1790b44585a3bd1e15459fd8f5bbfbb57a70624 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Mon, 22 Aug 2022 11:27:40 -0300 Subject: [PATCH 259/305] Update pee_por_categoria_name --- src/libs/routes/enrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 4c6a840a..b0e710a7 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -821,7 +821,7 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { for (var i in result_parcial){ if(i !== 'year'){ let obj = {}; - obj.category_name = i; + obj.pee_por_categoria_name = i; obj.total = result_parcial[i]; obj.year = result_parcial.year; result_total.push(obj); -- GitLab 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 260/305] 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 From 487f30a7f26a311c11ec30d7d5b8fa96f438d9c0 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 25 Aug 2022 10:12:26 -0300 Subject: [PATCH 261/305] Remove pee.js --- src/libs/convert/pee.js | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 src/libs/convert/pee.js diff --git a/src/libs/convert/pee.js b/src/libs/convert/pee.js deleted file mode 100644 index f7f183f8..00000000 --- a/src/libs/convert/pee.js +++ /dev/null @@ -1,29 +0,0 @@ -/* -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 -- GitLab From b90b9cc8bcf9599237a3a845c9015917a1ee4bba Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Tue, 30 Aug 2022 11:46:33 -0300 Subject: [PATCH 262/305] Add TEA in pee_por_categoria --- src/libs/convert/peePorCategoria.js | 4 +++- src/libs/middlewares/reqQueryFields.js | 10 +++++++--- src/libs/routes/enrollment.js | 24 +++++++++++++++++++----- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/libs/convert/peePorCategoria.js b/src/libs/convert/peePorCategoria.js index 6249ae31..f944fe4e 100644 --- a/src/libs/convert/peePorCategoria.js +++ b/src/libs/convert/peePorCategoria.js @@ -45,6 +45,8 @@ module.exports = function peeCategory(id) { case 12: return 'Transtorno Desintegrativo da Infância'; case 13: - return 'Superdotado'; + return 'Altas habilidades / Superdotação'; + case 14: + return 'Transtorno do Espectro Austista (TEA)'; } }; diff --git a/src/libs/middlewares/reqQueryFields.js b/src/libs/middlewares/reqQueryFields.js index 720e84aa..0891e1b8 100644 --- a/src/libs/middlewares/reqQueryFields.js +++ b/src/libs/middlewares/reqQueryFields.js @@ -173,11 +173,15 @@ class ReqQueryFields { } let categorias = ['', 'blindness', 'low_vision', 'deafness', 'hearing_deficiency', 'deafblindness', 'physical_disability', 'intellectual_disability', - 'multiple_disabilities', 'autism', 'asperger_syndrom', 'rett_syndrom', 'childhood_desintegrative_disorder', 'supergifted']; + 'multiple_disabilities', 'autism', 'asperger_syndrom', 'rett_syndrom', 'childhood_desintegrative_disorder', 'supergifted', 'autism_spectrum_disorder']; - if(obj.pee_por_categoria !== undefined && queryField === 'filter') - for(var cat of obj.pee_por_categoria) + if(obj.pee_por_categoria !== undefined && queryField === 'filter'){ + for(var cat of obj.pee_por_categoria){ + cat = parseInt(cat); obj[categorias[cat]] = true; + } + delete obj.pee_por_categoria; + } // Se o array existe e não está vazio fazemos a interseção diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index fa39a4f0..ac85866f 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -250,7 +250,7 @@ enrollmentApp.get('/pee', (req, res, next) => { enrollmentApp.get('/pee_por_categoria', (req, res, next) => { req.result = []; - for(let i = 1; i <= 13; ++i) { + for(let i = 1; i <= 14; ++i) { req.result.push({ id: i, name: id2str.peePorCategoria(i) @@ -717,6 +717,16 @@ rqf.addField({ type: 'boolean', field: 'autismo' } +}).addValue({ + name: 'autism_spectrum_disorder', + table: 'matricula', + tableField: 'transtorno_espectro_autista', + resultField: 'autism_spectrum_disorder', + where: { + relation: '=', + type: 'boolean', + field: 'transtorno_espectro_autista' + } }).addValue({ name: 'asperger_syndrom', table: 'matricula', @@ -767,7 +777,7 @@ rqf.addField({ type: 'boolean', field: 'possui_necessidade_especial' } -}).addValueToField({ +}).addValue({ name: 'pee_por_categoria', table: 'matricula', tableField: 'possui_necessidade_especial', @@ -777,7 +787,7 @@ rqf.addField({ type: 'boolean', field: 'possui_necessidade_especial' } -}, 'dims'); +}); enrollmentApp.get('/', rqf.parse(), (req, res, next) => { if('pee_por_categoria' in req.dims){ @@ -792,10 +802,11 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { .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 transtorno_espectro_autista = true THEN 1 ELSE 0 END)', 'Transtorno do Espectro Autista (TEA)') .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('SUM(CASE WHEN superdotado = true THEN 1 ELSE 0 END)', 'Altas habilidades / Superdotação') .field('matricula.ano_censo', 'year') .from('matricula') .group('matricula.ano_censo') @@ -811,7 +822,10 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); } next(); -}, rqf.build(), query, id2str.transform(false), (req, res, next) => { +}, rqf.build(), (req, res, next) => { + console.log('sql:' + req.sql.toString()); + next(); +}, query, id2str.transform(false), (req, res, next) => { if(req.pee_por_categoria === true){ let result = req.result; let result_total = []; -- GitLab From 33fe13d05a3206647a6607b13bb73c742eebebdf Mon Sep 17 00:00:00 2001 From: Pietro Cavassin <ppc19@inf.ufpr.br> Date: Tue, 30 Aug 2022 14:50:02 +0000 Subject: [PATCH 263/305] Remove console.log from enrollment.js --- src/libs/routes/enrollment.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index ac85866f..87259385 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -822,10 +822,7 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); } next(); -}, rqf.build(), (req, res, next) => { - console.log('sql:' + req.sql.toString()); - next(); -}, query, id2str.transform(false), (req, res, next) => { +}, rqf.build(), query, id2str.transform(false), (req, res, next) => { if(req.pee_por_categoria === true){ let result = req.result; let result_total = []; -- GitLab From 6a654073b067fd1113520e3208e9ca491425178a Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 23 Sep 2022 11:17:35 -0300 Subject: [PATCH 264/305] Add studentsAee rout --- src/libs/routes/studentsAee.js | 212 +++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 src/libs/routes/studentsAee.js diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js new file mode 100644 index 00000000..987e25ff --- /dev/null +++ b/src/libs/routes/studentsAee.js @@ -0,0 +1,212 @@ +const express = require('express'); + +const studentsAeeApp = express.Router(); + +const libs = `${process.cwd()}/libs`; + +const log = require(`${libs}/log`)(module); + +const squel = require('squel'); + +const query = require(`${libs}/middlewares/query`).query; + +const response = require(`${libs}/middlewares/response`); + +const id2str = require(`${libs}/middlewares/id2str`); + +const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); + +const request = require(`request`); + +const config = require(`${libs}/config`); + +const passport = require('passport'); + +const download = require(`${libs}/middlewares/downloadDatabase`); + +const addMissing = require(`${libs}/middlewares/addMissing`); + +const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware; + +let rqf = new ReqQueryFields(); +let rqfCount = new ReqQueryFields(); +// cubApp.get('/year_range', (req, res, next) => { + +// req.sql.from('cub') +// .field('MIN(cub.ano_censo)', 'start_year') +// .field('MAX(cub.ano_censo)', 'end_year'); +// next(); +// }, query, response('range')); + +// cubApp.get('/years', (req, res, next) => { +// req.sql.from('cub') +// .field('DISTINCT cub.ano_censo', 'year'); +// next(); +// }, query, response('years')); + +// cubApp.get('/months', (req, res, next) => { +// req.sql.from('cub') +// .field('DISTINCT cub.mes_censo', 'month'); +// next(); +// }, query, response('months')); + +// cubApp.get('/years_months', (req, res, next) => { +// req.sql.from('cub') +// .field('DISTINCT cub.ano_censo AS "year", cub.mes_censo AS "month"'); +// next(); +// }, query, response('years_months')); + +// cubApp.get('/price_type', (req, res, next) => { +// req.sql.from('cub') +// .field('DISTINCT cub.tipo_preco', 'price_type'); +// next(); +// }, query, response('price_type')); + +rqf.addField({ + name: 'filter', + field: false, + where: true +}).addField({ + name: 'dims', + field: true, + where: false +}).addValue({ + name: 'state', + table: 'estado', + tableField: ['sigla', 'id'], + resultField: ['sigla_uf', 'cod_uf'], + where: { + relation: '=', + type: 'integer', + field: 'estado_id', + table: 'numero_estudantes_aee' + }, + join: { + primary: 'id', + foreign: 'estado_id', + foreignTable: 'numero_estudantes_aee' + } +}).addValueToField({ + name: 'city', + table: 'municipio', + tableField: 'nome', + resultField: 'city_name', + where: { + relation: '=', + type: 'integer', + field: 'id', + table: 'numero_estudantes_aee' + }, + join: { + primary: 'id', + foreign: 'municipio_id', + foreignTable: 'numero_estudantes_aee' + } +}).addValue({ + name: 'region', + table: 'regiao', + tableField: ['nome', 'id'], + resultField: ['region_name', 'regiao_id'], + where: { + relation: '=', + type: 'integer', + field: 'id', + table: 'numero_estudantes_aee' + }, + join: { + primary: 'id', + foreign: 'regiao_id', + foreignTable: 'numero_estudantes_aee' + } +}).addValueToField({ + name: 'school', + table: 'numero_estudantes_aee', + tableField: 'escola_id', + resultField: 'school_id', + where: { + relation: '=', + type: 'integer', + field: 'id' + }, +}).addValueToField({ + name: 'locale_id', + table: 'numero_estudantes_aee', + tableField: 'localizacao_id', + resultField: 'locale_id', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_id' + } +}).addValue({ + name: 'ethnic_group', + table: 'numero_estudantes_aee', + tableField: 'cor_raca_id', + resultField: 'ethnic_group_id', + where: { + relation: '=', + type: 'integer', + field: 'cor_raca_id' + } +}).addValue({ + name: 'adm_dependency', + table: 'numero_estudantes_aee', + tableField: 'dependencia_adm_id', + resultField: 'adm_dependency_id', + where: { + relation: '=', + type: 'integer', + field: 'dependencia_adm_id' + } +}).addValue({ + name:'age_range_all', + table: 'numero_estudantes_aee', + tableField: 'faixa_etaria_31_03', + resultField: 'age_range_all_id', + where: { + relation: '=', + type: 'integer', + field: 'faixa_etaria_31_03' + } + }).addValue({ + name: 'gender', + table: 'numero_estudantes_aee', + tableField: 'sexo', + resultField: 'gender_id', + where: { + relation: '=', + type: 'integer', + field: 'sexo' + } +}).addValue({ + name: 'activity_days', + table: 'numero_estudantes_aee', + tableField: 'dias_atividade', + resultField: 'activity_days_id', + where: { + relation: '=', + type: 'integer', + field: 'dias_atividade' + } +}).addField({ + name: 'special_service', + table: 'numero_estudantes_aee', + tableField: 'disc_atendimento_especiais', + resultField: 'special_service_id', + where: { + relation: '=', + type: 'integer', + field: 'disc_atendimento_especiais' + } +}); + +studentsAeeApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { + req.sql.from('numero_estudantes_aee') + .field('ano_censo') + .field('COUNT(distinct id_aluno)') + .group('ano_censo') + .order('ano_censo') + next(); +}, query, id2str.transform(), response('studentsAee')); + +module.exports = studentsAeeApp; -- GitLab From 9346bffa3e6d0fc69ce3aff2c5f3a2a6a1ddd669 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Fri, 16 Sep 2022 10:54:32 -0300 Subject: [PATCH 265/305] Add region and state not filter --- src/libs/routes/city.js | 34 +++++++++++++++++++++++++++++++++- src/libs/routes/region.js | 10 ++++++++++ src/libs/routes/state.js | 9 +++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/city.js b/src/libs/routes/city.js index 1686c850..fc697a9f 100644 --- a/src/libs/routes/city.js +++ b/src/libs/routes/city.js @@ -69,6 +69,22 @@ rqf.addField({ foreign: 'estado_id', foreignTable: 'municipio' } +}).addValue({ + name: 'state_not', + table: 'estado', + tableField: ['nome', 'id'], + resultField: ['state_name', 'state_id'], + where: { + relation: '<>', + type: 'integer', + field: 'estado_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'estado_id', + foreignTable: 'municipio' + } }).addField({ name: 'search', field: false, @@ -100,7 +116,23 @@ rqf.addField({ type: 'integer', field: 'microrregiao_id' } -}); +}).addValueToField({ + name: 'region', + table: 'estado', + tableField: 'regiao_id', + resultField: 'region_id', + where: { + relation: '=', + type: 'integer', + field: 'regiao_id', + table: 'estado' + }, + join: { + primary: 'id', + foreign: 'estado_id', + foreignTable: 'municipio' + } +}, 'filter'); // Return all cities cityApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { diff --git a/src/libs/routes/region.js b/src/libs/routes/region.js index b1076e64..5df65e72 100644 --- a/src/libs/routes/region.js +++ b/src/libs/routes/region.js @@ -36,6 +36,16 @@ rqf.addField({ field: 'id', table: '@' } +}).addValue({ + name: 'id_not', + table: '@', + tableField: 'id', + where: { + relation: '<>', + type: 'integer', + field: 'id', + table: '@' + } }).addField({ name: 'search', field: false, diff --git a/src/libs/routes/state.js b/src/libs/routes/state.js index 453ca6eb..c9830b20 100644 --- a/src/libs/routes/state.js +++ b/src/libs/routes/state.js @@ -53,6 +53,15 @@ rqf.addField({ type: 'integer', field: 'id' } +}).addValue({ + name: 'id_not', + table: 'estado', + tableField: 'id', + where: { + relation: '<>', + type: 'integer', + field: 'id' + } }).addValue({ name: 'region', table: 'regiao', -- GitLab From 22d8137bca5515c256b7f586fbef8be9a0738934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Mon, 26 Sep 2022 09:49:10 -0300 Subject: [PATCH 266/305] Add new rout - studentsAee --- src/libs/routes/api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 7fa6818b..92d7d6bd 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -118,6 +118,8 @@ const educationalBudget = require(`${libs}/routes/educationalBudget`); const schoolLocation = require(`${libs}/routes/schoolLocation`); +const studentsAee = require(`${libs}/routes/studentsAee`); + const mesoregion = require(`${libs}/routes/mesoregion`); const microregion = require(`${libs}/routes/microregion`); @@ -182,6 +184,7 @@ api.use('/university', university); api.use('/university_teacher', universityTeacher); api.use('/course_count', courseCount); api.use('/school_location', schoolLocation); +api.use('/studentsAee', studentsAee); api.use('/mesoregion', mesoregion); api.use('/microregion', microregion); api.use('/location', location); -- GitLab From 967aa3d199206c6011e63d4325866fe447cb41d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Mon, 26 Sep 2022 10:59:56 -0300 Subject: [PATCH 267/305] Add value to field - filter --- src/libs/routes/studentsAee.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 987e25ff..8471dca4 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -30,6 +30,7 @@ const cache = require('apicache').options({ debug: config.debug, statusCodes: {i let rqf = new ReqQueryFields(); let rqfCount = new ReqQueryFields(); + // cubApp.get('/year_range', (req, res, next) => { // req.sql.from('cub') @@ -70,7 +71,7 @@ rqf.addField({ name: 'dims', field: true, where: false -}).addValue({ +}).addValueToField({ name: 'state', table: 'estado', tableField: ['sigla', 'id'], @@ -86,7 +87,7 @@ rqf.addField({ foreign: 'estado_id', foreignTable: 'numero_estudantes_aee' } -}).addValueToField({ +}, 'filter').addValueToField({ name: 'city', table: 'municipio', tableField: 'nome', @@ -102,7 +103,7 @@ rqf.addField({ foreign: 'municipio_id', foreignTable: 'numero_estudantes_aee' } -}).addValue({ +}, 'filter').addValue({ name: 'region', table: 'regiao', tableField: ['nome', 'id'], @@ -128,7 +129,7 @@ rqf.addField({ type: 'integer', field: 'id' }, -}).addValueToField({ +}, 'filter').addValueToField({ name: 'locale_id', table: 'numero_estudantes_aee', tableField: 'localizacao_id', @@ -200,13 +201,13 @@ rqf.addField({ } }); -studentsAeeApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { +studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('numero_estudantes_aee') .field('ano_censo') .field('COUNT(distinct id_aluno)') .group('ano_censo') .order('ano_censo') next(); -}, query, id2str.transform(), response('studentsAee')); +}, rqf.build(), query, id2str.transform(), response('studentsAee')); module.exports = studentsAeeApp; -- GitLab From 0ad0423edb53c35a3487a06e95b7f125d8de9218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Mon, 26 Sep 2022 11:21:43 -0300 Subject: [PATCH 268/305] Add value to field - filter(2) --- src/libs/routes/studentsAee.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 8471dca4..5f15aab8 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -139,7 +139,7 @@ rqf.addField({ type: 'integer', field: 'localizacao_id' } -}).addValue({ +}, 'filter').addValue({ name: 'ethnic_group', table: 'numero_estudantes_aee', tableField: 'cor_raca_id', -- GitLab From 54f1b08cb53b29ab51c410d3e5eca0fead04d76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Mon, 26 Sep 2022 11:40:16 -0300 Subject: [PATCH 269/305] Update rout name studentsAee -> students_aee --- src/libs/routes/api.js | 2 +- src/libs/routes/studentsAee.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 92d7d6bd..f6715eaa 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -184,7 +184,7 @@ api.use('/university', university); api.use('/university_teacher', universityTeacher); api.use('/course_count', courseCount); api.use('/school_location', schoolLocation); -api.use('/studentsAee', studentsAee); +api.use('/students_aee', studentsAee); api.use('/mesoregion', mesoregion); api.use('/microregion', microregion); api.use('/location', location); diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 5f15aab8..6b2d3f84 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -204,7 +204,7 @@ rqf.addField({ studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('numero_estudantes_aee') .field('ano_censo') - .field('COUNT(distinct id_aluno)') + .field('COUNT(distinct id_aluno)', 'total') .group('ano_censo') .order('ano_censo') next(); -- GitLab From a454dfaa9c2ad80dd75a7721fb9f6bd8f7352d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Tue, 27 Sep 2022 10:05:28 -0300 Subject: [PATCH 270/305] Update filter city (test) --- src/libs/routes/studentsAee.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 6b2d3f84..31db6ff5 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -71,7 +71,7 @@ rqf.addField({ name: 'dims', field: true, where: false -}).addValueToField({ +}).addValueToField({ // working name: 'state', table: 'estado', tableField: ['sigla', 'id'], @@ -90,13 +90,12 @@ rqf.addField({ }, 'filter').addValueToField({ name: 'city', table: 'municipio', - tableField: 'nome', - resultField: 'city_name', + tableField: ['nome', 'id'], + resultField: ['city_name', 'city_id'], where: { relation: '=', type: 'integer', - field: 'id', - table: 'numero_estudantes_aee' + field: 'id' }, join: { primary: 'id', @@ -130,7 +129,7 @@ rqf.addField({ field: 'id' }, }, 'filter').addValueToField({ - name: 'locale_id', + name: 'locale_id', // working table: 'numero_estudantes_aee', tableField: 'localizacao_id', resultField: 'locale_id', @@ -140,7 +139,7 @@ rqf.addField({ field: 'localizacao_id' } }, 'filter').addValue({ - name: 'ethnic_group', + name: 'ethnic_group', // working table: 'numero_estudantes_aee', tableField: 'cor_raca_id', resultField: 'ethnic_group_id', @@ -150,7 +149,7 @@ rqf.addField({ field: 'cor_raca_id' } }).addValue({ - name: 'adm_dependency', + name: 'adm_dependency', // working table: 'numero_estudantes_aee', tableField: 'dependencia_adm_id', resultField: 'adm_dependency_id', @@ -160,7 +159,7 @@ rqf.addField({ field: 'dependencia_adm_id' } }).addValue({ - name:'age_range_all', + name:'age_range_all', // working table: 'numero_estudantes_aee', tableField: 'faixa_etaria_31_03', resultField: 'age_range_all_id', @@ -170,7 +169,7 @@ rqf.addField({ field: 'faixa_etaria_31_03' } }).addValue({ - name: 'gender', + name: 'gender', // working table: 'numero_estudantes_aee', tableField: 'sexo', resultField: 'gender_id', @@ -180,7 +179,7 @@ rqf.addField({ field: 'sexo' } }).addValue({ - name: 'activity_days', + name: 'activity_days', // working table: 'numero_estudantes_aee', tableField: 'dias_atividade', resultField: 'activity_days_id', @@ -190,7 +189,7 @@ rqf.addField({ field: 'dias_atividade' } }).addField({ - name: 'special_service', + name: 'special_service', // working table: 'numero_estudantes_aee', tableField: 'disc_atendimento_especiais', resultField: 'special_service_id', -- GitLab From e728b216d7c9ba831f9e860f9933af1e92fd08a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Tue, 27 Sep 2022 10:13:15 -0300 Subject: [PATCH 271/305] Update filter region (test) --- src/libs/routes/studentsAee.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 31db6ff5..929af12b 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -71,8 +71,8 @@ rqf.addField({ name: 'dims', field: true, where: false -}).addValueToField({ // working - name: 'state', +}).addValueToField({ + name: 'state', // working table: 'estado', tableField: ['sigla', 'id'], resultField: ['sigla_uf', 'cod_uf'], @@ -88,7 +88,7 @@ rqf.addField({ foreignTable: 'numero_estudantes_aee' } }, 'filter').addValueToField({ - name: 'city', + name: 'city', // working table: 'municipio', tableField: ['nome', 'id'], resultField: ['city_name', 'city_id'], @@ -106,12 +106,11 @@ rqf.addField({ name: 'region', table: 'regiao', tableField: ['nome', 'id'], - resultField: ['region_name', 'regiao_id'], + resultField: ['region_name', 'region_id'], where: { relation: '=', type: 'integer', - field: 'id', - table: 'numero_estudantes_aee' + field: 'id' }, join: { primary: 'id', -- GitLab From 5ea29c53749b53f18ae7bb2b0a3c3cef4af3a93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Tue, 27 Sep 2022 10:18:40 -0300 Subject: [PATCH 272/305] Update filter school (test) --- src/libs/routes/studentsAee.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 929af12b..fcc0572f 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -103,7 +103,7 @@ rqf.addField({ foreignTable: 'numero_estudantes_aee' } }, 'filter').addValue({ - name: 'region', + name: 'region', // working table: 'regiao', tableField: ['nome', 'id'], resultField: ['region_name', 'region_id'], @@ -119,14 +119,19 @@ rqf.addField({ } }).addValueToField({ name: 'school', - table: 'numero_estudantes_aee', - tableField: 'escola_id', - resultField: 'school_id', + table: 'escola', + tableField: ['nome_escola', 'id'], + resultField: ['school_name', 'school_id'], where: { relation: '=', type: 'integer', field: 'id' }, + join: { + primary: ['id', 'ano_censo'], + foreign: ['escola_id', 'ano_censo'], + foreignTable: 'numero_estudantes_aee' + } }, 'filter').addValueToField({ name: 'locale_id', // working table: 'numero_estudantes_aee', -- GitLab From 8094cff11f796976bc01b478664d3ccc1e20f8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Tue, 27 Sep 2022 10:23:11 -0300 Subject: [PATCH 273/305] Update filter school (test 2) --- src/libs/routes/studentsAee.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index fcc0572f..617cceb5 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -128,8 +128,8 @@ rqf.addField({ field: 'id' }, join: { - primary: ['id', 'ano_censo'], - foreign: ['escola_id', 'ano_censo'], + primary: 'id', + foreign: 'escola_id', foreignTable: 'numero_estudantes_aee' } }, 'filter').addValueToField({ -- GitLab From fccfee524cec78edca217cbfdceb74080ecf25cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Tue, 27 Sep 2022 11:10:19 -0300 Subject: [PATCH 274/305] Update filter school (test 3) --- src/libs/routes/studentsAee.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 617cceb5..f2906170 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -129,7 +129,7 @@ rqf.addField({ }, join: { primary: 'id', - foreign: 'escola_id', + foreign: ['escola_id', 'ano_censo'], foreignTable: 'numero_estudantes_aee' } }, 'filter').addValueToField({ -- GitLab From 13500d94ca0e1c47240c59ab03571fc21a85fb27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Wed, 28 Sep 2022 09:34:44 -0300 Subject: [PATCH 275/305] Add console log --- src/libs/routes/studentsAee.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index f2906170..fe4d985c 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -211,6 +211,9 @@ studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { .group('ano_censo') .order('ano_censo') next(); -}, rqf.build(), query, id2str.transform(), response('studentsAee')); +}, rqf.build(), (req, res, next) => { + console.log(req.sql.toString()); + next(); +}, query, id2str.transform(), response('studentsAee')); module.exports = studentsAeeApp; -- GitLab From f57e6833ab0429938274b0909304d3fdd02b8247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Wed, 28 Sep 2022 09:41:57 -0300 Subject: [PATCH 276/305] Update school filter --- src/libs/routes/studentsAee.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index fe4d985c..6664294e 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -128,7 +128,7 @@ rqf.addField({ field: 'id' }, join: { - primary: 'id', + primary: ['id', 'ano_censo'], foreign: ['escola_id', 'ano_censo'], foreignTable: 'numero_estudantes_aee' } -- GitLab From 7e1a86f35ff63212b8e1169342de68bf7f377d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Wed, 28 Sep 2022 09:51:36 -0300 Subject: [PATCH 277/305] Update school filter(2) --- src/libs/routes/studentsAee.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 6664294e..6e58c188 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -206,10 +206,10 @@ rqf.addField({ studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('numero_estudantes_aee') - .field('ano_censo') - .field('COUNT(distinct id_aluno)', 'total') - .group('ano_censo') - .order('ano_censo') + .field('numero_estudantes_aee.ano_censo') + .field('COUNT(distinct numero_estudantes_aee.id_aluno)', 'total') + .group('numero_estudantes_aee.ano_censo') + .order('numero_estudantes_aee.ano_censo') next(); }, rqf.build(), (req, res, next) => { console.log(req.sql.toString()); -- GitLab From 49d521ab082a413370115084a9677e59ea6ead24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Wed, 28 Sep 2022 10:00:19 -0300 Subject: [PATCH 278/305] Update school filter(3) --- src/libs/routes/studentsAee.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 6e58c188..6664294e 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -206,10 +206,10 @@ rqf.addField({ studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('numero_estudantes_aee') - .field('numero_estudantes_aee.ano_censo') - .field('COUNT(distinct numero_estudantes_aee.id_aluno)', 'total') - .group('numero_estudantes_aee.ano_censo') - .order('numero_estudantes_aee.ano_censo') + .field('ano_censo') + .field('COUNT(distinct id_aluno)', 'total') + .group('ano_censo') + .order('ano_censo') next(); }, rqf.build(), (req, res, next) => { console.log(req.sql.toString()); -- GitLab From 82a9fe969476d1db5e227849fd9298c4370c6a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Wed, 28 Sep 2022 10:04:45 -0300 Subject: [PATCH 279/305] Update school filter(2) --- src/libs/routes/studentsAee.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 6664294e..44752281 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -118,7 +118,7 @@ rqf.addField({ foreignTable: 'numero_estudantes_aee' } }).addValueToField({ - name: 'school', + name: 'school', // working table: 'escola', tableField: ['nome_escola', 'id'], resultField: ['school_name', 'school_id'], @@ -206,10 +206,10 @@ rqf.addField({ studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('numero_estudantes_aee') - .field('ano_censo') - .field('COUNT(distinct id_aluno)', 'total') - .group('ano_censo') - .order('ano_censo') + .field('numero_estudantes_aee.ano_censo') + .field('COUNT(distinct numero_estudantes_aee.id_aluno)', 'total') + .group('numero_estudantes_aee.ano_censo') + .order('numero_estudantes_aee.ano_censo') next(); }, rqf.build(), (req, res, next) => { console.log(req.sql.toString()); -- GitLab From ef472e3f2f27a6b7e6b1526761e8c396c5031e0b Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 29 Sep 2022 09:08:19 -0300 Subject: [PATCH 280/305] removing some forbidden filters on universityEnrollment default route --- src/libs/routes/universityEnrollment.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 619bcf8f..88186651 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -776,8 +776,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('COUNT(*)', 'total') .field("'Brasil'", 'name') .field('localoferta_ens_superior_matricula.ano_censo', 'year') - .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') - .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') } -- GitLab From cd83b890d47297868f9a4091f73e4df398382606 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 29 Sep 2022 11:04:38 -0300 Subject: [PATCH 281/305] removing forbidden filters from all universityEnrollment subRoutes --- src/libs/routes/universityEnrollment.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 88186651..b1d0355c 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -732,8 +732,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('curso_ens_superior.ano_censo', 'year') .field('COUNT(localoferta_ens_superior.cod_local_oferta)', 'total') .group('localoferta_ens_superior_matricula.ano_censo') - .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') - .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .order('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior.cod_local_oferta'); } else { @@ -745,8 +743,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .group('localoferta_ens_superior_matricula.ano_censo') .group('localoferta_ens_superior_matricula.cod_ies') .group('localoferta_ens_superior_matricula.nome_ies') - .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') - .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .order('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.cod_local_oferta'); } @@ -756,8 +752,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('DISTINCT COUNT(*)', 'total') .field("'Brasil'", 'name') .field('localoferta_ens_superior_matricula.ano_censo', 'year') - .where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1') - .where('localoferta_ens_superior_matricula.cod_nivel_academico = 1') .group('localoferta_ens_superior_matricula.ano_censo') .order('localoferta_ens_superior_matricula.ano_censo') } else if ("university" in req.dims || "universityLocalOffer" in req.dims) { @@ -765,8 +759,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .field('COUNT(*)', 'total') .field("'Brasil'", 'name') .field('aluno_ens_superior.ano_censo', 'year') - .where('aluno_ens_superior.cod_aluno_situacao = 2 OR aluno_ens_superior.cod_aluno_situacao = 6 OR aluno_ens_superior.matriculado = 1') - .where('aluno_ens_superior.cod_nivel_academico = 1') .group('aluno_ens_superior.cod_ies') .group('aluno_ens_superior.ano_censo') .order('aluno_ens_superior.cod_ies') @@ -799,7 +791,6 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) => .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') @@ -824,7 +815,6 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex .field('SUM(CASE WHEN localoferta_ens_superior_matricula.cod_aluno_situacao=3 THEN 1 ELSE 0 END)', 'trancado') .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') -- GitLab From ef675009d475dbb9bd9ed88365337afa1f19d5da Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Thu, 29 Sep 2022 11:06:09 -0300 Subject: [PATCH 282/305] adding a console log for debbuging purposes --- src/libs/routes/universityEnrollment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index b1d0355c..7b40635c 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -772,7 +772,7 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => { .order('localoferta_ens_superior_matricula.ano_censo') } next(); -}, rqf.build(), query, id2str.transform(), addMissing(rqf), (req, res, next) => { +}, rqf.build(), query, (req, res, next) =>{ console.log(req.sql.toString()); next()}, id2str.transform(), addMissing(rqf), (req, res, next) => { if ('course' in req.dims){ var total_course = req.result.reduce((total, cur) => {return total += cur.total}, 0) for (var course of req.result){ -- GitLab From 7a4fd1c01236a23ba3af7657eaaaefc2f1bd60bd Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Fri, 16 Sep 2022 10:54:32 -0300 Subject: [PATCH 283/305] Add region and state not filter --- src/libs/routes/city.js | 34 +++++++++++++++++++++++++++++++++- src/libs/routes/region.js | 10 ++++++++++ src/libs/routes/state.js | 9 +++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/city.js b/src/libs/routes/city.js index 1686c850..fc697a9f 100644 --- a/src/libs/routes/city.js +++ b/src/libs/routes/city.js @@ -69,6 +69,22 @@ rqf.addField({ foreign: 'estado_id', foreignTable: 'municipio' } +}).addValue({ + name: 'state_not', + table: 'estado', + tableField: ['nome', 'id'], + resultField: ['state_name', 'state_id'], + where: { + relation: '<>', + type: 'integer', + field: 'estado_id', + table: 'municipio' + }, + join: { + primary: 'id', + foreign: 'estado_id', + foreignTable: 'municipio' + } }).addField({ name: 'search', field: false, @@ -100,7 +116,23 @@ rqf.addField({ type: 'integer', field: 'microrregiao_id' } -}); +}).addValueToField({ + name: 'region', + table: 'estado', + tableField: 'regiao_id', + resultField: 'region_id', + where: { + relation: '=', + type: 'integer', + field: 'regiao_id', + table: 'estado' + }, + join: { + primary: 'id', + foreign: 'estado_id', + foreignTable: 'municipio' + } +}, 'filter'); // Return all cities cityApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { diff --git a/src/libs/routes/region.js b/src/libs/routes/region.js index b1076e64..5df65e72 100644 --- a/src/libs/routes/region.js +++ b/src/libs/routes/region.js @@ -36,6 +36,16 @@ rqf.addField({ field: 'id', table: '@' } +}).addValue({ + name: 'id_not', + table: '@', + tableField: 'id', + where: { + relation: '<>', + type: 'integer', + field: 'id', + table: '@' + } }).addField({ name: 'search', field: false, diff --git a/src/libs/routes/state.js b/src/libs/routes/state.js index 453ca6eb..c9830b20 100644 --- a/src/libs/routes/state.js +++ b/src/libs/routes/state.js @@ -53,6 +53,15 @@ rqf.addField({ type: 'integer', field: 'id' } +}).addValue({ + name: 'id_not', + table: 'estado', + tableField: 'id', + where: { + relation: '<>', + type: 'integer', + field: 'id' + } }).addValue({ name: 'region', table: 'regiao', -- GitLab From 3b4eb9fc476c9c28b985464dce995365a9bb1bc4 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Thu, 29 Sep 2022 10:41:01 -0300 Subject: [PATCH 284/305] add university filter --- src/libs/routes/universityLocalOffer.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/universityLocalOffer.js b/src/libs/routes/universityLocalOffer.js index 4a594f62..05425df7 100644 --- a/src/libs/routes/universityLocalOffer.js +++ b/src/libs/routes/universityLocalOffer.js @@ -126,7 +126,19 @@ rqf.addField({ foreign: 'cod_uf', foreignTable: 'localoferta_ens_superior' } -}); +}).addValueToField({ + name: 'university', + table: 'localoferta_ens_superior', + tableField: 'cod_ies', + resultField: 'university_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_ies', + table: 'localoferta_ens_superior' + } +}, filter); + universityLocalOfferApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { req.sql.from('localoferta_ens_superior') -- GitLab From 0ca0bbabd4e487edfaab3ab2b8b87e8ef81aa742 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Thu, 29 Sep 2022 11:50:03 -0300 Subject: [PATCH 285/305] fix filter --- src/libs/routes/universityLocalOffer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/universityLocalOffer.js b/src/libs/routes/universityLocalOffer.js index 05425df7..452c0648 100644 --- a/src/libs/routes/universityLocalOffer.js +++ b/src/libs/routes/universityLocalOffer.js @@ -137,7 +137,7 @@ rqf.addField({ field: 'cod_ies', table: 'localoferta_ens_superior' } -}, filter); +}, 'filter'); universityLocalOfferApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { -- GitLab From 9b1c4b02ab7c2b199332905be0c0eb6c20519518 Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Fri, 23 Sep 2022 11:17:35 -0300 Subject: [PATCH 286/305] Add studentsAee rout --- src/libs/routes/studentsAee.js | 212 +++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 src/libs/routes/studentsAee.js diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js new file mode 100644 index 00000000..987e25ff --- /dev/null +++ b/src/libs/routes/studentsAee.js @@ -0,0 +1,212 @@ +const express = require('express'); + +const studentsAeeApp = express.Router(); + +const libs = `${process.cwd()}/libs`; + +const log = require(`${libs}/log`)(module); + +const squel = require('squel'); + +const query = require(`${libs}/middlewares/query`).query; + +const response = require(`${libs}/middlewares/response`); + +const id2str = require(`${libs}/middlewares/id2str`); + +const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); + +const request = require(`request`); + +const config = require(`${libs}/config`); + +const passport = require('passport'); + +const download = require(`${libs}/middlewares/downloadDatabase`); + +const addMissing = require(`${libs}/middlewares/addMissing`); + +const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware; + +let rqf = new ReqQueryFields(); +let rqfCount = new ReqQueryFields(); +// cubApp.get('/year_range', (req, res, next) => { + +// req.sql.from('cub') +// .field('MIN(cub.ano_censo)', 'start_year') +// .field('MAX(cub.ano_censo)', 'end_year'); +// next(); +// }, query, response('range')); + +// cubApp.get('/years', (req, res, next) => { +// req.sql.from('cub') +// .field('DISTINCT cub.ano_censo', 'year'); +// next(); +// }, query, response('years')); + +// cubApp.get('/months', (req, res, next) => { +// req.sql.from('cub') +// .field('DISTINCT cub.mes_censo', 'month'); +// next(); +// }, query, response('months')); + +// cubApp.get('/years_months', (req, res, next) => { +// req.sql.from('cub') +// .field('DISTINCT cub.ano_censo AS "year", cub.mes_censo AS "month"'); +// next(); +// }, query, response('years_months')); + +// cubApp.get('/price_type', (req, res, next) => { +// req.sql.from('cub') +// .field('DISTINCT cub.tipo_preco', 'price_type'); +// next(); +// }, query, response('price_type')); + +rqf.addField({ + name: 'filter', + field: false, + where: true +}).addField({ + name: 'dims', + field: true, + where: false +}).addValue({ + name: 'state', + table: 'estado', + tableField: ['sigla', 'id'], + resultField: ['sigla_uf', 'cod_uf'], + where: { + relation: '=', + type: 'integer', + field: 'estado_id', + table: 'numero_estudantes_aee' + }, + join: { + primary: 'id', + foreign: 'estado_id', + foreignTable: 'numero_estudantes_aee' + } +}).addValueToField({ + name: 'city', + table: 'municipio', + tableField: 'nome', + resultField: 'city_name', + where: { + relation: '=', + type: 'integer', + field: 'id', + table: 'numero_estudantes_aee' + }, + join: { + primary: 'id', + foreign: 'municipio_id', + foreignTable: 'numero_estudantes_aee' + } +}).addValue({ + name: 'region', + table: 'regiao', + tableField: ['nome', 'id'], + resultField: ['region_name', 'regiao_id'], + where: { + relation: '=', + type: 'integer', + field: 'id', + table: 'numero_estudantes_aee' + }, + join: { + primary: 'id', + foreign: 'regiao_id', + foreignTable: 'numero_estudantes_aee' + } +}).addValueToField({ + name: 'school', + table: 'numero_estudantes_aee', + tableField: 'escola_id', + resultField: 'school_id', + where: { + relation: '=', + type: 'integer', + field: 'id' + }, +}).addValueToField({ + name: 'locale_id', + table: 'numero_estudantes_aee', + tableField: 'localizacao_id', + resultField: 'locale_id', + where: { + relation: '=', + type: 'integer', + field: 'localizacao_id' + } +}).addValue({ + name: 'ethnic_group', + table: 'numero_estudantes_aee', + tableField: 'cor_raca_id', + resultField: 'ethnic_group_id', + where: { + relation: '=', + type: 'integer', + field: 'cor_raca_id' + } +}).addValue({ + name: 'adm_dependency', + table: 'numero_estudantes_aee', + tableField: 'dependencia_adm_id', + resultField: 'adm_dependency_id', + where: { + relation: '=', + type: 'integer', + field: 'dependencia_adm_id' + } +}).addValue({ + name:'age_range_all', + table: 'numero_estudantes_aee', + tableField: 'faixa_etaria_31_03', + resultField: 'age_range_all_id', + where: { + relation: '=', + type: 'integer', + field: 'faixa_etaria_31_03' + } + }).addValue({ + name: 'gender', + table: 'numero_estudantes_aee', + tableField: 'sexo', + resultField: 'gender_id', + where: { + relation: '=', + type: 'integer', + field: 'sexo' + } +}).addValue({ + name: 'activity_days', + table: 'numero_estudantes_aee', + tableField: 'dias_atividade', + resultField: 'activity_days_id', + where: { + relation: '=', + type: 'integer', + field: 'dias_atividade' + } +}).addField({ + name: 'special_service', + table: 'numero_estudantes_aee', + tableField: 'disc_atendimento_especiais', + resultField: 'special_service_id', + where: { + relation: '=', + type: 'integer', + field: 'disc_atendimento_especiais' + } +}); + +studentsAeeApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { + req.sql.from('numero_estudantes_aee') + .field('ano_censo') + .field('COUNT(distinct id_aluno)') + .group('ano_censo') + .order('ano_censo') + next(); +}, query, id2str.transform(), response('studentsAee')); + +module.exports = studentsAeeApp; -- GitLab From 31cd11c659f7cbad0adf9242e054aa8ea92649fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Mon, 26 Sep 2022 09:49:10 -0300 Subject: [PATCH 287/305] Add new rout - studentsAee --- src/libs/routes/api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 7fa6818b..92d7d6bd 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -118,6 +118,8 @@ const educationalBudget = require(`${libs}/routes/educationalBudget`); const schoolLocation = require(`${libs}/routes/schoolLocation`); +const studentsAee = require(`${libs}/routes/studentsAee`); + const mesoregion = require(`${libs}/routes/mesoregion`); const microregion = require(`${libs}/routes/microregion`); @@ -182,6 +184,7 @@ api.use('/university', university); api.use('/university_teacher', universityTeacher); api.use('/course_count', courseCount); api.use('/school_location', schoolLocation); +api.use('/studentsAee', studentsAee); api.use('/mesoregion', mesoregion); api.use('/microregion', microregion); api.use('/location', location); -- GitLab From ecccada6d55fae6627d2e46aeb67b4540a496dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Mon, 26 Sep 2022 10:59:56 -0300 Subject: [PATCH 288/305] Add value to field - filter --- src/libs/routes/studentsAee.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 987e25ff..8471dca4 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -30,6 +30,7 @@ const cache = require('apicache').options({ debug: config.debug, statusCodes: {i let rqf = new ReqQueryFields(); let rqfCount = new ReqQueryFields(); + // cubApp.get('/year_range', (req, res, next) => { // req.sql.from('cub') @@ -70,7 +71,7 @@ rqf.addField({ name: 'dims', field: true, where: false -}).addValue({ +}).addValueToField({ name: 'state', table: 'estado', tableField: ['sigla', 'id'], @@ -86,7 +87,7 @@ rqf.addField({ foreign: 'estado_id', foreignTable: 'numero_estudantes_aee' } -}).addValueToField({ +}, 'filter').addValueToField({ name: 'city', table: 'municipio', tableField: 'nome', @@ -102,7 +103,7 @@ rqf.addField({ foreign: 'municipio_id', foreignTable: 'numero_estudantes_aee' } -}).addValue({ +}, 'filter').addValue({ name: 'region', table: 'regiao', tableField: ['nome', 'id'], @@ -128,7 +129,7 @@ rqf.addField({ type: 'integer', field: 'id' }, -}).addValueToField({ +}, 'filter').addValueToField({ name: 'locale_id', table: 'numero_estudantes_aee', tableField: 'localizacao_id', @@ -200,13 +201,13 @@ rqf.addField({ } }); -studentsAeeApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { +studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('numero_estudantes_aee') .field('ano_censo') .field('COUNT(distinct id_aluno)') .group('ano_censo') .order('ano_censo') next(); -}, query, id2str.transform(), response('studentsAee')); +}, rqf.build(), query, id2str.transform(), response('studentsAee')); module.exports = studentsAeeApp; -- GitLab From 9ccc0857322273eebd00dbded6f865a44d1b961b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Mon, 26 Sep 2022 11:21:43 -0300 Subject: [PATCH 289/305] Add value to field - filter(2) --- src/libs/routes/studentsAee.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 8471dca4..5f15aab8 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -139,7 +139,7 @@ rqf.addField({ type: 'integer', field: 'localizacao_id' } -}).addValue({ +}, 'filter').addValue({ name: 'ethnic_group', table: 'numero_estudantes_aee', tableField: 'cor_raca_id', -- GitLab From 8f29b0179abdea1ef7eab81dd7918e9517a332fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Mon, 26 Sep 2022 11:40:16 -0300 Subject: [PATCH 290/305] Update rout name studentsAee -> students_aee --- src/libs/routes/api.js | 2 +- src/libs/routes/studentsAee.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 92d7d6bd..f6715eaa 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -184,7 +184,7 @@ api.use('/university', university); api.use('/university_teacher', universityTeacher); api.use('/course_count', courseCount); api.use('/school_location', schoolLocation); -api.use('/studentsAee', studentsAee); +api.use('/students_aee', studentsAee); api.use('/mesoregion', mesoregion); api.use('/microregion', microregion); api.use('/location', location); diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 5f15aab8..6b2d3f84 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -204,7 +204,7 @@ rqf.addField({ studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('numero_estudantes_aee') .field('ano_censo') - .field('COUNT(distinct id_aluno)') + .field('COUNT(distinct id_aluno)', 'total') .group('ano_censo') .order('ano_censo') next(); -- GitLab From 4db96fe80154513e49060582bd63668a64afafca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Tue, 27 Sep 2022 10:05:28 -0300 Subject: [PATCH 291/305] Update filter city (test) --- src/libs/routes/studentsAee.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 6b2d3f84..31db6ff5 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -71,7 +71,7 @@ rqf.addField({ name: 'dims', field: true, where: false -}).addValueToField({ +}).addValueToField({ // working name: 'state', table: 'estado', tableField: ['sigla', 'id'], @@ -90,13 +90,12 @@ rqf.addField({ }, 'filter').addValueToField({ name: 'city', table: 'municipio', - tableField: 'nome', - resultField: 'city_name', + tableField: ['nome', 'id'], + resultField: ['city_name', 'city_id'], where: { relation: '=', type: 'integer', - field: 'id', - table: 'numero_estudantes_aee' + field: 'id' }, join: { primary: 'id', @@ -130,7 +129,7 @@ rqf.addField({ field: 'id' }, }, 'filter').addValueToField({ - name: 'locale_id', + name: 'locale_id', // working table: 'numero_estudantes_aee', tableField: 'localizacao_id', resultField: 'locale_id', @@ -140,7 +139,7 @@ rqf.addField({ field: 'localizacao_id' } }, 'filter').addValue({ - name: 'ethnic_group', + name: 'ethnic_group', // working table: 'numero_estudantes_aee', tableField: 'cor_raca_id', resultField: 'ethnic_group_id', @@ -150,7 +149,7 @@ rqf.addField({ field: 'cor_raca_id' } }).addValue({ - name: 'adm_dependency', + name: 'adm_dependency', // working table: 'numero_estudantes_aee', tableField: 'dependencia_adm_id', resultField: 'adm_dependency_id', @@ -160,7 +159,7 @@ rqf.addField({ field: 'dependencia_adm_id' } }).addValue({ - name:'age_range_all', + name:'age_range_all', // working table: 'numero_estudantes_aee', tableField: 'faixa_etaria_31_03', resultField: 'age_range_all_id', @@ -170,7 +169,7 @@ rqf.addField({ field: 'faixa_etaria_31_03' } }).addValue({ - name: 'gender', + name: 'gender', // working table: 'numero_estudantes_aee', tableField: 'sexo', resultField: 'gender_id', @@ -180,7 +179,7 @@ rqf.addField({ field: 'sexo' } }).addValue({ - name: 'activity_days', + name: 'activity_days', // working table: 'numero_estudantes_aee', tableField: 'dias_atividade', resultField: 'activity_days_id', @@ -190,7 +189,7 @@ rqf.addField({ field: 'dias_atividade' } }).addField({ - name: 'special_service', + name: 'special_service', // working table: 'numero_estudantes_aee', tableField: 'disc_atendimento_especiais', resultField: 'special_service_id', -- GitLab From a67c356d13a8119245a8ac7339778d00f21dffb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Tue, 27 Sep 2022 10:13:15 -0300 Subject: [PATCH 292/305] Update filter region (test) --- src/libs/routes/studentsAee.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 31db6ff5..929af12b 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -71,8 +71,8 @@ rqf.addField({ name: 'dims', field: true, where: false -}).addValueToField({ // working - name: 'state', +}).addValueToField({ + name: 'state', // working table: 'estado', tableField: ['sigla', 'id'], resultField: ['sigla_uf', 'cod_uf'], @@ -88,7 +88,7 @@ rqf.addField({ foreignTable: 'numero_estudantes_aee' } }, 'filter').addValueToField({ - name: 'city', + name: 'city', // working table: 'municipio', tableField: ['nome', 'id'], resultField: ['city_name', 'city_id'], @@ -106,12 +106,11 @@ rqf.addField({ name: 'region', table: 'regiao', tableField: ['nome', 'id'], - resultField: ['region_name', 'regiao_id'], + resultField: ['region_name', 'region_id'], where: { relation: '=', type: 'integer', - field: 'id', - table: 'numero_estudantes_aee' + field: 'id' }, join: { primary: 'id', -- GitLab From 767f725df089c735069339d258a55067771126ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Tue, 27 Sep 2022 10:18:40 -0300 Subject: [PATCH 293/305] Update filter school (test) --- src/libs/routes/studentsAee.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 929af12b..fcc0572f 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -103,7 +103,7 @@ rqf.addField({ foreignTable: 'numero_estudantes_aee' } }, 'filter').addValue({ - name: 'region', + name: 'region', // working table: 'regiao', tableField: ['nome', 'id'], resultField: ['region_name', 'region_id'], @@ -119,14 +119,19 @@ rqf.addField({ } }).addValueToField({ name: 'school', - table: 'numero_estudantes_aee', - tableField: 'escola_id', - resultField: 'school_id', + table: 'escola', + tableField: ['nome_escola', 'id'], + resultField: ['school_name', 'school_id'], where: { relation: '=', type: 'integer', field: 'id' }, + join: { + primary: ['id', 'ano_censo'], + foreign: ['escola_id', 'ano_censo'], + foreignTable: 'numero_estudantes_aee' + } }, 'filter').addValueToField({ name: 'locale_id', // working table: 'numero_estudantes_aee', -- GitLab From 430aa1f8520a1e32b4a0a5a2eace0974a11752d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Tue, 27 Sep 2022 10:23:11 -0300 Subject: [PATCH 294/305] Update filter school (test 2) --- src/libs/routes/studentsAee.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index fcc0572f..617cceb5 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -128,8 +128,8 @@ rqf.addField({ field: 'id' }, join: { - primary: ['id', 'ano_censo'], - foreign: ['escola_id', 'ano_censo'], + primary: 'id', + foreign: 'escola_id', foreignTable: 'numero_estudantes_aee' } }, 'filter').addValueToField({ -- GitLab From 3efd5518e3b80320fa0a844209ea5fcfe7bfdc16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Tue, 27 Sep 2022 11:10:19 -0300 Subject: [PATCH 295/305] Update filter school (test 3) --- src/libs/routes/studentsAee.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 617cceb5..f2906170 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -129,7 +129,7 @@ rqf.addField({ }, join: { primary: 'id', - foreign: 'escola_id', + foreign: ['escola_id', 'ano_censo'], foreignTable: 'numero_estudantes_aee' } }, 'filter').addValueToField({ -- GitLab From 12524926f33956bfc3ec18edb3925da799482904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Wed, 28 Sep 2022 09:34:44 -0300 Subject: [PATCH 296/305] Add console log --- src/libs/routes/studentsAee.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index f2906170..fe4d985c 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -211,6 +211,9 @@ studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { .group('ano_censo') .order('ano_censo') next(); -}, rqf.build(), query, id2str.transform(), response('studentsAee')); +}, rqf.build(), (req, res, next) => { + console.log(req.sql.toString()); + next(); +}, query, id2str.transform(), response('studentsAee')); module.exports = studentsAeeApp; -- GitLab From 15d7874ff2fc1369b9d94bf65f77b23df7ab6ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Wed, 28 Sep 2022 09:41:57 -0300 Subject: [PATCH 297/305] Update school filter --- src/libs/routes/studentsAee.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index fe4d985c..6664294e 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -128,7 +128,7 @@ rqf.addField({ field: 'id' }, join: { - primary: 'id', + primary: ['id', 'ano_censo'], foreign: ['escola_id', 'ano_censo'], foreignTable: 'numero_estudantes_aee' } -- GitLab From 9d68fdf1ed7f0e8c8a5ddb357f55cb0dc43c2b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Wed, 28 Sep 2022 09:51:36 -0300 Subject: [PATCH 298/305] Update school filter(2) --- src/libs/routes/studentsAee.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 6664294e..6e58c188 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -206,10 +206,10 @@ rqf.addField({ studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('numero_estudantes_aee') - .field('ano_censo') - .field('COUNT(distinct id_aluno)', 'total') - .group('ano_censo') - .order('ano_censo') + .field('numero_estudantes_aee.ano_censo') + .field('COUNT(distinct numero_estudantes_aee.id_aluno)', 'total') + .group('numero_estudantes_aee.ano_censo') + .order('numero_estudantes_aee.ano_censo') next(); }, rqf.build(), (req, res, next) => { console.log(req.sql.toString()); -- GitLab From f47c9c748055651398ec1c15c1ef24fc18691113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Wed, 28 Sep 2022 10:00:19 -0300 Subject: [PATCH 299/305] Update school filter(3) --- src/libs/routes/studentsAee.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 6e58c188..6664294e 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -206,10 +206,10 @@ rqf.addField({ studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('numero_estudantes_aee') - .field('numero_estudantes_aee.ano_censo') - .field('COUNT(distinct numero_estudantes_aee.id_aluno)', 'total') - .group('numero_estudantes_aee.ano_censo') - .order('numero_estudantes_aee.ano_censo') + .field('ano_censo') + .field('COUNT(distinct id_aluno)', 'total') + .group('ano_censo') + .order('ano_censo') next(); }, rqf.build(), (req, res, next) => { console.log(req.sql.toString()); -- GitLab From 60566edf870f95e6be8c4e557089a4b8bd1c1974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Wed, 28 Sep 2022 10:04:45 -0300 Subject: [PATCH 300/305] Update school filter(2) --- src/libs/routes/studentsAee.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 6664294e..44752281 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -118,7 +118,7 @@ rqf.addField({ foreignTable: 'numero_estudantes_aee' } }).addValueToField({ - name: 'school', + name: 'school', // working table: 'escola', tableField: ['nome_escola', 'id'], resultField: ['school_name', 'school_id'], @@ -206,10 +206,10 @@ rqf.addField({ studentsAeeApp.get('/', rqf.parse(), (req, res, next) => { req.sql.from('numero_estudantes_aee') - .field('ano_censo') - .field('COUNT(distinct id_aluno)', 'total') - .group('ano_censo') - .order('ano_censo') + .field('numero_estudantes_aee.ano_censo') + .field('COUNT(distinct numero_estudantes_aee.id_aluno)', 'total') + .group('numero_estudantes_aee.ano_censo') + .order('numero_estudantes_aee.ano_censo') next(); }, rqf.build(), (req, res, next) => { console.log(req.sql.toString()); -- GitLab From 36ae691f3224bd84a7b0cf85cdbfec48c2bf7515 Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Fri, 30 Sep 2022 10:21:42 -0300 Subject: [PATCH 301/305] added result for 11 value on cimne detailed filter --- src/libs/convert/cineDetailed.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/convert/cineDetailed.js b/src/libs/convert/cineDetailed.js index bf246f55..d95c7451 100644 --- a/src/libs/convert/cineDetailed.js +++ b/src/libs/convert/cineDetailed.js @@ -19,6 +19,8 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. */ module.exports = function cineDetailed(id) { switch (id) { + case 11: + return 'Programas Básicos'; case 111: return 'Ciência da educação'; case 112: -- GitLab From 8b732db119bea3167b19b18cb25ff2b479bdb8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Kieras?= <jpkieras.oliveira@gmail.com> Date: Fri, 30 Sep 2022 10:56:33 -0300 Subject: [PATCH 302/305] Update adm_dep and localizacao --- src/libs/routes/studentsAee.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/routes/studentsAee.js b/src/libs/routes/studentsAee.js index 44752281..2a45a2f5 100644 --- a/src/libs/routes/studentsAee.js +++ b/src/libs/routes/studentsAee.js @@ -135,12 +135,12 @@ rqf.addField({ }, 'filter').addValueToField({ name: 'locale_id', // working table: 'numero_estudantes_aee', - tableField: 'localizacao_id', + tableField: 'localidade_area_rural', resultField: 'locale_id', where: { relation: '=', type: 'integer', - field: 'localizacao_id' + field: 'localidade_area_rural' } }, 'filter').addValue({ name: 'ethnic_group', // working @@ -155,12 +155,12 @@ rqf.addField({ }).addValue({ name: 'adm_dependency', // working table: 'numero_estudantes_aee', - tableField: 'dependencia_adm_id', + tableField: 'dependencia_adm_priv', resultField: 'adm_dependency_id', where: { relation: '=', type: 'integer', - field: 'dependencia_adm_id' + field: 'dependencia_adm_priv' } }).addValue({ name:'age_range_all', // working -- GitLab From 06345fd5080d0baf3a955b68b5286ff5205405e0 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Fri, 30 Sep 2022 11:00:05 -0300 Subject: [PATCH 303/305] Add local offer name and year filter --- src/libs/routes/universityLocalOffer.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/universityLocalOffer.js b/src/libs/routes/universityLocalOffer.js index 452c0648..64e9d718 100644 --- a/src/libs/routes/universityLocalOffer.js +++ b/src/libs/routes/universityLocalOffer.js @@ -137,7 +137,18 @@ rqf.addField({ field: 'cod_ies', table: 'localoferta_ens_superior' } -}, 'filter'); +}, 'filter').addValue({ + name: 'year', + table: 'localoferta_ens_superior', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '=', + type: 'integer', + table: 'localoferta_ens_superior', + field: 'ano_censo' + } +}); universityLocalOfferApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { @@ -145,6 +156,7 @@ universityLocalOfferApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => .field('distinct localoferta_ens_superior.cod_ies', 'id') .field('localoferta_ens_superior.ano_censo', 'year') .field('ies_ens_superior.nome_ies', 'name') + .field('localoferta_ens_superior.nome', 'localoffer_name') .field('localoferta_ens_superior.cod_uf', 'state_id') .field('localoferta_ens_superior.cod_municipio', 'city_id') .field('localoferta_ens_superior.cod_regiao', 'region_id') -- GitLab From 1082bd49529ec9ca9c26f709ed31231419a89670 Mon Sep 17 00:00:00 2001 From: Pietro Polinari Cavassin <ppc19@inf.ufpr.br> Date: Wed, 5 Oct 2022 10:15:47 -0300 Subject: [PATCH 304/305] add localoffer id --- src/libs/routes/universityLocalOffer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/routes/universityLocalOffer.js b/src/libs/routes/universityLocalOffer.js index 64e9d718..535094c4 100644 --- a/src/libs/routes/universityLocalOffer.js +++ b/src/libs/routes/universityLocalOffer.js @@ -154,6 +154,7 @@ rqf.addField({ universityLocalOfferApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { req.sql.from('localoferta_ens_superior') .field('distinct localoferta_ens_superior.cod_ies', 'id') + .field('localoferta_ens_superior.cod_local_oferta', 'localoffer_id') .field('localoferta_ens_superior.ano_censo', 'year') .field('ies_ens_superior.nome_ies', 'name') .field('localoferta_ens_superior.nome', 'localoffer_name') -- GitLab From 857b477b4d09b0ddc34ef8265fa5afb057ae599c Mon Sep 17 00:00:00 2001 From: godp21 <godp21@inf.ufpr.br> Date: Mon, 10 Oct 2022 09:50:25 -0300 Subject: [PATCH 305/305] removing name column on ocde filters --- src/libs/routes/universityEnrollment.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/routes/universityEnrollment.js b/src/libs/routes/universityEnrollment.js index 7b40635c..3a1d6e47 100644 --- a/src/libs/routes/universityEnrollment.js +++ b/src/libs/routes/universityEnrollment.js @@ -466,8 +466,8 @@ rqf.addField({ }).addValue({ name:'ocde_specific', table: '@', - tableField: ['par_cod_ocde_area_especifica', 'nome_ocde_area_especifica'], - resultField: ['ocde_specific_id', 'ocde_specific_name'], + tableField: ['par_cod_ocde_area_especifica'], + resultField: ['ocde_specific_id'], where: { relation: '=', type: 'integer', @@ -476,8 +476,8 @@ rqf.addField({ }).addValue({ name:'ocde_geral', table: '@', - tableField: ['par_cod_ocde_area_geral', 'nome_ocde_area_geral'], - resultField: ['ocde_geral_id', 'ocde_geral_name'], + tableField: ['par_cod_ocde_area_geral'], + resultField: ['ocde_geral_id'], where: { relation: '=', type: 'integer', @@ -486,8 +486,8 @@ rqf.addField({ }).addValue({ name:'ocde_detailed', table: '@', - tableField: ['par_cod_ocde_area_detalhada', 'nome_ocde_area_detalhada'], - resultField: ['ocde_detailed_id', 'ocde_detailed_name'], + tableField: ['par_cod_ocde_area_detalhada'], + resultField: ['ocde_detailed_id'], where: { relation: '=', type: 'integer', -- GitLab