Change camshaft naming from filters
This commit is contained in:
parent
a7dddcebe8
commit
c539d4fbbd
@ -1,6 +1,6 @@
|
||||
var _ = require('underscore');
|
||||
var step = require('step');
|
||||
var CamshaftFilter = require('../models/filter/camshaft');
|
||||
var AnalysisFilter = require('../models/filter/analysis');
|
||||
|
||||
function FilterStatsApi(pgQueryRunner) {
|
||||
this.pgQueryRunner = pgQueryRunner;
|
||||
@ -40,8 +40,8 @@ FilterStatsApi.prototype.getFilterStats = function (username, unfiltered_query,
|
||||
},
|
||||
function getFilteredRows() {
|
||||
if ( filters && !_.isEmpty(filters)) {
|
||||
var camshaftFilter = new CamshaftFilter(filters);
|
||||
var query = camshaftFilter.sql(unfiltered_query);
|
||||
var analysisFilter = new AnalysisFilter(filters);
|
||||
var query = analysisFilter.sql(unfiltered_query);
|
||||
getEstimatedRows(self.pgQueryRunner, username, query, this);
|
||||
} else {
|
||||
this(null, null);
|
||||
|
@ -1,6 +1,6 @@
|
||||
var filters = {
|
||||
category: require('./camshaft/category'),
|
||||
range: require('./camshaft/range')
|
||||
category: require('./analysis/category'),
|
||||
range: require('./analysis/range')
|
||||
};
|
||||
|
||||
function createFilter(filterDefinition) {
|
||||
@ -11,11 +11,11 @@ function createFilter(filterDefinition) {
|
||||
return new filters[filterType](filterDefinition.column, filterDefinition.params);
|
||||
}
|
||||
|
||||
function CamshaftFilters(filters) {
|
||||
function AnalysisFilters(filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
CamshaftFilters.prototype.sql = function(rawSql) {
|
||||
AnalysisFilters.prototype.sql = function(rawSql) {
|
||||
var filters = this.filters || {};
|
||||
var applyFilters = {};
|
||||
|
||||
@ -32,4 +32,4 @@ CamshaftFilters.prototype.sql = function(rawSql) {
|
||||
}, rawSql);
|
||||
};
|
||||
|
||||
module.exports = CamshaftFilters;
|
||||
module.exports = AnalysisFilters;
|
@ -6,7 +6,7 @@ dot.templateSettings.strip = false;
|
||||
|
||||
var filterQueryTpl = dot.template([
|
||||
'SELECT *',
|
||||
'FROM ({{=it._sql}}) _camshaft_category_filter',
|
||||
'FROM ({{=it._sql}}) _analysis_category_filter',
|
||||
'WHERE {{=it._filters}}'
|
||||
].join('\n'));
|
||||
var escapeStringTpl = dot.template('$escape_{{=it._i}}${{=it._value}}$escape_{{=it._i}}$');
|
@ -6,7 +6,7 @@ dot.templateSettings.strip = false;
|
||||
var betweenFilterTpl = dot.template('{{=it._column}} BETWEEN {{=it._min}} AND {{=it._max}}');
|
||||
var minFilterTpl = dot.template('{{=it._column}} >= {{=it._min}}');
|
||||
var maxFilterTpl = dot.template('{{=it._column}} <= {{=it._max}}');
|
||||
var filterQueryTpl = dot.template('SELECT * FROM ({{=it._sql}}) _camshaft_range_filter WHERE {{=it._filter}}');
|
||||
var filterQueryTpl = dot.template('SELECT * FROM ({{=it._sql}}) _analysis_range_filter WHERE {{=it._filter}}');
|
||||
|
||||
function Range(column, filterParams) {
|
||||
this.column = column;
|
@ -2,7 +2,7 @@ var _ = require('underscore');
|
||||
var TableNameParser = require('./table_name_parser');
|
||||
|
||||
var BBoxFilter = require('../models/filter/bbox');
|
||||
var CamshaftFilter = require('../models/filter/camshaft');
|
||||
var AnalysisFilter = require('../models/filter/analysis');
|
||||
|
||||
// Minimim number of filtered rows to use overviews
|
||||
var FILTER_MIN_ROWS = 65536;
|
||||
@ -11,8 +11,8 @@ var FILTER_MAX_FRACTION = 0.2;
|
||||
|
||||
function apply_filters_to_query(query, filters, bbox_filter) {
|
||||
if ( filters && !_.isEmpty(filters)) {
|
||||
var camshaftFilter = new CamshaftFilter(filters);
|
||||
query = camshaftFilter.sql(query);
|
||||
var analysisFilter = new AnalysisFilter(filters);
|
||||
query = analysisFilter.sql(query);
|
||||
}
|
||||
if ( bbox_filter ) {
|
||||
var bboxFilter = new BBoxFilter(bbox_filter.options, bbox_filter.params);
|
||||
|
@ -527,7 +527,7 @@ describe('Overviews query rewriter', function() {
|
||||
it('generates query with filters', function(){
|
||||
var sql = "SELECT ST_Transform(the_geom, 3857) the_geom_webmercator, cartodb_id, name\
|
||||
FROM (SELECT *\
|
||||
FROM (select * from table1) _camshaft_category_filter\
|
||||
FROM (select * from table1) _analysis_category_filter\
|
||||
WHERE name IN ($escape_0$X$escape_0$)) _cdb_analysis_query";
|
||||
var data = {
|
||||
overviews: {
|
||||
@ -555,7 +555,7 @@ describe('Overviews query rewriter', function() {
|
||||
SELECT * FROM table1_ov3, _vovw_scale WHERE _vovw_z = 3\
|
||||
UNION ALL\
|
||||
SELECT * FROM table1, _vovw_scale WHERE _vovw_z > 3\
|
||||
) AS _vovw_table1) _camshaft_category_filter\
|
||||
) AS _vovw_table1) _analysis_category_filter\
|
||||
WHERE name IN ($escape_0$X$escape_0$)\
|
||||
";
|
||||
assertSameSql(overviews_sql, expected_sql);
|
||||
@ -564,7 +564,7 @@ describe('Overviews query rewriter', function() {
|
||||
it('generates query with filters for specific zoom level', function(){
|
||||
var sql = "SELECT ST_Transform(the_geom, 3857) the_geom_webmercator, cartodb_id, name\
|
||||
FROM (SELECT *\
|
||||
FROM (select * from table1) _camshaft_category_filter\
|
||||
FROM (select * from table1) _analysis_category_filter\
|
||||
WHERE name IN ($escape_0$X$escape_0$)) _cdb_analysis_query";
|
||||
var data = {
|
||||
overviews: {
|
||||
@ -581,7 +581,7 @@ describe('Overviews query rewriter', function() {
|
||||
};
|
||||
var overviews_sql = overviewsQueryRewriter.query(sql, data, { zoom_level: 2 });
|
||||
var expected_sql = "\
|
||||
SELECT * FROM (SELECT * FROM table1_ov2) _camshaft_category_filter\
|
||||
SELECT * FROM (SELECT * FROM table1_ov2) _analysis_category_filter\
|
||||
WHERE name IN ($escape_0$X$escape_0$)\
|
||||
";
|
||||
assertSameSql(overviews_sql, expected_sql);
|
||||
@ -590,7 +590,7 @@ describe('Overviews query rewriter', function() {
|
||||
it('does not generates query with aggressive filtering', function(){
|
||||
var sql = "SELECT ST_Transform(the_geom, 3857) the_geom_webmercator, cartodb_id, name\
|
||||
FROM (SELECT *\
|
||||
FROM (select * from table1) _camshaft_category_filter\
|
||||
FROM (select * from table1) _analysis_category_filter\
|
||||
WHERE name IN ($escape_0$X$escape_0$)) _cdb_analysis_query";
|
||||
var data = {
|
||||
overviews: {
|
||||
|
Loading…
Reference in New Issue
Block a user