Skip to content

Commit

Permalink
Fix custom compare time range not applied
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaHegde committed Jan 3, 2025
1 parent 0be3982 commit 94e9be7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 3 additions & 0 deletions web-common/src/features/dashboards/stores/dashboard-stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,9 @@ const metricsViewReducers = {
metricsViewSpec: V1MetricsViewSpec,
) {
updateMetricsExplorerByName(name, (metricsExplorer) => {
if (comparisonTimeRange) {
metricsExplorer.showTimeComparison = true;
}
metricsExplorer.selectedComparisonTimeRange = comparisonTimeRange;
AdvancedMeasureCorrector.correct(metricsExplorer, metricsViewSpec);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@
start: Date,
end: Date,
) {
if (!showTimeComparison) {
metricsExplorerStore.displayTimeComparison(
$exploreName,
!showTimeComparison,
);
}
metricsExplorerStore.setSelectedComparisonRange(
$exploreName,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
getAdjustedFetchTime,
} from "@rilldata/web-common/lib/time/ranges";
import { isoDurationToFullTimeRange } from "@rilldata/web-common/lib/time/ranges/iso-ranges";
import type { DashboardTimeControls } from "@rilldata/web-common/lib/time/types";
import {
type DashboardTimeControls,
TimeComparisonOption,
type TimeRange,
TimeRangePreset,
Expand Down Expand Up @@ -419,7 +419,12 @@ function getComparisonTimeRange(
name: comparisonOption,
};
}
} else if (comparisonTimeRange.name === TimeComparisonOption.CUSTOM) {
} else if (
comparisonTimeRange.name === TimeComparisonOption.CUSTOM ||
// 1st step towards using a single `Custom` variable
// TODO: replace the usage of TimeComparisonOption.CUSTOM with TimeRangePreset.CUSTOM
comparisonTimeRange.name === TimeRangePreset.CUSTOM
) {
return comparisonTimeRange;
} else {
// variable time range of some kind.
Expand Down

0 comments on commit 94e9be7

Please sign in to comment.