From e5864f6f69b8ae98fd0b2422e5ac753057e463d7 Mon Sep 17 00:00:00 2001
From: Vytor Calixto <vytorcalixto@gmail.com>
Date: Thu, 8 Dec 2016 11:28:54 -0200
Subject: [PATCH] :art: Refactor squel in /enrollment

---
 src/libs/routes/enrollment.js | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js
index 446d7aca..78aab08c 100644
--- a/src/libs/routes/enrollment.js
+++ b/src/libs/routes/enrollment.js
@@ -20,8 +20,7 @@ const parseParams = require(`${libs}/middlewares/parseParams`);
 // Complete range of the enrollments dataset.
 // Returns a tuple of start and ending years of the complete enrollments dataset.
 enrollmentApp.get('/year_range', (req, res, next) => {
-    req.sql = squel.select()
-        .from('turmas')
+    req.sql.from('turmas')
         .field('MIN(turmas.ano_censo)', 'start_year')
         .field('MAX(turmas.ano_censo)', 'end_year');
 
@@ -30,8 +29,7 @@ enrollmentApp.get('/year_range', (req, res, next) => {
 
 // Returns all educational levels avaible
 enrollmentApp.get('/education_level', (req, res, next) => {
-    req.sql = squel.select()
-        .from('etapa_ensino')
+    req.sql.from('etapa_ensino')
         .field('pk_etapa_ensino_id', 'id')
         .field('desc_etapa', 'name');
 
@@ -40,8 +38,7 @@ enrollmentApp.get('/education_level', (req, res, next) => {
 
 // Returns all adm dependencies
 enrollmentApp.get('/adm_dependency', (req, res, next) => {
-    req.sql = squel.select()
-        .from('dependencia_adms')
+    req.sql.from('dependencia_adms')
         .field('pk_dependencia_adm_id', 'id')
         .field('nome', 'name');
 
-- 
GitLab