Skip to content
Snippets Groups Projects
Commit c16ed270 authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

[ci skip] Fix cache loop in infrastrucutre

cache
ehcac
cache
ehcac
parent 1c540973
No related branches found
No related tags found
1 merge request!116Release v1.0.0
Pipeline #
...@@ -24,24 +24,20 @@ const cache = require('apicache').options({ debug: config.debug, statusCodes: {i ...@@ -24,24 +24,20 @@ const cache = require('apicache').options({ debug: config.debug, statusCodes: {i
let rqf = new ReqQueryFields(); let rqf = new ReqQueryFields();
infrastructureApp.use(cache('15 day'));
infrastructureApp.get('/year_range', cache('15 day'), (req, res, next) => { infrastructureApp.get('/year_range', cache('15 day'), (req, res, next) => {
req.sql.from('escola') req.sql.from('escola')
.field('MIN(escola.ano_censo)', 'start_year') .field('MIN(escola.ano_censo)', 'start_year')
.field('MAX(escola.ano_censo)', 'end_year') .field('MAX(escola.ano_censo)', 'end_year');
.where('escola.ano_censo > 2014');
next(); next();
}, query, response('range')); }, query, response('range'));
infrastructureApp.get('/years', cache('15 day'), (req, res, next) => { infrastructureApp.get('/years', cache('15 day'), (req, res, next) => {
req.sql.from('escola'). req.sql.from('escola')
field('DISTINCT escola.ano_censo', 'year') .field('DISTINCT escola.ano_censo', 'year');
.where('escola.ano_censo > 2014');
next(); next();
}, query, response('years')); }, query, response('years'));
infrastructureApp.get('/source', (req, res, next) => { infrastructureApp.get('/source', cache('15 day'), (req, res, next) => {
req.sql.from('fonte') req.sql.from('fonte')
.field('fonte', 'source') .field('fonte', 'source')
.where('tabela = \'escola\''); .where('tabela = \'escola\'');
...@@ -56,7 +52,7 @@ infrastructureApp.get('/location', cache('15 day'), (req, res, next) => { ...@@ -56,7 +52,7 @@ infrastructureApp.get('/location', cache('15 day'), (req, res, next) => {
next(); next();
}, response('location')); }, response('location'));
infrastructureApp.get('/location_detailed', (req, res, next) => { infrastructureApp.get('/location_detailed', cache('15 day'), (req, res, next) => {
req.result = [ req.result = [
{id: 1, name: "Urbana"}, {id: 1, name: "Urbana"},
{id: 2, name: "Rural"}, {id: 2, name: "Rural"},
...@@ -68,7 +64,7 @@ infrastructureApp.get('/location_detailed', (req, res, next) => { ...@@ -68,7 +64,7 @@ infrastructureApp.get('/location_detailed', (req, res, next) => {
next(); next();
}, response('location_detailed')); }, 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') req.sql.from('dependencia_adm')
.field('id') .field('id')
.field('nome', 'name') .field('nome', 'name')
...@@ -255,7 +251,7 @@ function matchQueries(queryTotal, queryPartial) { ...@@ -255,7 +251,7 @@ function matchQueries(queryTotal, queryPartial) {
return match; 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.querySet = [];
req.queryIndex = {}; req.queryIndex = {};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment