diff --git a/src/libs/routes/infrastructure.js b/src/libs/routes/infrastructure.js index 73b0084899d160ecfba32eb0f2efb8ad283b63cb..ab9331cb8cb5dda65015b33ec013c32c493c4ad2 100644 --- a/src/libs/routes/infrastructure.js +++ b/src/libs/routes/infrastructure.js @@ -24,24 +24,20 @@ const cache = require('apicache').options({ debug: config.debug, statusCodes: {i 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'); + .field('MAX(escola.ano_censo)', 'end_year'); 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'); + req.sql.from('escola') + .field('DISTINCT escola.ano_censo', 'year'); next(); }, query, response('years')); -infrastructureApp.get('/source', (req, res, next) => { +infrastructureApp.get('/source', cache('15 day'), (req, res, next) => { req.sql.from('fonte') .field('fonte', 'source') .where('tabela = \'escola\''); @@ -56,7 +52,7 @@ infrastructureApp.get('/location', cache('15 day'), (req, res, next) => { next(); }, response('location')); -infrastructureApp.get('/location_detailed', (req, res, next) => { +infrastructureApp.get('/location_detailed', cache('15 day'), (req, res, next) => { req.result = [ {id: 1, name: "Urbana"}, {id: 2, name: "Rural"}, @@ -68,7 +64,7 @@ infrastructureApp.get('/location_detailed', (req, res, next) => { next(); }, response('location_detailed')); -infrastructureApp.get('/adm_dependency', (req, res, next) => { +infrastructureApp.get('/adm_dependency', cache('15 day'), (req, res, next) => { req.sql.from('dependencia_adm') .field('id') .field('nome', 'name') @@ -255,7 +251,7 @@ function matchQueries(queryTotal, queryPartial) { return match; } -infrastructureApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { +infrastructureApp.get('/', rqf.parse(), rqf.build(), cache('15 day'), (req, res, next) => { req.querySet = []; req.queryIndex = {};