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 01/18] 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 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 02/18] 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 03/18] 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 04/18] 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 05/18] 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 06/18] 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 07/18] 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 08/18] 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 09/18] 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 10/18] 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 11/18] 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 12/18] 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 13/18] 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 14/18] 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 15/18] 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 16/18] 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 17/18] 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 18/18] 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