rusackas commented on code in PR #44362:
URL: https://github.com/apache/superset/pull/44362#discussion_r4042068144


##########
superset/migrations/versions/2026-09-16_00-01_00fab727cd0a_add_theme_editors_theme_id_index.py:
##########
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""add theme_editors.theme_id index
+
+Revision ID: 00fab727cd0a
+Revises: 60f94cd6cd11
+Create Date: 2026-09-16 00:01:00.000000
+
+"""
+
+from superset.migrations.shared.utils import create_index, drop_index
+
+# revision identifiers, used by Alembic.
+revision = "00fab727cd0a"
+down_revision = "60f94cd6cd11"
+
+TABLE_NAME = "theme_editors"
+INDEX_NAME = "ix_theme_editors_theme_id"
+
+
+def upgrade() -> None:
+    # theme_editors' only index is the UNIQUE(subject_id, theme_id) constraint
+    # from its creation (#42404), which leads with subject_id -- most engines
+    # can't use a composite index to serve a lookup filtered on its trailing
+    # column alone. Loading a theme's editor list filters on theme_id only,
+    # so that's a table scan on every load without a dedicated index.
+    create_index(TABLE_NAME, INDEX_NAME, ["theme_id"])
+
+
+def downgrade() -> None:
+    drop_index(TABLE_NAME, INDEX_NAME)

Review Comment:
   Added short docstrings to `upgrade`/`downgrade`.



##########
superset/security/manager.py:
##########
@@ -201,6 +201,26 @@ def get_extra_editors_by_pk(
     }
 
 
+def attach_extra_editors(result: dict[str, Any], resource: Model) -> None:
+    """
+    Attach ``extra_editors`` to a single-object API response, if configured.
+    """
+    if has_app_context() and current_app.config.get("EXTRA_EDITORS_RESOLVER"):
+        result["extra_editors"] = get_extra_editor_subject_ids(resource)
+
+
+def attach_extra_editors_to_rows(data: dict[str, Any], model_cls: type[Model]) 
-> None:
+    """
+    Attach ``extra_editors`` to each row of a list API response, matching
+    ``attach_extra_editors``'s single-object behavior.
+    """
+    ids = data.get("ids", [])
+    extra_editors_by_id = get_extra_editors_by_pk(model_cls, ids)
+    for row, row_id in zip(data.get("result", []), ids, strict=False):
+        if row_id in extra_editors_by_id:
+            row["extra_editors"] = extra_editors_by_id[row_id]

Review Comment:
   ids and result both come from the same lst in FAB's get_list, so they're 
already positionally aligned. The re-query only builds the pk-keyed dict, not 
the zip.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to