-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
[migration]clean up __from and __to in dashboard json_metadata #6378
[migration]clean up __from and __to in dashboard json_metadata #6378
Conversation
424dcbb
to
2c70db4
Compare
Codecov Report
@@ Coverage Diff @@
## master #6378 +/- ##
=======================================
Coverage 77.31% 77.31%
=======================================
Files 67 67
Lines 9581 9581
=======================================
Hits 7408 7408
Misses 2173 2173 Continue to review full report at Codecov.
|
2c70db4
to
b0a1123
Compare
b020596
to
476b2ce
Compare
|
||
if has_update: | ||
dashboard.json_metadata = json.dumps(json_metadata) | ||
session.merge(dashboard) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to do a merge
and having a single commit
at the end is more efficient.
for key in keys: | ||
val = filters[key] | ||
val['__time_range'] = '{} : {}'.format( | ||
val.pop('__from', '') or '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need the or
.
476b2ce
to
cdc0658
Compare
code is updated per comment. also tested in dev environment...much faster!! |
val.pop('__from', ''), | ||
val.pop('__to', ''), | ||
) | ||
json_metadata.update( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. json_metadata['default_filters'] = json.dumps(filters)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
if '__to' in val: | ||
val.remove('__to') | ||
val.append('__time_range') | ||
json_metadata.update( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. json_metadata['filter_immune_slice_fields'] = filter_immune_slice_fields
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
if len(keys): | ||
for key in keys: | ||
val = filters[key] | ||
val['__time_range'] = '{} : {}'.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any concern that __time_range
could already exist? If so should it trump the __from
and __to
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i think should check if __time_range exist
. if it is exist, just abandon __from and __to parameter, so that not override existed __time_range.
cdc0658
to
dec824f
Compare
dec824f
to
5219596
Compare
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
…data (apache#6378) (cherry picked from commit c42bcf8)
In dashboard Superset allows user save default values for filter slice, and saved in json_metadata. So that when the dashboard is loaded, it will be pre-populated with values for the filters. Superset also allows user set charts that immune from filters. For example:
{"filter_immune_slices": [], "timed_refresh_immune_slices": [], "filter_immune_slice_fields": {"255": ["__from", "__to"]}, "expanded_slices": {}, "default_filters": "{\"254\": {\"__from\": \"1 months ago\", \"dim_country\": [\"all\"]}}"}
after recently introduced time_range, __from and __to in json_metadata didn't correctly merge with time_range. It introduces extra __from/__to parameter into Filter control, and cause chart show
no data
. In airbnb we have about 500 dashboards set __from and __to in json_metadata.Fix: I wrote this migration script to update __from/__to to __time_range for json_metadata.
@betodealmeida @mistercrunch @john-bodley @timifasubaa @michellethomas