diff --git a/lib/cartodb/api/overviews_api.js b/lib/cartodb/api/overviews_api.js index 305d6422..98ac4881 100644 --- a/lib/cartodb/api/overviews_api.js +++ b/lib/cartodb/api/overviews_api.js @@ -1,6 +1,6 @@ // TODO: use pgQueryRunner parameter directly -function OverviewsApi(queryTablesApi) { - this.pgQueryRunner = queryTablesApi.pgQueryRunner; +function OverviewsApi(pgQueryRunner) { + this.pgQueryRunner = pgQueryRunner; } module.exports = OverviewsApi; diff --git a/lib/cartodb/controllers/map.js b/lib/cartodb/controllers/map.js index 803f5768..ba06a48f 100644 --- a/lib/cartodb/controllers/map.js +++ b/lib/cartodb/controllers/map.js @@ -18,7 +18,6 @@ var TablesCacheEntry = require('../cache/model/database_tables_entry'); var MapConfigNamedLayersAdapter = require('../models/mapconfig_named_layers_adapter'); var NamedMapMapConfigProvider = require('../models/mapconfig/named_map_provider'); var CreateLayergroupMapConfigProvider = require('../models/mapconfig/create_layergroup_provider'); -var OverviewsApi = require('../api/overviews_api'); var MapConfigOverviewsAdapter = require('../models/mapconfig_overviews_adapter'); /** @@ -33,7 +32,8 @@ var MapConfigOverviewsAdapter = require('../models/mapconfig_overviews_adapter') * @param {LayergroupAffectedTables} layergroupAffectedTables * @constructor */ -function MapController(authApi, pgConnection, templateMaps, mapBackend, metadataBackend, queryTablesApi, +function MapController(authApi, pgConnection, templateMaps, mapBackend, metadataBackend, + queryTablesApi, overviewsApi, surrogateKeysCache, userLimitsApi, layergroupAffectedTables) { BaseController.call(this, authApi, pgConnection); @@ -43,7 +43,7 @@ function MapController(authApi, pgConnection, templateMaps, mapBackend, metadata this.mapBackend = mapBackend; this.metadataBackend = metadataBackend; this.queryTablesApi = queryTablesApi; - this.overviewsApi = new OverviewsApi(this.queryTablesApi); + this.overviewsApi = overviewsApi; this.surrogateKeysCache = surrogateKeysCache; this.userLimitsApi = userLimitsApi; this.layergroupAffectedTables = layergroupAffectedTables; diff --git a/lib/cartodb/server.js b/lib/cartodb/server.js index f4205676..0a1f92af 100644 --- a/lib/cartodb/server.js +++ b/lib/cartodb/server.js @@ -20,6 +20,7 @@ var mapnik = windshaft.mapnik; var TemplateMaps = require('./backends/template_maps.js'); var QueryTablesApi = require('./api/query_tables_api'); +var OverviewsApi = require('./api/overviews_api'); var UserLimitsApi = require('./api/user_limits_api'); var AuthApi = require('./api/auth_api'); var LayergroupAffectedTablesCache = require('./cache/layergroup_affected_tables'); @@ -52,6 +53,7 @@ module.exports = function(serverOptions) { var pgConnection = new PgConnection(metadataBackend); var pgQueryRunner = new PgQueryRunner(pgConnection); var queryTablesApi = new QueryTablesApi(pgQueryRunner); + var overviewsApi = new OverviewsApi(pgQueryRunner); var userLimitsApi = new UserLimitsApi(metadataBackend, { limits: { cacheOnTimeout: serverOptions.renderer.mapnik.limits.cacheOnTimeout || false, @@ -175,6 +177,7 @@ module.exports = function(serverOptions) { mapBackend, metadataBackend, queryTablesApi, + overviewsApi, surrogateKeysCache, userLimitsApi, layergroupAffectedTablesCache diff --git a/test/integration/mapconfig_overviews_adapter.js b/test/integration/mapconfig_overviews_adapter.js index e6178d1b..b7d95cfc 100644 --- a/test/integration/mapconfig_overviews_adapter.js +++ b/test/integration/mapconfig_overviews_adapter.js @@ -6,7 +6,6 @@ var RedisPool = require('redis-mpool'); var cartodbRedis = require('cartodb-redis'); var PgConnection = require(__dirname + '/../../lib/cartodb/backends/pg_connection'); var PgQueryRunner = require('../../lib/cartodb/backends/pg_query_runner'); -var QueryTablesApi = require('../../lib/cartodb/api/query_tables_api'); var OverviewsApi = require('../../lib/cartodb/api/overviews_api'); var MapConfigOverviewsAdapter = require('../../lib/cartodb/models/mapconfig_overviews_adapter'); @@ -18,8 +17,7 @@ var redisPool = new RedisPool(global.environment.redis); var metadataBackend = cartodbRedis({pool: redisPool}); var pgConnection = new PgConnection(metadataBackend); var pgQueryRunner = new PgQueryRunner(pgConnection); -var queryTablesApi = new QueryTablesApi(pgQueryRunner); -var overviewsApi = new OverviewsApi(queryTablesApi); +var overviewsApi = new OverviewsApi(pgQueryRunner); var mapConfigOverviewsAdapter = new MapConfigOverviewsAdapter(overviewsApi); diff --git a/test/integration/overviews-api.js b/test/integration/overviews-api.js index c7dface6..0d28f050 100644 --- a/test/integration/overviews-api.js +++ b/test/integration/overviews-api.js @@ -21,7 +21,7 @@ describe('OverviewsApi', function() { var pgConnection = new PgConnection(metadataBackend); var pgQueryRunner = new PgQueryRunner(pgConnection); queryTablesApi = new QueryTablesApi(pgQueryRunner); - overviewsApi = new OverviewsApi(queryTablesApi); + overviewsApi = new OverviewsApi(pgQueryRunner); }); it('should return an empty relation for tables that have no overviews', function(done) {