Date histogram: Reduce the threshold to change in auto mode to 100

This commit is contained in:
Raul Marin 2017-12-18 13:30:04 +01:00 committed by Raúl Marín
parent bba6db9dbf
commit 418f5faa11

View File

@ -141,8 +141,8 @@ const dateIntervalQueryTpl = ctx => `
FROM __cdb_interval_in_days, __cdb_interval_in_hours, __cdb_interval_in_minutes, __cdb_interval_in_seconds FROM __cdb_interval_in_days, __cdb_interval_in_hours, __cdb_interval_in_minutes, __cdb_interval_in_seconds
`; `;
/** Constant to switch between aggregations in auto mode */
const MAX_INTERVAL_VALUE = 366; const MAX_INTERVAL_VALUE = 100;
const DATE_AGGREGATIONS = { const DATE_AGGREGATIONS = {
'auto': true, 'auto': true,
@ -250,9 +250,9 @@ ORDER BY bin ASC;
return callback(err); return callback(err);
} }
const aggegations = result.rows[0]; const aggregations = result.rows[0];
const aggregation = Object.keys(aggegations) const aggregation = Object.keys(aggregations)
.map(key => ({ name: key, value: aggegations[key] })) .map(key => ({ name: key, value: aggregations[key] }))
.reduce((closer, current) => { .reduce((closer, current) => {
if (current.value > MAX_INTERVAL_VALUE) { if (current.value > MAX_INTERVAL_VALUE) {
return closer; return closer;