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] 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