diff --git a/lib/cartodb/models/aggregation/time-dimension.js b/lib/cartodb/models/aggregation/time-dimension.js index 6fb09771..1a1909ed 100644 --- a/lib/cartodb/models/aggregation/time-dimension.js +++ b/lib/cartodb/models/aggregation/time-dimension.js @@ -32,7 +32,7 @@ function timeExpression(t, tz) { function epochExpression(epoch) { /* jshint maxcomplexity:8 */ // goddammit linter, I like this as is!! const format = /^(\d\d\d\d)(?:\-?(\d\d)(?:\-?(\d\d)(?:[T\s]?(\d\d)(?:(\d\d)(?:\:(\d\d))?)?)?)?)?$/; - const match = epoch.match(format) || []; + const match = (epoch || '').match(format) || []; const year = match[1] || '0001'; const month = match[2] || '01'; const day = match[3] || '01'; @@ -165,7 +165,7 @@ const cyclicParts = { function cyclicSqlExpr(params) { const column = timeExpression(params.time, params.timezone); - return isoParts[params.grouping].replace(/\$t/g, column); + return cyclicParts[params.grouping].replace(/\$t/g, column); } const ACCEPTED_PARAMETERS = ['time', 'grouping', 'timezone', 'count', 'starting', 'format']; @@ -256,7 +256,7 @@ const CLASSIFIERS = { }; function isCyclic(groupBy) { - return groupBy.match(/.+By.+/); + return VALID_CYCLIC_GROUPINGS.includes(groupBy); } function classifierFor(params) {