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: ensure that users viewing chart does not automatically save edit data #16077
Conversation
❗ Please consider rebasing your branch to avoid db migration conflicts. |
…ix-modified-chart
Codecov Report
@@ Coverage Diff @@
## master #16077 +/- ##
==========================================
- Coverage 76.76% 76.60% -0.17%
==========================================
Files 995 996 +1
Lines 52881 52960 +79
Branches 6721 6736 +15
==========================================
- Hits 40596 40571 -25
- Misses 12059 12163 +104
Partials 226 226
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
Comments on the DB migration.
superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py
Outdated
Show resolved
Hide resolved
superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py
Outdated
Show resolved
Hide resolved
superset/migrations/versions/f6196627326f_update_chart_permissions.py
Outdated
Show resolved
Hide resolved
…_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
…_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
…ions.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
…ix-modified-chart
…erset into fix-modified-chart
@pkdotson Maybe I missed some details. I'm curious as to why a get method would modify the metadata? Should we avoid this operation? I searched all of the codebases seems that only save_or_overwrite_slice can change slice object. |
❗ Please consider rebasing your branch to avoid db migration conflicts. |
@zhaoyongjie I'm not sure exactly where it happens either, but one of @betodealmeida's changes started saving The main thing here is that the value being used for "last modified" in the UI should not be something that auto-updates when a database row is written. This PR makes it more explicit. |
/testenv up |
@pkdotson Ephemeral environment spinning up at http://52.38.130.113:8080. Credentials are |
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.
Nice! LGTM
query_context_generation = fields.Boolean( | ||
description=query_context_generation_description, allow_none=True | ||
) |
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 probably don't need this here, but it does no harm.
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.
Awesome, thanks for fixing this!
Ephemeral environment shutdown and build artifacts deleted. |
🏷 2021.31 |
… data (apache#16077) * add last_change_at migration * add last_saved_by db migration * finish rest of api migration * run precommit * fix name * run precommitt * remove unused mods * merge migrations * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/f6196627326f_update_chart_permissions.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * fix test * precommit * remove print * fix test * change test * test commit * test 2 * test 3 * third time the charm * fix put req Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> (cherry picked from commit f0e3b68)
I'm a little perplexed by this PR,
Shouldn't we remedy the root cause, i.e., prevent viewing of a slice from augmenting the database record, rather than adding additional columns to the table schema? This feels somewhat akin to the There Was an Old Lady Who Swallowed a Fly |
@john-bodley I added a change where the first time the user views a saved chart it does a
This means that, programmatically, it was impossible to get the data for a given saved chart, something we needed for reports. We can't populate the new column The side-effect of this is that charts are being shown as modified, even if they're not. The problem here is that the Personally I don't see this as an anti-pattern. FAB offers a column I hope this clarifies things, and makes the solution more acceptable. |
… data (#16077) * add last_change_at migration * add last_saved_by db migration * finish rest of api migration * run precommit * fix name * run precommitt * remove unused mods * merge migrations * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/f6196627326f_update_chart_permissions.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * fix test * precommit * remove print * fix test * change test * test commit * test 2 * test 3 * third time the charm * fix put req Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> (cherry picked from commit f0e3b68)
@betodealmeida I don't have much context on the query context change, but when I read, the following,
i.e., a |
… data (apache#16077) * add last_change_at migration * add last_saved_by db migration * finish rest of api migration * run precommit * fix name * run precommitt * remove unused mods * merge migrations * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/f6196627326f_update_chart_permissions.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * fix test * precommit * remove print * fix test * change test * test commit * test 2 * test 3 * third time the charm * fix put req Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
… data (apache#16077) * add last_change_at migration * add last_saved_by db migration * finish rest of api migration * run precommit * fix name * run precommitt * remove unused mods * merge migrations * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/f6196627326f_update_chart_permissions.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * fix test * precommit * remove print * fix test * change test * test commit * test 2 * test 3 * third time the charm * fix put req Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> (cherry picked from commit f0e3b68)
… data (apache#16077) * add last_change_at migration * add last_saved_by db migration * finish rest of api migration * run precommit * fix name * run precommitt * remove unused mods * merge migrations * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/f6196627326f_update_chart_permissions.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * fix test * precommit * remove print * fix test * change test * test commit * test 2 * test 3 * third time the charm * fix put req Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
… data (apache#16077) * add last_change_at migration * add last_saved_by db migration * finish rest of api migration * run precommit * fix name * run precommitt * remove unused mods * merge migrations * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/f6196627326f_update_chart_permissions.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * fix test * precommit * remove print * fix test * change test * test commit * test 2 * test 3 * third time the charm * fix put req Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> (cherry picked from commit f0e3b68)
… data (apache#16077) * add last_change_at migration * add last_saved_by db migration * finish rest of api migration * run precommit * fix name * run precommitt * remove unused mods * merge migrations * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/6d20ba9ecb33_add_last_saved_at_to_slice_model.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * Update superset/migrations/versions/f6196627326f_update_chart_permissions.py Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> * fix test * precommit * remove print * fix test * change test * test commit * test 2 * test 3 * third time the charm * fix put req Co-authored-by: Beto Dealmeida <roberto@dealmeida.net> (cherry picked from commit 51c04bd)
SUMMARY
This pr fixes an issue where user would view charts and run queries without saving but the api would return that user had modified the chart. This was caused because of a change in the api using query_context where accessing the slice table would do an automatic saved changed_on_delta_humanize. This pr add two new cols to the Slice table so that the user only see's actually modified charts.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
before:
Screen.Recording.2021-08-05.at.9.11.25.AM.mov
after
Screen.Recording.2021-08-05.at.9.40.46.AM.mov
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION