Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: timezone from dashboard not being applied in alerts #6292

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions web-common/src/features/alerts/CreateAlertForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
metricsViewName,
exploreName,
dashboardStore,
validSpecStore,
selectors: {
timeRangeSelectors: { timeControlsState },
},
Expand All @@ -56,8 +57,11 @@
dimension = $dashboardStore.selectedDimensionName ?? "";
}

// TODO: get metrics view spec
const timeRange = mapTimeRange(timeControls, {});
const timeRange = mapTimeRange(
timeControls,
$validSpecStore.data?.explore ?? {},
$dashboardStore,
);
const comparisonTimeRange = mapComparisonTimeRange(
$dashboardStore,
timeControls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function getDimensionTableExportArgs(
const timeRange = mapTimeRange(
timeControlState,
validSpecStore.data.explore,
dashboardState,
);
if (!timeRange) return undefined;

Expand Down
6 changes: 5 additions & 1 deletion web-common/src/features/dashboards/pivot/pivot-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ export function getPivotExportArgs(ctx: StateManagers) {

const metricsViewSpec = validSpecStore.data?.metricsView ?? {};
const exploreSpec = validSpecStore.data?.explore ?? {};
const timeRange = mapTimeRange(timeControlState, exploreSpec);
const timeRange = mapTimeRange(
timeControlState,
exploreSpec,
dashboardState,
);
if (!timeRange) return undefined;

return getPivotAggregationRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ export const PreviousCompleteRangeMap: Partial<
export function mapTimeRange(
timeControlState: TimeControlState,
explore: V1ExploreSpec,
exploreState: MetricsExplorerEntity,
) {
if (!timeControlState.selectedTimeRange?.name) return undefined;

const timeRange: V1TimeRange = {};
const timeRange: V1TimeRange = {
timeZone: exploreState.selectedTimezone,
};
switch (timeControlState.selectedTimeRange.name) {
case TimeRangePreset.DEFAULT:
timeRange.isoDuration = explore?.defaultPreset?.timeRange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function getTDDAggregationRequest(
)
return undefined;

const timeRange = mapTimeRange(timeControlState, explore);
const timeRange = mapTimeRange(timeControlState, explore, dashboardState);
if (!timeRange) return undefined;

const comparisonTimeRange = mapComparisonTimeRange(
Expand Down
Loading