|
6 | 6 | TO_PARTITION_RANGE, |
7 | 7 | MAX_SOURCE_ROW_LIMIT, |
8 | 8 | reformatInIsoLocal, |
9 | | - utcToLocalTimeZone, |
| 9 | + utcToLocalTimeZoneInUtc, |
10 | 10 | timeSeries, |
11 | 11 | inDbTimeZone, |
12 | 12 | extractDate |
@@ -136,9 +136,9 @@ export class PreAggregationPartitionRangeLoader { |
136 | 136 | return queryValues?.map( |
137 | 137 | param => { |
138 | 138 | if (param === BUILD_RANGE_START_LOCAL) { |
139 | | - return utcToLocalTimeZone(this.preAggregation.timezone, this.preAggregation.timestampFormat, buildRangeStart); |
| 139 | + return utcToLocalTimeZoneInUtc(this.preAggregation.timezone, this.preAggregation.timestampFormat, buildRangeStart); |
140 | 140 | } else if (param === BUILD_RANGE_END_LOCAL) { |
141 | | - return utcToLocalTimeZone(this.preAggregation.timezone, this.preAggregation.timestampFormat, buildRangeEnd); |
| 141 | + return utcToLocalTimeZoneInUtc(this.preAggregation.timezone, this.preAggregation.timestampFormat, buildRangeEnd); |
142 | 142 | } else { |
143 | 143 | return param; |
144 | 144 | } |
@@ -396,31 +396,42 @@ export class PreAggregationPartitionRangeLoader { |
396 | 396 | const { preAggregationStartEndQueries } = this.preAggregation; |
397 | 397 | const [startDate, endDate] = await Promise.all( |
398 | 398 | preAggregationStartEndQueries.map( |
399 | | - async rangeQuery => PreAggregationPartitionRangeLoader.extractDate(await this.loadRangeQuery(rangeQuery)), |
| 399 | + async rangeQuery => utcToLocalTimeZoneInUtc( |
| 400 | + this.preAggregation.timezone, |
| 401 | + 'YYYY-MM-DDTHH:mm:ss.SSS', |
| 402 | + PreAggregationPartitionRangeLoader.extractDate(await this.loadRangeQuery(rangeQuery)), |
| 403 | + ) |
400 | 404 | ), |
401 | 405 | ); |
| 406 | + |
402 | 407 | if (!this.preAggregation.partitionGranularity) { |
403 | 408 | return this.orNowIfEmpty([startDate, endDate]); |
404 | 409 | } |
| 410 | + |
| 411 | + // startDate & endDate are `localized` here |
405 | 412 | const wholeSeriesRanges = PreAggregationPartitionRangeLoader.timeSeries( |
406 | 413 | this.preAggregation.partitionGranularity, |
407 | 414 | this.orNowIfEmpty([startDate, endDate]), |
408 | 415 | this.preAggregation.timestampPrecision, |
409 | 416 | ); |
410 | 417 | const [rangeStart, rangeEnd] = await Promise.all( |
411 | 418 | preAggregationStartEndQueries.map( |
412 | | - async (rangeQuery, i) => PreAggregationPartitionRangeLoader.extractDate( |
413 | | - await this.loadRangeQuery( |
414 | | - rangeQuery, i === 0 ? wholeSeriesRanges[0] : wholeSeriesRanges[wholeSeriesRanges.length - 1], |
| 419 | + async (rangeQuery, i) => utcToLocalTimeZoneInUtc( |
| 420 | + this.preAggregation.timezone, |
| 421 | + 'YYYY-MM-DDTHH:mm:ss.SSS', |
| 422 | + PreAggregationPartitionRangeLoader.extractDate( |
| 423 | + await this.loadRangeQuery( |
| 424 | + rangeQuery, i === 0 ? wholeSeriesRanges[0] : wholeSeriesRanges[wholeSeriesRanges.length - 1], |
| 425 | + ), |
415 | 426 | ), |
416 | | - ), |
| 427 | + ) |
417 | 428 | ), |
418 | 429 | ); |
419 | 430 | return this.orNowIfEmpty([rangeStart, rangeEnd]); |
420 | 431 | } |
421 | 432 |
|
422 | 433 | private now() { |
423 | | - return utcToLocalTimeZone(this.preAggregation.timezone, 'YYYY-MM-DDTHH:mm:ss.SSS', new Date().toJSON().substring(0, 23)); |
| 434 | + return utcToLocalTimeZoneInUtc(this.preAggregation.timezone, 'YYYY-MM-DDTHH:mm:ss.SSS', new Date().toJSON().substring(0, 23)); |
424 | 435 | } |
425 | 436 |
|
426 | 437 | private orNowIfEmpty(dateRange: QueryDateRange): QueryDateRange { |
|
0 commit comments