Refactor construction of OverviewsApi
This commit is contained in:
parent
ef9e9f8c78
commit
3b6abb5c9f
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user