You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2023/11/02 17:33:39 UTC

(superset) branch sc-73568 updated (a52b0e7f41 -> 29845f7afc)

This is an automated email from the ASF dual-hosted git repository.

beto pushed a change to branch sc-73568
in repository https://gitbox.apache.org/repos/asf/superset.git


    omit a52b0e7f41 fix: remove update_charts_owners
     new 29845f7afc fix: remove update_charts_owners

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (a52b0e7f41)
            \
             N -- N -- N   refs/heads/sc-73568 (29845f7afc)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 tests/integration_tests/dashboards/api_tests.py | 49 -------------------------
 1 file changed, 49 deletions(-)


(superset) 01/01: fix: remove update_charts_owners

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch sc-73568
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 29845f7afc8d39c734fd0f599b854a1b8d5d8ecf
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Thu Nov 2 11:31:50 2023 -0400

    fix: remove update_charts_owners
---
 superset/daos/dashboard.py                      |  9 -----
 superset/dashboards/commands/create.py          |  3 +-
 superset/dashboards/commands/update.py          |  1 -
 tests/integration_tests/dashboards/api_tests.py | 49 -------------------------
 4 files changed, 1 insertion(+), 61 deletions(-)

diff --git a/superset/daos/dashboard.py b/superset/daos/dashboard.py
index cec9e43bea..77f2dd9f34 100644
--- a/superset/daos/dashboard.py
+++ b/superset/daos/dashboard.py
@@ -178,15 +178,6 @@ class DashboardDAO(BaseDAO[Dashboard]):
             return not db.session.query(dashboard_query.exists()).scalar()
         return True
 
-    @staticmethod
-    def update_charts_owners(model: Dashboard, commit: bool = True) -> Dashboard:
-        owners = list(model.owners)
-        for slc in model.slices:
-            slc.owners = list(set(owners) | set(slc.owners))
-        if commit:
-            db.session.commit()
-        return model
-
     @staticmethod
     def set_dash_metadata(  # pylint: disable=too-many-locals
         dashboard: Dashboard,
diff --git a/superset/dashboards/commands/create.py b/superset/dashboards/commands/create.py
index be7468c2ef..4b5cd5fb04 100644
--- a/superset/dashboards/commands/create.py
+++ b/superset/dashboards/commands/create.py
@@ -40,8 +40,7 @@ class CreateDashboardCommand(CreateMixin, BaseCommand):
     def run(self) -> Model:
         self.validate()
         try:
-            dashboard = DashboardDAO.create(attributes=self._properties, commit=False)
-            dashboard = DashboardDAO.update_charts_owners(dashboard, commit=True)
+            dashboard = DashboardDAO.create(attributes=self._properties, commit=True)
         except DAOCreateFailedError as ex:
             logger.exception(ex.exception)
             raise DashboardCreateFailedError() from ex
diff --git a/superset/dashboards/commands/update.py b/superset/dashboards/commands/update.py
index c880eebe89..f9975c0dd2 100644
--- a/superset/dashboards/commands/update.py
+++ b/superset/dashboards/commands/update.py
@@ -58,7 +58,6 @@ class UpdateDashboardCommand(UpdateMixin, BaseCommand):
                     data=json.loads(self._properties.get("json_metadata", "{}")),
                     commit=False,
                 )
-            dashboard = DashboardDAO.update_charts_owners(dashboard, commit=False)
             db.session.commit()
         except DAOUpdateFailedError as ex:
             logger.exception(ex.exception)
diff --git a/tests/integration_tests/dashboards/api_tests.py b/tests/integration_tests/dashboards/api_tests.py
index f676e873b7..cc7bc109b4 100644
--- a/tests/integration_tests/dashboards/api_tests.py
+++ b/tests/integration_tests/dashboards/api_tests.py
@@ -1378,55 +1378,6 @@ class TestDashboardApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixi
         db.session.delete(model)
         db.session.commit()
 
-    @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
-    def test_update_dashboard_chart_owners(self):
-        """
-        Dashboard API: Test update chart owners
-        """
-        user_alpha1 = self.create_user(
-            "alpha1", "password", "Alpha", email="alpha1@superset.org"
-        )
-        user_alpha2 = self.create_user(
-            "alpha2", "password", "Alpha", email="alpha2@superset.org"
-        )
-        admin = self.get_user("admin")
-        slices = []
-        slices.append(
-            db.session.query(Slice).filter_by(slice_name="Girl Name Cloud").first()
-        )
-        slices.append(db.session.query(Slice).filter_by(slice_name="Trends").first())
-        slices.append(db.session.query(Slice).filter_by(slice_name="Boys").first())
-
-        dashboard = self.insert_dashboard(
-            "title1",
-            "slug1",
-            [admin.id],
-            slices=slices,
-        )
-        self.login(username="admin")
-        uri = f"api/v1/dashboard/{dashboard.id}"
-        dashboard_data = {"owners": [user_alpha1.id, user_alpha2.id]}
-        rv = self.client.put(uri, json=dashboard_data)
-        self.assertEqual(rv.status_code, 200)
-
-        # verify slices owners include alpha1 and alpha2 users
-        slices_ids = [slice.id for slice in slices]
-        # Refetch Slices
-        slices = db.session.query(Slice).filter(Slice.id.in_(slices_ids)).all()
-        for slice in slices:
-            self.assertIn(user_alpha1, slice.owners)
-            self.assertIn(user_alpha2, slice.owners)
-            self.assertNotIn(admin, slice.owners)
-            # Revert owners on slice
-            slice.owners = []
-            db.session.commit()
-
-        # Rollback changes
-        db.session.delete(dashboard)
-        db.session.delete(user_alpha1)
-        db.session.delete(user_alpha2)
-        db.session.commit()
-
     @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
     def test_update_dashboard_chart_owners_propagation(self):
         """