-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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(dashboard): Native filters - add type to native filter configuration #16549
feat(dashboard): Native filters - add type to native filter configuration #16549
Conversation
Codecov Report
@@ Coverage Diff @@
## master #16549 +/- ##
==========================================
- Coverage 76.71% 76.55% -0.16%
==========================================
Files 1002 1004 +2
Lines 53784 53964 +180
Branches 6859 7332 +473
==========================================
+ Hits 41259 41312 +53
- Misses 12288 12412 +124
- Partials 237 240 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Hi @m-ajay this PR is good. After this PR is merged and migration is executed, all exist native filter components should have a |
@Grace Thanks for the review. |
) | ||
continue | ||
|
||
json_meta = json.loads(dashboard.json_metadata) |
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.
You might want to wrap this in a try/except since some charts could store invalid JSON. You can see how other migrations handle this.
json_meta = json.loads(dashboard.json_metadata) | ||
|
||
for native_filter in json_meta.get("native_filter_configuration", []): | ||
native_filter.setdefault("type", "NATIVE_FILTER") |
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.
Why not just native_filter["type"] = "NATIVE_FILTER"
if type
is a new key (which per line 90 it would indicate that it is)? I always forget how dict.setdefault
works as it's rarely used.
|
||
for native_filter in json_meta.get("native_filter_configuration", []): | ||
native_filter.setdefault("type", "NATIVE_FILTER") | ||
dashboard.json_metadata = json.dumps(json_meta) |
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.
For efficiency we likely should only be updating dashboard.json_metadata
for those dashboards which were modified, so maybe something of the form,
if "native_filter_configuration" in json_meta:
for native_filter in json_meta["native_filter_configuration"]:
native_filter["type"] = "NATIVE_FILTER"
dashboard.json_metadata = json.dumps(json_meta)
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.
this lgtm, i love the verbose logging in the db migration too, it makes it easy to understand exactly what's happening
…tion (apache#16549) * iSort fixes * Add type key to the new filters * Fix wrong attribute * PR comments * PR comments * Fix failing tests
…tion (apache#16549) * iSort fixes * Add type key to the new filters * Fix wrong attribute * PR comments * PR comments * Fix failing tests
SUMMARY
In a future PR, we will add a "Section" component to the native filters. We will need a new key to distinguish between them.
TESTING INSTRUCTIONS
Testing existing filters
superset db upgrade
json_metadata
column in dashboards table)Testing new filters
json_metadata
column in dashboards table)ADDITIONAL INFORMATION