fixed number of categories

This commit is contained in:
javi 2015-11-09 10:42:38 +01:00
parent 695cab290a
commit e0606ee295

View File

@ -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 ')
},