From 196e9da775005fb1f09f5dd4dd67d510d21a5ac8 Mon Sep 17 00:00:00 2001
From: Victor Picussa <vp16@inf.ufpr.br>
Date: Wed, 14 Nov 2018 11:28:33 -0200
Subject: [PATCH] [v1.8.0]Adding fix school

---
 CHANGELOG.md              |  1 +
 src/libs/routes/school.js | 42 +++++++++++++++++++++++++++++----------
 2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 05e1e145..97fb7ab0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
 - Add financial route
 - Add employees route
 ### Changed
+- Fix school route
 - Fix transport route
 - Fix return where integral time is null
 - Classroom count route returns school year results for education level 1
diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js
index 83069774..3f4dd714 100644
--- a/src/libs/routes/school.js
+++ b/src/libs/routes/school.js
@@ -60,6 +60,18 @@ schoolApp.get('/location', cache('15 day'), (req, res, next) => {
     next();
 }, response('location'));
 
+schoolApp.get('/rural_location', cache('15 day'), (req, res, next) => {
+    req.result = [
+        {id: 1, name: "Urbana"},
+        {id: 2, name: "Rural"},
+        {id: 3, name: "Rural - Área de assentamento"},
+        {id: 4, name: "Rural - Terra indígena"},
+        {id: 5, name: "Rural - Área remanescente de quilombos"},
+        {id: 6, name: "Rural - Unidade de uso sustentável"}
+    ];
+    next();
+}, response('rural_location'));
+
 schoolApp.get('/adm_dependency', (req, res, next) => {
     req.result = [];
     for(let i = 1; i <= 4; ++i) {
@@ -359,6 +371,16 @@ rqfCount.addField({
         type: 'integer',
         field: 'cod_localizacao'
     }
+}).addValue({
+    name: 'rural_location',
+    table: 'escola',
+    tableField: 'localidade_area_rural',
+    resultField: 'rural_location_id',
+    where: {
+        relation: '=',
+        type: 'integer',
+        field: 'localidade_area_rural'
+    }
 }).addValue({
     name: 'adm_dependency',
     table: 'escola',
@@ -402,52 +424,52 @@ rqfCount.addField({
 }).addValue({
     name: 'education_day_care_child',
     table: 'escola',
-    tableField: 'reg_infantil_creche',
+    tableField: 'reg_infantil_creche_t1',
     resultField: 'education_day_care_child_id',
     where: {
         relation: '=',
         type: 'boolean',
-        field: 'reg_infantil_creche'
+        field: 'reg_infantil_creche_t1'
     }
 }).addValue({
     name: 'education_preschool_child',
     table: 'escola',
-    tableField: 'reg_infantil_preescola',
+    tableField: 'reg_infantil_preescola_t1',
     resultField: 'education_preschool_child_id',
     where: {
         relation: '=',
         type: 'boolean',
-        field: 'reg_infantil_preescola'
+        field: 'reg_infantil_preescola_t1'
     }
 }).addValue({
     name: 'education_begin_elementary_school',
     table: 'escola',
-    tableField: 'reg_fund_ai',
+    tableField: 'reg_fund_ai_t1',
     resultField: 'education_begin_elementary_school_id',
     where: {
         relation: '=',
         type: 'boolean',
-        field: 'reg_fund_ai'
+        field: 'reg_fund_ai_t1'
     }
 }).addValue({
     name: 'education_end_elementary_school',
     table: 'escola',
-    tableField: 'reg_fund_af',
+    tableField: 'reg_fund_af_t1',
     resultField: 'education_end_elementary_school_id',
     where: {
         relation: '=',
         type: 'boolean',
-        field: 'reg_fund_af'
+        field: 'reg_fund_af_t1'
     }
 }).addValue({
     name: 'education_middle_school',
     table: 'escola',
-    tableField: 'reg_medio_medio',
+    tableField: 'reg_medio_medio_t1',
     resultField: 'education_middle_school_id',
     where: {
         relation: '=',
         type: 'boolean',
-        field: 'reg_medio_medio'
+        field: 'reg_medio_medio_t1'
     }
 }).addValue({
     name: 'education_professional',
-- 
GitLab