From 07be2051441a3cea3d3d99625dd3044d54e3c00d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Leon=20A=2E=20Okida=20Gon=C3=A7alves?= <laog19@inf.ufpr.br>
Date: Wed, 31 May 2023 11:36:17 -0300
Subject: [PATCH] update classroomcount v2

---
 src/libs/routes_v2/classroomCount.js | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/src/libs/routes_v2/classroomCount.js b/src/libs/routes_v2/classroomCount.js
index fbac836a..b7a0ec7e 100644
--- a/src/libs/routes_v2/classroomCount.js
+++ b/src/libs/routes_v2/classroomCount.js
@@ -66,21 +66,6 @@ rqf.addField({
         foreign: 'municipio_id',
         foreignTable: '@'
     }
-}, 'dims').addValueToField({
-    name: 'cityTeacher',
-    table: 'municipio',
-    tableField: ['nome', 'id'],
-    resultField: ['city_name', 'city_id'],
-    where: {
-        relation: '=',
-        type: 'integer',
-        field: 'id'
-    },
-    join: {
-        primary: 'id',
-        foreign: 'escola_cidade_id',
-        foreignTable: '@'
-    }
 }, 'dims').addValueToField({
     name: 'state',
     table: 'estado',
@@ -354,7 +339,7 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
         req.teacherCalc = true;
     }
 
-    req.dims.cityTeacher = true;
+    req.dims.city = true;
     req.dims.formation_level = true;
     req.sql.field('SUM(simcaq_docente_agregada.num_docentes)', 'total')
            .field("'Brasil'", 'name')
@@ -530,11 +515,11 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
                 currentClassroomObj = obj;
 
                 var id_attribute = req.dims.school ? "school_id" : "city_id"
-                
                 var old_ti = ti;
-                while (ti < req.teacher.length && req.teacher[ti][id_attribute] !== classroom[id_attribute]) // match da tabela de professores.
+                while (ti < req.teacher.length && req.teacher[ti][id_attribute] !== classroom[id_attribute]) { // match da tabela de professores.
                     ti++;
-                
+                }
+
                 if (ti === req.teacher.length) {
                     while (classroom[id_attribute] === enrollments[j][id_attribute])
                         enrollments.splice(j, 1)
@@ -1137,6 +1122,8 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
         })
     }
 
+    console.log('fim')
+
     next();
 }, response('classroom_count'));
 
-- 
GitLab