diff --git a/lib/torque/provider/filterableJson.js b/lib/torque/provider/filterableJson.js index 8acf153..ea86295 100644 --- a/lib/torque/provider/filterableJson.js +++ b/lib/torque/provider/filterableJson.js @@ -110,10 +110,13 @@ var Profiler = require('../profiler'); var k = 'f' + (j + 1) var v = vals[k]; if (this.options.fields[j].type === 'cat') { - var m = this.categoryMapping[this.options.fields[j].name][v] - if (!m) { - this.categoryMapping[this.options.fields[j].name][v] = Object.keys(this.categoryMapping[this.options.fields[j].name]).length + 1; // do not use 0 + var mapping = this.categoryMapping[this.options.fields[j].name]; + var m = mapping[v] + var count = Object.keys(mapping).length + if (!m && count < 100) { + mapping[v] = 0; } + mapping[v] += 1; v = m } rr.push([r, v]); @@ -191,10 +194,10 @@ var Profiler = require('../profiler'); var filter = self._filters[filterName] if (filter) { if (filter.type == 'range') { - return '(' + self._generateFilterSQLForRange(filterName, filter.range) + ')' + return self._generateFilterSQLForRange(filterName, filter.range) } else if (filter.type == 'cat' && filter.categories.length) { - return '(' + self._generateFilterSQLForCat(filterName, filter.categories, filter.exclusive) + ')' + return self._generateFilterSQLForCat(filterName, filter.categories, filter.exclusive) } else { return "" @@ -205,6 +208,8 @@ var Profiler = require('../profiler'); } }).filter(function(f) { return f.length > 0; + }).map(function(f) { + return "(" + f + ")"; }).join(' and ') },