From 95509c096d7f3376e6f5fcb59766010c5ee69df4 Mon Sep 17 00:00:00 2001
From: Nicollas <ns17@inf.ufpr.br>
Date: Wed, 19 Aug 2020 09:20:33 -0300
Subject: [PATCH] creating quotas acessibility page

---
 src/libs/routes/SMPPIR/education.js | 139 ++++++++++++++++++++++++++++
 1 file changed, 139 insertions(+)
 create mode 100644 src/libs/routes/SMPPIR/education.js

diff --git a/src/libs/routes/SMPPIR/education.js b/src/libs/routes/SMPPIR/education.js
new file mode 100644
index 00000000..812f0eda
--- /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;
-- 
GitLab