From e450bde4bff13edf286568c46f8a6e11860eaeb7 Mon Sep 17 00:00:00 2001
From: fgs21 <fgs21@inf.ufpr.br>
Date: Wed, 9 Oct 2024 11:55:54 -0300
Subject: [PATCH] [ADD] Adding new filters and new fields to query

---
 src/libs/routes_v1/uniLocalOfferAggregate.js | 33 ++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/libs/routes_v1/uniLocalOfferAggregate.js b/src/libs/routes_v1/uniLocalOfferAggregate.js
index ab50ef37..f50afff1 100644
--- a/src/libs/routes_v1/uniLocalOfferAggregate.js
+++ b/src/libs/routes_v1/uniLocalOfferAggregate.js
@@ -46,6 +46,36 @@ rqf.addField({
     name: 'dims',
     field: true,
     where: false
+}).addValue({
+    name: 'min_year',
+    table: 'curso_superior_agregado',
+    tableField: 'ano_censo',
+    resultField: 'year',
+    where: {
+        relation: '>=',
+        type: 'integer',
+        field: 'ano_censo'
+    }
+}).addValue({
+    name: 'max_year',
+    table: 'curso_superior_agregado',
+    tableField: '',
+    resultField: 'year',
+    where: {
+        relation: '<=',
+        type: 'integer',
+        field: 'ano_censo'
+    }
+}).addValue({
+    name: 'region',
+    table: 'curso_superior_agregado',
+    tableField: 'cod_reg',
+    resultField: 'region_id',
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'cod_reg'
+    }
 }).addValue({
     name: 'state',
     table: 'estado',
@@ -83,6 +113,9 @@ uniLocalOfferAggregateApp.get('/', rqf.parse(), rqf.build(), (req, res, next) =>
     req.sql.from('curso_superior_agregado')
     .field('DISTINCT curso_superior_agregado.cod_ies', 'id')
     .field('ies_ens_superior.nome_ies', 'name')
+    .field('curso_superior_agregado.cod_mun', 'city_id')
+    .field('curso_superior_agregado.cod_uf', 'state_id')
+    .field('curso_superior_agregado.cod_reg', 'region_id')
     .join('ies_ens_superior', null, 'curso_superior_agregado.cod_ies = ies_ens_superior.cod_ies and curso_superior_agregado.ano_censo = ies_ens_superior.ano_censo')
     .order('curso_superior_agregado.cod_ies')
     next();
-- 
GitLab