Pick render limit and add it to request context
- Extends the problematic fake request in templates - Picks the value in waterfall, this must be improved because: 1. It does not make sense if there is no layers with limits 2. If we want to include it always without considering the layer type we can do the operation in parallel
This commit is contained in:
parent
f019f34601
commit
a9ab9f8b5c
@ -408,7 +408,8 @@ TemplateMapsController.prototype.instantiateTemplate = function(req, res, templa
|
||||
if ( req.profiler ) req.profiler.done('TemplateMaps_instance');
|
||||
if ( err ) throw err;
|
||||
layergroup = instance;
|
||||
fakereq = { query: {}, params: {}, headers: _.clone(req.headers),
|
||||
fakereq = {query: {}, params: {}, headers: _.clone(req.headers),
|
||||
context: _.clone(req.context),
|
||||
method: req.method,
|
||||
res: res,
|
||||
profiler: req.profiler
|
||||
|
@ -1,12 +1,14 @@
|
||||
var _ = require('underscore');
|
||||
var step = require('step');
|
||||
var LZMA = require('lzma').LZMA;
|
||||
var assert = require('assert');
|
||||
var RedisPool = require('redis-mpool');
|
||||
|
||||
var QueryTablesApi = require('./api/query_tables_api');
|
||||
var PgConnection = require('./backends/pg_connection');
|
||||
var LZMA = require('lzma').LZMA;
|
||||
var TemplateMaps = require('./template_maps.js');
|
||||
var MapConfigNamedLayersAdapter = require('./models/mapconfig_named_layers_adapter');
|
||||
var CdbRequest = require('./models/cdb_request');
|
||||
var assert = require('assert');
|
||||
|
||||
// Whitelist query parameters and attach format
|
||||
var REQUEST_QUERY_PARAMS_WHITELIST = [
|
||||
@ -18,8 +20,7 @@ var REQUEST_QUERY_PARAMS_WHITELIST = [
|
||||
];
|
||||
|
||||
module.exports = function(redisPool) {
|
||||
redisPool = redisPool ||
|
||||
require('redis-mpool')(_.extend(global.environment.redis, {name: 'windshaft:server_options'}));
|
||||
redisPool = redisPool || new RedisPool(_.extend(global.environment.redis, {name: 'windshaft:server_options'}));
|
||||
|
||||
var cartoData = require('cartodb-redis')({ pool: redisPool }),
|
||||
lzmaWorker = new LZMA(),
|
||||
@ -242,14 +243,37 @@ module.exports = function(redisPool) {
|
||||
};
|
||||
|
||||
me.beforeLayergroupCreate = function(req, requestMapConfig, callback) {
|
||||
mapConfigNamedLayersAdapter.getLayers(cdbRequest.userByReq(req), requestMapConfig.layers, pgConnection,
|
||||
function(err, layers, datasource) {
|
||||
var user = cdbRequest.userByReq(req);
|
||||
var namedLayersDatasource;
|
||||
step(
|
||||
function extractNamedLayers() {
|
||||
mapConfigNamedLayersAdapter.getLayers(user, requestMapConfig.layers, pgConnection, this);
|
||||
},
|
||||
function handleNamedLayers(err, layers, datasource) {
|
||||
assert.ifError(err);
|
||||
|
||||
namedLayersDatasource = datasource;
|
||||
requestMapConfig.layers = layers;
|
||||
|
||||
return null;
|
||||
},
|
||||
function getLimits(err) {
|
||||
assert.ifError(err);
|
||||
cartoData.getTilerRenderLimit(user, this);
|
||||
},
|
||||
function handleTilerLimits(err, renderLimit) {
|
||||
assert.ifError(err);
|
||||
req.context.limits = {
|
||||
render: renderLimit
|
||||
};
|
||||
return null;
|
||||
},
|
||||
function finish(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
requestMapConfig.layers = layers;
|
||||
return callback(null, requestMapConfig, datasource);
|
||||
return callback(null, requestMapConfig, namedLayersDatasource);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user