Skip to content

Commit 6a5b563

Browse files
committed
optimize to avoid doble ts convertion, add ts format to loadBuildRange()
1 parent bfad841 commit 6a5b563

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/cubejs-query-orchestrator/src/orchestrator/PreAggregationPartitionRangeLoader.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class PreAggregationPartitionRangeLoader {
132132

133133
public async replaceQueryBuildRangeParams(queryValues: string[]): Promise<string[] | null> {
134134
if (queryValues.find(p => p === BUILD_RANGE_START_LOCAL || p === BUILD_RANGE_END_LOCAL)) {
135-
const [buildRangeStart, buildRangeEnd] = await this.loadBuildRange();
135+
const [buildRangeStart, buildRangeEnd] = await this.loadBuildRange(this.preAggregation.timestampFormat);
136136
return queryValues?.map(
137137
param => {
138138
if (param === BUILD_RANGE_START_LOCAL) {
@@ -406,13 +406,13 @@ export class PreAggregationPartitionRangeLoader {
406406
return { buildRange: dateRange, partitionRanges };
407407
}
408408

409-
public async loadBuildRange(): Promise<QueryDateRange> {
409+
public async loadBuildRange(timestampFormat: string = 'YYYY-MM-DDTHH:mm:ss.SSS'): Promise<QueryDateRange> {
410410
const { preAggregationStartEndQueries } = this.preAggregation;
411411
const [startDate, endDate] = await Promise.all(
412412
preAggregationStartEndQueries.map(
413413
async rangeQuery => utcToLocalTimeZone(
414414
this.preAggregation.timezone,
415-
'YYYY-MM-DDTHH:mm:ss.SSS',
415+
timestampFormat,
416416
PreAggregationPartitionRangeLoader.extractDate(await this.loadRangeQuery(rangeQuery)),
417417
)
418418
),
@@ -432,7 +432,7 @@ export class PreAggregationPartitionRangeLoader {
432432
preAggregationStartEndQueries.map(
433433
async (rangeQuery, i) => utcToLocalTimeZone(
434434
this.preAggregation.timezone,
435-
'YYYY-MM-DDTHH:mm:ss.SSS',
435+
timestampFormat,
436436
PreAggregationPartitionRangeLoader.extractDate(
437437
await this.loadRangeQuery(
438438
rangeQuery, i === 0 ? wholeSeriesRanges[0] : wholeSeriesRanges[wholeSeriesRanges.length - 1],

0 commit comments

Comments
 (0)