diff --git a/src/libs/routes/SMPPIR/education.js b/src/libs/routes/SMPPIR/education.js new file mode 100644 index 0000000000000000000000000000000000000000..812f0eda72be80a4c4cdcf63895073a20ee384bb --- /dev/null +++ b/src/libs/routes/SMPPIR/education.js @@ -0,0 +1,139 @@ +/* +Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre +Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + +This file is part of SMPPIR-Node. + +SMPPIR-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. + +SMPPIR-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 SMPPIR-Node. If not, see <https://www.gnu.org/licenses/>. +*/ + + + +const express = require('express'); + +const educationApp = express.Router(); + +const libs = `${process.cwd()}/libs`; + +const squel = require('squel'); + +const query = require(`${libs}/middlewares/query`).query; + +const response = require(`${libs}/middlewares/response`); + +const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); + +const rqf = new ReqQueryFields(); +rqf.addField({ + name: 'filter', + field: false, + where: true, +}).addField({ + name: 'dims', + field: true, + where: false, +}) + +.addValue({ + name: 'ethnic', + table: 'education_ag', + tableField: 'cor_raca_aluno', + resultField: 'ds_cor_raca_aluno', + where: { + relation: '=', + type: 'string', + field: 'cor_raca_aluno', + }, +}).addValue({ + name: 'year', + table: 'education_ag', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '=', + type: 'integer', + field: 'ano_censo', + }, +}).addValue({ + name: 'min_year', + table: 'education_ag', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '>=', + type: 'integer', + field: 'ano_censo', + }, +}).addValue({ + name: 'max_year', + table: 'v_ag', + tableField: 'ano_censo', + resultField: 'year', + where: { + relation: '<=', + type: 'integer', + field: 'ano_censo', + }, +}).addValue({ + name: 'region', + table: 'education_ag', + tableField: 'nome_regiao_ies', + resultField: 'region', + where: { + relation: '=', + type: 'string', + field: 'nome_regiao_ies', + }, +}).addValue({ + name: 'uf', + table: 'education_ag', + tableField: 'sigla_uf_ies', + resultField: 'uf', + where: { + relation: '=', + type: 'string', + field: 'sigla_uf_ies', + }, +}).addValue({ + name: 'quotas', + table: 'education_ag', + tableField: 'reserva_vagas', + resultField: 'cod_reserva_vagas', + where: { + relation: '=', + type: 'string', + field: 'reserva_vagas', + }, +}).addValue({ + name: 'admission', + table: 'education_ag', + tableField: 'ingressante', + resultField: 'cod_ingressantes', + where: { + relation: '=', + type: 'string', + field: 'ingressante', + }, +}); + +educationApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { + req.sql.field('education_ag.ano_censo as no_ano_pesquisa') + .field('SUM(total) AS total') + .from('education_ag') + .group('education_ag.ano_censo') + .order('education_ag.ano_censo'); + next(); +}, query, response('education')); + +module.exports = educationApp; diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 4b0cdd71b1853e330e6dc24789e9b6edd0c2e43c..23c1b92d4ff5cdeac4fd1ef71fd052f820a4c6e8 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -100,6 +100,8 @@ const youth_education = require(`${libs}/routes/SMPPIR/youth_education`) const sim = require(`${libs}/routes/SMPPIR/sim`) +const education = require(`${libs}/routes/SMPPIR/education`) + const taxa_homicidios = require(`${libs}/routes/SMPPIR/taxa_homicidios`) const traditional_families = require(`${libs}/routes/SMPPIR/traditional_families`) @@ -156,6 +158,7 @@ api.use('/ciganos_sustentability', ciganos_sustentability); api.use('/youth_jobs', youth_jobs) api.use('/youth_education', youth_education) api.use('/sim', sim) +api.use('/education', education) api.use('/taxa_homicidios', taxa_homicidios) api.use('/traditional_families', traditional_families) api.use('/traditional_families_people', traditional_families_people)