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: public urls with computed measures and dependant measures are hidden #6520

Merged
merged 6 commits into from
Jan 30, 2025

Conversation

AdityaHegde
Copy link
Collaborator

@AdityaHegde AdityaHegde commented Jan 29, 2025

If a public url is created by selecting a computed measure but not the measure it is computed on, the dashboard fails to load since all required measures are not added to the token.

So we need to add all referencedMeasures to fields as well. This has a side effect of showing measures that were not selected.

We do not need to send the referencedMeasures for non-window computed measures.

@begelundmuller
Copy link
Contributor

FYI it's referencedMeasures, not requiredMeasures (maybe getting confused with requiredDimensions)

@AdityaHegde
Copy link
Collaborator Author

I used referencedMeasures in code but mixed it up in the description, updated now.

@AdityaHegde AdityaHegde marked this pull request as ready for review January 29, 2025 11:49
@AdityaHegde AdityaHegde changed the title fix: Add requiredMeasures to explore fields during public url creation fix: public urls with computed measures and dependant measures are hidden Jan 29, 2025
@AdityaHegde AdityaHegde force-pushed the fix/advanced-measures-public-url branch from d72c4ce to e6a6249 Compare January 29, 2025 13:33
@begelundmuller begelundmuller requested review from ericpgreen2 and removed request for begelundmuller January 29, 2025 15:47
@begelundmuller
Copy link
Contributor

@ericpgreen2 Do you want to do this review? I don't have much context around this code.

@@ -145,10 +147,11 @@ export const getFilteredMeasuresAndDimensions = ({
});
if (skipMeasure) return;
measures.add(measureName);
measure.referencedMeasures?.filter((refMes) => measures.add(refMes));
if (!measure.window) nonWindowMeasures.add(measureName);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm having trouble following this function.

  1. What is a "filtered" measure and dimension?
  2. I'm nervous about this line. Adding measures to the list of user-selected measures feels like exactly what caused the original bug. Double-checking... are you sure this is necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding these measures break the totals query, since we dont really get totals data anyway (no data can be seen) it is better to filter them out.

Would be great to add E2E once the setup PR is merged.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems one way this function is overloaded is that it's preparing two different query requests: totals and timeseries, which each have a different set of measures & dimensions.

Can we split this into two functions:

  1. getMeasuresAndDimensionsForTimeSeriesRequest()
  2. getMeasuresForTotalsRequest()

Copy link
Collaborator Author

@AdityaHegde AdityaHegde Jan 30, 2025

Choose a reason for hiding this comment

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

Updated the method, added a param to include/exclude window measures. I dont think the method should differentiate between timeseries vs totals request.

Comment on lines 96 to 128
const measures = new Set<string>();
measureNames.forEach((measureName) => {
const measure = metricsViewSpec.measures?.find(
(m) => m.name === measureName,
);
// temporary check for window measures until the PR to move to AggregationApi is merged
if (!measure || measure.requiredDimensions?.length || !!measure.window)
if (
!measure ||
measure.type ===
MetricsViewSpecMeasureType.MEASURE_TYPE_TIME_COMPARISON ||
(!includeWindowMeasures && measure.window)
// TODO: we need to send a single query for this support
// (measure.type ===
// MetricsViewSpecMeasureType.MEASURE_TYPE_TIME_COMPARISON &&
// (!dashboard.showTimeComparison ||
// !dashboard.selectedComparisonTimeRange))
)
return;

let skipMeasure = false;
measure.requiredDimensions?.forEach((reqDim) => {
if (
reqDim.timeGrain !== V1TimeGrain.TIME_GRAIN_UNSPECIFIED &&
reqDim.timeGrain !== exploreState.selectedTimeRange?.interval
) {
// filter out measures with dependant dimensions not matching the selected grain
skipMeasure = true;
return;
}
});
if (skipMeasure) return;

measures.add(measureName);
measure.referencedMeasures?.filter((refMes) => measures.add(refMes));
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this should be a measures.filter() statement

Copy link
Collaborator Author

@AdityaHegde AdityaHegde Jan 30, 2025

Choose a reason for hiding this comment

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

We dont need referencedMeasures anymore. That was the big fix in the PR. The earlier code should have been a forEach.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, GitHub's UI made this comment confusIng... I meant the whole code block that's highlighted. At the top-level, this code is initializing an empty set const measures = new Set(), then building up an array. Rather, I'd expect the input measureNames to be filtered like measureNames.filter(...).

Copy link
Collaborator Author

@AdityaHegde AdityaHegde Jan 30, 2025

Choose a reason for hiding this comment

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

Ah it was adding referencedMeasures before so it was not a filter. Will change in a follow up PR.

@AdityaHegde AdityaHegde merged commit 0b87431 into main Jan 30, 2025
7 checks passed
@AdityaHegde AdityaHegde deleted the fix/advanced-measures-public-url branch January 30, 2025 15:04
AdityaHegde added a commit that referenced this pull request Jan 30, 2025
…dden (#6520)

* Add requiredMeasures to explore fields

* Do not send referenced measures for non-window measures

* Fix windowed measures

* Fix lint+tests

* Refactor filter method

* Change function name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants