sadpandajoe commented on code in PR #44358:
URL: https://github.com/apache/superset/pull/44358#discussion_r4141054668


##########
superset/commands/chart/utils.py:
##########
@@ -81,3 +83,23 @@ def validate_query_context_datasource(
 
     if not ids_match or not types_match:
         exceptions.append(ChartQueryContextDatasourceMismatchValidationError())
+
+
+def touch_dashboards(dashboards: list[Any] | None) -> None:
+    """
+    Touch the audit metadata (changed_on and changed_by) for the given 
dashboards.
+
+    When a chart's links to dashboards change during chart creation or update
+    (dashboards added to or removed from the chart), this ensures the 
dashboards'
+    last modified timestamps reflect the change (issue #44305).
+
+    :param dashboards: list of Dashboard models to touch.
+    """
+    if not dashboards:
+        return
+    now = datetime.now()
+    user = getattr(g, "user", None)
+    for dashboard in dashboards:
+        dashboard.changed_on = now
+        if user is not None:

Review Comment:
   In no-user contexts, this update can erase a dashboard's existing 
modified-by value: changing `changed_on` triggers `changed_by_fk`'s `onupdate`, 
which resolves to `None` when `g.user` is absent, while this helper leaves it 
unspecified. Could we preserve the prior value explicitly and cover the 
persisted-model case?



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