Skip to content

Commit 2f0d2da

Browse files
committed
use dayRange instead of new func
1 parent 3b93ada commit 2f0d2da

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

packages/cubejs-client-core/src/ResultSet.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { aliasSeries } from './utils';
88
import {
99
DateRegex,
1010
dayRange,
11-
getGranularityDateRange,
1211
internalDayjs,
1312
isPredefinedGranularity,
1413
LocalDateRegex,
@@ -241,13 +240,8 @@ export default class ResultSet<T extends Record<string, any> = any> {
241240
const [cubeName, dimension, granularity] = member.split('.');
242241

243242
if (granularity !== undefined) {
244-
// Use the new helper function that handles both predefined and custom granularities
245-
const range = getGranularityDateRange(
246-
value,
247-
granularity,
248-
timeDimensionsAnnotation?.[member],
249-
timeDimensionsAnnotation
250-
);
243+
// dayRange.snapTo now handles both predefined and custom granularities
244+
const range = dayRange(value, value, timeDimensionsAnnotation).snapTo(granularity);
251245

252246
const originalTimeDimension = query.timeDimensions?.find((td) => td.dimension);
253247

packages/cubejs-client-core/src/time.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ export const dayRange = (from: any, to: any, annotations?: Record<string, { gran
109109
}
110110

111111
if (customGranularity && customGranularity.interval) {
112-
// For custom granularities, calculate the range based on interval
112+
// For custom granularities, calculate the range for the bucket
113113
const intervalParsed = parseSqlInterval(customGranularity.interval);
114114
const intervalStart = internalDayjs(from);
115-
const intervalEnd = addInterval(internalDayjs(to), intervalParsed);
115+
// End is start + interval - 1 millisecond (to stay within the bucket)
116+
const intervalEnd = addInterval(intervalStart, intervalParsed).subtract(1, 'millisecond');
116117

117118
return dayRange(intervalStart, intervalEnd, annotations);
118119
}

0 commit comments

Comments
 (0)