Skip to content

Commit 48fcd20

Browse files
committed
fix: default snap for XTD time ranges (#9231)
1 parent d8e3f5c commit 48fcd20

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

web-common/src/features/dashboards/url-state/time-ranges/RillTime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export class RillPeriodToGrainInterval implements RillTimeInterval {
246246
}
247247

248248
public getGrain() {
249-
return GrainAliasToV1TimeGrain[this.grain];
249+
return getLowerOrderGrain(GrainAliasToV1TimeGrain[this.grain]);
250250
}
251251

252252
public toString() {

web-common/src/features/dashboards/url-state/time-ranges/rill-time.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import {
77
type RillTimeAsOfLabel,
88
RillTimeLabel,
99
} from "@rilldata/web-common/features/dashboards/url-state/time-ranges/RillTime.ts";
10-
import { GrainAliasToV1TimeGrain } from "@rilldata/web-common/lib/time/new-grains";
10+
import {
11+
getLowerOrderGrain,
12+
GrainAliasToV1TimeGrain,
13+
} from "@rilldata/web-common/lib/time/new-grains";
1114
import { V1TimeGrain } from "@rilldata/web-common/runtime-client";
1215
import type { DateTimeUnit } from "luxon";
1316
import nearley from "nearley";
@@ -98,7 +101,7 @@ function getMultiPeriodTestCases(n: number): TestCase[] {
98101

99102
function getPeriodToDateTestCases(): TestCase[] {
100103
return GRAINS.map((g) => {
101-
const protoGrain = GrainAliasToV1TimeGrain[g];
104+
const protoGrain = getLowerOrderGrain(GrainAliasToV1TimeGrain[g]);
102105
const label = capitalizeFirstChar(`${GRAIN_TO_LUXON[g]} to date`);
103106
return <TestCase[]>[
104107
[`${g}TD as of watermark/${g}`, label, true, protoGrain, undefined],
@@ -111,6 +114,8 @@ function getPeriodToDateTestCases(): TestCase[] {
111114
],
112115

113116
[`${g}TD as of watermark/h`, label, true, protoGrain, undefined],
117+
118+
[`${g}TD`, label, false, protoGrain, undefined],
114119
];
115120
}).flat();
116121
}

0 commit comments

Comments
 (0)