From 1683215042061e1b0e5b50a24d065bf4398054ec Mon Sep 17 00:00:00 2001 From: Vytor Calixto <vytorcalixto@gmail.com> Date: Tue, 25 Jul 2017 09:44:18 -0300 Subject: [PATCH] Add route /idhml/years --- src/libs/routes/idhml.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libs/routes/idhml.js b/src/libs/routes/idhml.js index 81b920cd..5ba3e12b 100644 --- a/src/libs/routes/idhml.js +++ b/src/libs/routes/idhml.js @@ -39,6 +39,24 @@ idhmlApp.get('/year_range', (req, res, next) => { next(); }, query, response('range')); +idhmlApp.get('/years', (req, res, next) => { + req.sql.from('adh_idh') + .field('DISTINCT adh_idh.ano_censo', 'year'); + next(); +}, query, (req, res, next) => { + req.oldResult = req.result; + + req.sql = squel.select(); + + req.sql.from('adh_idh_uf') + .field('DISTINCT adh_idh_uf.ano_censo', 'year'); + next(); +}, query, (req, res, next) => { + let result = Object.assign(req.oldResult, req.result); + req.result = result; + next(); +}, response('years')); + rqf.addField({ name: 'filter', field: false, -- GitLab