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

feat(explore): Make metric title respond to changes immediately #12747

Merged
merged 4 commits into from
Jan 28, 2021

Conversation

kgabryje
Copy link
Member

SUMMARY

When changes are made in metrics popover, the title should show current value immediately rather than after saving and reopening the popover. When there is no custom title set - display title based on current metric value. If there is a custom title set - always display that title, ignore changes in metric values.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Nagranie.z.ekranu.2021-01-25.o.21.46.58.mov

TEST PLAN

ADDITIONAL INFORMATION

CC @villebro @junlincc @adam-stasiak @ktmud

@junlincc junlincc added the explore:metrics Related to metrics of Explore label Jan 25, 2021
@codecov-io
Copy link

codecov-io commented Jan 25, 2021

Codecov Report

Merging #12747 (72a5e44) into master (044d1ae) will decrease coverage by 0.19%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12747      +/-   ##
==========================================
- Coverage   67.00%   66.81%   -0.20%     
==========================================
  Files        1022     1022              
  Lines       50047    50071      +24     
  Branches     4914     4930      +16     
==========================================
- Hits        33533    33453      -80     
- Misses      16390    16494     +104     
  Partials      124      124              
Flag Coverage Δ
cypress 50.93% <88.57%> (+0.04%) ⬆️
javascript 61.72% <68.57%> (+0.02%) ⬆️
python 63.74% <ø> (-0.35%) ⬇️

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

Impacted Files Coverage Δ
.../controls/MetricControl/AdhocMetricEditPopover.jsx 80.62% <100.00%> (+0.46%) ⬆️
...ntrols/MetricControl/AdhocMetricPopoverTrigger.tsx 94.73% <100.00%> (+3.07%) ⬆️
superset/db_engines/hive.py 0.00% <0.00%> (-85.72%) ⬇️
superset/db_engine_specs/hive.py 73.84% <0.00%> (-17.31%) ⬇️
superset/db_engine_specs/presto.py 81.38% <0.00%> (-6.71%) ⬇️
superset/views/database/mixins.py 80.70% <0.00%> (-1.76%) ⬇️
superset/models/core.py 88.04% <0.00%> (-0.82%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 044d1ae...72a5e44. Read the comment docs.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

A few comments

componentDidUpdate(prevProps, prevState) {
if (
prevState.adhocMetric?.label !== this.state.adhocMetric?.label ||
prevState.savedMetric?.metric_name !== this.state.savedMetric?.metric_name
Copy link
Member

Choose a reason for hiding this comment

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

do we need to add a prevState.savedMetric?.verbose_name !== this.state.savedMetric?.verbose_name here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so - metric_name check is used only to determine whether a different saved metric has been chosen. metric_name is unique, so it's sufficient to compare only this field.

Comment on lines 31 to 32
newMetric: AdhocMetric | Record<string, any>,
oldMetric: AdhocMetric | Record<string, any>,
Copy link
Member

Choose a reason for hiding this comment

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

Is Record<string, any> for saved metrics here? Could this be savedMetricType? (Unrelated bycatch, this type should probably be called SavedMetricType)

Copy link
Member

Choose a reason for hiding this comment

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

Maybe import { Metric } from '@superset-ui/core'; ?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

@kgabryje kgabryje Jan 26, 2021

Choose a reason for hiding this comment

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

@ktmud Good idea! 👍

@adam-stasiak
Copy link
Contributor

adam-stasiak commented Jan 26, 2021

I guess name used once should not be cached when metric was modified.
In my scenario
I set Simple metric and set my name. Then move to SAVED value and back to SIMPLE. I would expect to see name reflecting SIMPLE parameters
https://user-images.githubusercontent.com/25153919/105900651-a21b9700-601c-11eb-87df-6d6f99b67d0a.mov

@adam-stasiak
Copy link
Contributor

My second concern is whether SAVED METRICS Value chosen should reset custom name and set valid for this SAVED METRIC.
After Save I can see SAVED METRIC value is used as name for this metric.

Nagranie.z.ekranu.2021-01-26.o.21.35.28.mov

@junlincc
Copy link
Member

I guess name used once should not be cached when metric was modified.

thank you @adam-stasiak, yes this seems to be an issue. we should address it in this same PR.

@junlincc
Copy link
Member

My second concern is whether SAVED METRICS Value chosen should reset custom name and set valid for this SAVED METRIC.
After Save I can see SAVED METRIC value is used as name for this metric.

this one as well.
BUT, if addressing both @adam-stasiak 's concerns take more than 1 story point, we probably should let them go. @kgabryje

@adam-stasiak
Copy link
Contributor

Tested after changes 🟢

@kgabryje
Copy link
Member Author

Thanks @adam-stasiak 🙂
CC: @junlincc @villebro

@villebro villebro merged commit 14de7b4 into apache:master Jan 28, 2021
villebro pushed a commit that referenced this pull request Jan 29, 2021
* Make metric title respond to changes immediately

* Bug fix

* Change type to Metric

* Bug fix
@mistercrunch mistercrunch added 🍒 1.0.1 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels explore:metrics Related to metrics of Explore size/L v1.0.1 🍒 1.0.1 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants