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(contextmenu): uncaught TypeError #28203

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

sowo
Copy link
Contributor

@sowo sowo commented Apr 24, 2024

SUMMARY

This PR resolves a uncaught TypeError in MixedTimeseries charts with saved metrics.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before
Screencast from 04-24-2024 05:16:25 PM.webm

After
Screencast from 04-24-2024 08:09:58 PM.webm

TESTING INSTRUCTIONS

Create a MixedTimeseries chart with using saved metrics. Without the PR, the context menu (right click) will throw an uncaught TypeError exception. With the PR, the context menu works as expected.

ADDITIONAL INFORMATION

@sowo sowo changed the title Fix label map fix(contextmenu): uncaught TypeError Apr 24, 2024
@@ -257,7 +257,7 @@ def _move_deprecated_extra_fields(self, kwargs: dict[str, Any]) -> None:
@property
def metric_names(self) -> list[str]:
"""Return metrics names (labels), coerce adhoc metrics to strings."""
return get_metric_names(self.metrics or [])
return get_metric_names(self.metrics or [], self.datasource.verbose_map)
Copy link
Member

Choose a reason for hiding this comment

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

can we add a small unit test to verify that metric_names will always return properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hughhhh I've added a unit test and some sanity checking. Not sure if the implementation of those checks (https://github.com/sowo/superset/blob/bd0015426aab9ed949259454e36572473b927c39/superset/common/query_context_processor.py#L187 and https://github.com/sowo/superset/blob/bd0015426aab9ed949259454e36572473b927c39/superset/common/query_context_processor.py#L197) is optimal or if there is a better way to handle AdhocColumns and AdhocMetrics. Please advise.

@sowo sowo marked this pull request as draft April 25, 2024 11:51
@pull-request-size pull-request-size bot added size/M and removed size/S labels May 3, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.16%. Comparing base (a1983e4) to head (bd00154).
Report is 183 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #28203       +/-   ##
===========================================
+ Coverage   67.42%   83.16%   +15.74%     
===========================================
  Files        1923      521     -1402     
  Lines       75591    37187    -38404     
  Branches     8443        0     -8443     
===========================================
- Hits        50967    30928    -20039     
+ Misses      22566     6259    -16307     
+ Partials     2058        0     -2058     
Flag Coverage Δ
hive 49.10% <28.57%> (?)
javascript ?
mysql 77.23% <100.00%> (?)
postgres 77.35% <100.00%> (-0.51%) ⬇️
presto 53.70% <85.71%> (?)
python 83.16% <100.00%> (+5.22%) ⬆️
sqlite ?
unit 58.29% <42.85%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sowo sowo marked this pull request as ready for review May 7, 2024 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants