diff --git a/lib/cartodb/api/api-router.js b/lib/cartodb/api/api-router.js index 3f0f7ac0..5a08eb6d 100644 --- a/lib/cartodb/api/api-router.js +++ b/lib/cartodb/api/api-router.js @@ -17,7 +17,7 @@ const AuthBackend = require('../backends/auth'); const UserLimitsApi = require('../backends/api/user_limits_api'); const OverviewsMetadataBackend = require('../backends/overviews-metadata'); const FilterStatsApi = require('../backends/filter-stats'); -const TablesExtentApi = require('../backends/api/tables_extent_api'); +const TablesExtentBackend = require('../backends/tables-extent'); const LayergroupAffectedTablesCache = require('../cache/layergroup_affected_tables'); const SurrogateKeysCache = require('../cache/surrogate_keys_cache'); @@ -125,7 +125,7 @@ module.exports = class ApiRouter { const overviewsMetadataBackend = new OverviewsMetadataBackend(pgQueryRunner); const filterStatsBackend = new FilterStatsApi(pgQueryRunner); - const tablesExtentApi = new TablesExtentApi(pgQueryRunner); + const tablesExtentBackend = new TablesExtentBackend(pgQueryRunner); const mapConfigAdapter = new MapConfigAdapter( new MapConfigNamedLayersAdapter(templateMaps, pgConnection), @@ -173,7 +173,7 @@ module.exports = class ApiRouter { statsBackend, layergroupMetadata, namedMapProviderCache, - tablesExtentApi + tablesExtentBackend }; this.mapRouter = new MapRouter({ collaborators }); diff --git a/lib/cartodb/api/map/map-router.js b/lib/cartodb/api/map/map-router.js index 2e2a3f4a..78b87d1e 100644 --- a/lib/cartodb/api/map/map-router.js +++ b/lib/cartodb/api/map/map-router.js @@ -30,7 +30,7 @@ module.exports = class MapRouter { statsBackend, layergroupMetadata, namedMapProviderCache, - tablesExtentApi + tablesExtentBackend } = collaborators; this.analysisLayergroupController = new AnalysisLayergroupController( @@ -101,7 +101,7 @@ module.exports = class MapRouter { namedMapProviderCache, previewBackend, surrogateKeysCache, - tablesExtentApi, + tablesExtentBackend, metadataBackend, pgConnection, authBackend, diff --git a/lib/cartodb/api/map/preview-template-controller.js b/lib/cartodb/api/map/preview-template-controller.js index 73a194e6..acf58a91 100644 --- a/lib/cartodb/api/map/preview-template-controller.js +++ b/lib/cartodb/api/map/preview-template-controller.js @@ -26,7 +26,7 @@ function PreviewTemplateController ( namedMapProviderCache, previewBackend, surrogateKeysCache, - tablesExtentApi, + tablesExtentBackend, metadataBackend, pgConnection, authBackend, @@ -35,7 +35,7 @@ function PreviewTemplateController ( this.namedMapProviderCache = namedMapProviderCache; this.previewBackend = previewBackend; this.surrogateKeysCache = surrogateKeysCache; - this.tablesExtentApi = tablesExtentApi; + this.tablesExtentBackend = tablesExtentBackend; this.metadataBackend = metadataBackend; this.pgConnection = pgConnection; this.authBackend = authBackend; @@ -61,7 +61,7 @@ PreviewTemplateController.prototype.register = function (mapRouter) { namedMapProviderCache: this.namedMapProviderCache, label: 'STATIC_VIZ_MAP' }), - getStaticImageOptions({ tablesExtentApi: this.tablesExtentApi }), + getStaticImageOptions({ tablesExtentBackend: this.tablesExtentBackend }), getImage({ previewBackend: this.previewBackend, label: 'STATIC_VIZ_MAP' }), setContentTypeHeader(), incrementMapViews({ metadataBackend: this.metadataBackend }), @@ -138,7 +138,7 @@ function prepareLayerFilterFromPreviewLayers ({ namedMapProviderCache, label }) }; } -function getStaticImageOptions ({ tablesExtentApi }) { +function getStaticImageOptions ({ tablesExtentBackend }) { return function getStaticImageOptionsMiddleware(req, res, next) { const { user, mapConfigProvider, template } = res.locals; const { zoom, lon, lat, bbox } = req.query; @@ -164,7 +164,7 @@ function getStaticImageOptions ({ tablesExtentApi }) { return next(); } - tablesExtentApi.getBounds(user, tables, (err, bounds) => { + tablesExtentBackend.getBounds(user, tables, (err, bounds) => { if (err) { return next(); } diff --git a/lib/cartodb/backends/api/tables_extent_api.js b/lib/cartodb/backends/tables-extent.js similarity index 90% rename from lib/cartodb/backends/api/tables_extent_api.js rename to lib/cartodb/backends/tables-extent.js index 7b534a3f..5e78a6b1 100644 --- a/lib/cartodb/backends/api/tables_extent_api.js +++ b/lib/cartodb/backends/tables-extent.js @@ -1,8 +1,8 @@ -function TablesExtentApi(pgQueryRunner) { +function TablesExtentBackend(pgQueryRunner) { this.pgQueryRunner = pgQueryRunner; } -module.exports = TablesExtentApi; +module.exports = TablesExtentBackend; /** * Given a username and a list of tables it will return the estimated extent in SRID 4326 for all the tables based on @@ -13,7 +13,7 @@ module.exports = TablesExtentApi; * `table_name` format as valid input * @param {Function} callback function(err, result) {Object} result with `west`, `south`, `east`, `north` */ -TablesExtentApi.prototype.getBounds = function (username, tables, callback) { +TablesExtentBackend.prototype.getBounds = function (username, tables, callback) { var estimatedExtentSQLs = tables.map(function(table) { return "ST_EstimatedExtent('" + table.schema_name + "', '" + table.table_name + "', 'the_geom_webmercator')"; });