diff --git a/src/libs/routes/infrastructure.js b/src/libs/routes/infrastructure.js index 9e496ccdb4b28d524629d4306ffc2ef2fb8d3d1d..8f8d171cd79851f3b244e40c2e303a937d19c33a 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,