chesterxgchen opened a new pull request #9506: import_dashboards Issues URL: https://github.com/apache/incubator-superset/pull/9506 ### CATEGORY Choose one - [X] Bug Fix - [ ] Enhancement (new features, refinement) - [ ] Refactor - [ ] Add tests - [ ] Build / Development Environment - [ ] Documentation ### SUMMARY <!--- Describe the change below, including rationale and design decisions --> There are several related issues in the import_dashboards 1) The current code check if the imported dashboard is existing dashboard by comparing current dash's remote_id with imported_dashboard.id. But the imported_dashboard.id is always None. You can check the export_dashboards code and resulting json dump file. The result is that every dashboard imported is new dashboards. Change the code to compare remote_ids on both dashboard will partially this issue. 2) In cases of multiple superset instances, and each instance with its own database. For example, production and sandbox deployment. User develop on sandbox and publish to production instance using export/import_dashboards. In such scenario, even the two dashboards contents are the same, the remote_ids could be different. The result will be same as No. 1 issue, where imported dashboard is treated as new one instead of updated one. The proposed fix is to change the test for existing dashboard condition as follows: "remote_id" in dash.params_dict and ( dash.params_dict["remote_id"] == dashboard_to_import.params_dict["remote_id"] or dash.dashboard_title == dashboard_to_import.dashboard_title ) instead "remote_id" in dash.params_dict and dash.params_dict["remote_id"] == dashboard_to_import.id * If the remote_ids are the same, one can use it to update dashboards including update title * if the remote_ids are different, but the titles are the same, we can update dashboards, address the issue of database migration * if both remote_ids and titles are different, then we treat the imported dashboard as new one. Status: I have tested the changes in 0.34 release, where the code is still in core.py. Notice the latest versions only move the functions from core.py to dashboard.py, but no actually code changes. the same code should work for the new versions. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF <!--- Skip this if not applicable --> ### TEST PLAN <!--- What steps should be taken to verify the changes --> Base test : Before the code change: select and export a dashboard; then import the dashboard with the json file. you will see the new dashboard with same title created, instead updated. import multiple times, you will see each import creates a new dashboard Test case 1: after the code change: select and export a dashboard; then import the dashboard with the json file. you only see one dashboard with the same title Test Case 2: after the code change: use the same test case 1, except manually change the tile of dashboard in the json file, then import dashboard, you should seen the dashboard title changed to the new one Test Case 3 after the code change: Follow the test chase 1, except change the remote_id in the json file (simulate the dashboard from another database). Import the dashboard again, you should see the updated dashboard with (only one) with same title. ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [ ] Changes UI - [ ] Requires DB Migration. - [ ] Confirm DB Migration upgrade and downgrade tested. - [ ] Introduces new feature or API - [ ] Removes existing feature or API ### REVIEWERS
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
