From cc74bde45b4db760fb6dc965fd7208caf43e7f6a Mon Sep 17 00:00:00 2001
From: Vytor Calixto <vytorcalixto@gmail.com>
Date: Wed, 25 Oct 2017 16:14:25 -0200
Subject: [PATCH] Add auxiliar routes

---
 src/libs/routes/infrastructure.js | 47 +++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/src/libs/routes/infrastructure.js b/src/libs/routes/infrastructure.js
index 9e496ccd..8f8d171c 100644
--- a/src/libs/routes/infrastructure.js
+++ b/src/libs/routes/infrastructure.js
@@ -22,6 +22,53 @@ let rqf = new ReqQueryFields();
 
 infrastructureApp.use(cache('15 day'));
 
+infrastructureApp.get('/year_range', cache('15 day'), (req, res, next) => {
+    req.sql.from('escola')
+    .field('MIN(escola.ano_censo)', 'start_year')
+    .field('MAX(escola.ano_censo)', 'end_year')
+    .where('escola.ano_censo > 2014');
+    next();
+}, query, response('range'));
+
+infrastructureApp.get('/years', cache('15 day'), (req, res, next) => {
+    req.sql.from('escola').
+    field('DISTINCT escola.ano_censo', 'year')
+    .where('escola.ano_censo > 2014');
+    next();
+}, query, response('years'));
+
+infrastructureApp.get('/source', (req, res, next) => {
+    req.sql.from('fonte')
+    .field('fonte', 'source')
+    .where('tabela = \'escola\'');
+    next();
+}, query, response('source'));
+
+infrastructureApp.get('/location', cache('15 day'), (req, res, next) => {
+    req.result = [
+        {id: 1, name: 'Urbana'},
+        {id: 2, name: 'Rural'}
+    ];
+    next();
+}, response('location'));
+
+//TODO: location_detailed
+
+infrastructureApp.get('/adm_dependency', (req, res, next) => {
+    req.sql.from('dependencia_adm')
+    .field('id')
+    .field('nome', 'name')
+    .where('id <= 4');
+    next();
+}, query, response('adm_dependency'));
+
+infrastructureApp.get('/adm_dependency_detailed', cache('15 day'), (req, res, next) => {
+    req.sql.from('dependencia_adm_priv')
+    .field('id', 'id')
+    .field('nome', 'name');
+    next();
+}, query, response('adm_dependency_detailed'));
+
 rqf.addField({
     name: 'filter',
     field: false,
-- 
GitLab