From be0be3d5c60ad0861f8253a07cd4e3a63df31d9e Mon Sep 17 00:00:00 2001
From: Fernando Erd <fce15@inf.ufpr.br>
Date: Thu, 26 Jul 2018 09:34:24 -0300
Subject: [PATCH] Add generic tables

---
 src/libs/routes/employees.js | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/libs/routes/employees.js b/src/libs/routes/employees.js
index 8e1219d2..cf7dc1ee 100644
--- a/src/libs/routes/employees.js
+++ b/src/libs/routes/employees.js
@@ -104,7 +104,7 @@ rqf.addField({
     where: false
 }).addValue({
     name: 'adm_dependency',
-    table: 'docente',
+    table: '@',
     tableField: 'dependencia_adm_id',
     resultField: 'adm_dependency_id',
     where: {
@@ -114,7 +114,7 @@ rqf.addField({
     }
 }).addValue({
     name: 'adm_dependency_detailed',
-    table: 'docente',
+    table: '@',
     tableField: 'dependencia_adm_priv',
     resultField: 'adm_dependency_detailed_id',
     where: {
@@ -135,7 +135,7 @@ rqf.addField({
     join: {
         primary: 'id',
         foreign: 'escola_regiao_id',
-        foreignTable: 'docente'
+        foreignTable: '@'
     }
 }).addValue({
     name: 'state',
@@ -150,7 +150,7 @@ rqf.addField({
     join: {
         primary: 'id',
         foreign: 'escola_estado_id',
-        foreignTable: 'docente'
+        foreignTable: '@'
     }
 }).addValueToField({
     name: 'city',
@@ -165,7 +165,7 @@ rqf.addField({
     join: {
         primary: 'id',
         foreign: 'escola_municipio_id',
-        foreignTable: 'docente'
+        foreignTable: '@'
     }
 }, 'dims').addValueToField({
     name: 'city',
@@ -180,7 +180,7 @@ rqf.addField({
     join: {
         primary: 'id',
         foreign: 'escola_municipio_id',
-        foreignTable: 'docente'
+        foreignTable: '@'
     }
 }, 'filter').addValueToField({
     name: 'school',
@@ -329,7 +329,7 @@ employeesApp.get('/', rqf.parse(), (req, res, next) => {
     .join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo')
     .group('docente.ano_censo')
     .order('docente.ano_censo')
-    .where('(docente.tipo_docente <= 6) AND (turma.tipo_turma_id <= 3)');
+    .where('(docente.tipo_docente <= 6) AND (turma.tipo_turma_id <= 3) AND (docente.dependencia_adm_id > 1)');
     next();
 
 }, rqf.build(), query,  id2str.transform(),  (req, res, next) => {
-- 
GitLab