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: custom compare time range not applied #6345

Merged
merged 1 commit into from
Jan 6, 2025
Merged
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
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) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to setSelectedComparisonRange to make sure this action leads to a single store update.

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
Loading