diff --git a/lib/cartodb/controllers/layergroup.js b/lib/cartodb/controllers/layergroup.js index 0522e3b5..0d932008 100644 --- a/lib/cartodb/controllers/layergroup.js +++ b/lib/cartodb/controllers/layergroup.js @@ -243,6 +243,7 @@ LayergroupController.prototype.sendResponse = function(req, res, args) { self.getAffectedTables(req.context.user, dbName, req.params.token, this); }, function sendResponse(err, affectedTables) { + req.profiler.done('affectedTables'); if (err) { console.log('ERROR generating cache channel: ' + err); } @@ -258,18 +259,14 @@ LayergroupController.prototype.sendResponse = function(req, res, args) { }; LayergroupController.prototype.getAffectedTables = function(user, dbName, layergroupId, callback) { + + if (this.layergroupAffectedTables.hasAffectedTables(dbName, layergroupId)) { + return callback(null, this.layergroupAffectedTables.get(dbName, layergroupId)); + } + var self = this; - step( - function checkCached() { - if (self.layergroupAffectedTables.hasAffectedTables(dbName, layergroupId)) { - return callback(null, self.layergroupAffectedTables.get(dbName, layergroupId)); - } - return null; - }, - function extractSQL(err) { - assert.ifError(err); - + function extractSQL() { step( function loadFromStore() { self.mapStore.load(layergroupId, this);