bito-code-review[bot] commented on code in PR #42490:
URL: https://github.com/apache/superset/pull/42490#discussion_r3769987579
##########
superset/mcp_service/chart/tool/update_chart_preview.py:
##########
@@ -102,6 +103,49 @@ def _get_previous_form_data(form_data_key: str) ->
dict[str, Any] | None:
return None
+def _preserve_previous_adhoc_filters(
+ new_form_data: dict[str, Any], previous_form_data: dict[str, Any]
+) -> None:
+ """Preserve cached filters without dropping mapper-generated bindings."""
+ previous_filters = previous_form_data.get("adhoc_filters")
+ if not isinstance(previous_filters, list) or not previous_filters:
+ return
+
+ generated_filters = new_form_data.get("adhoc_filters", [])
+ previous_binding =
previous_form_data.get(MCP_DASHBOARD_TIME_FILTER_SUBJECT)
+ new_binding = new_form_data.get(MCP_DASHBOARD_TIME_FILTER_SUBJECT)
+ merged_filters = [
+ filter_
+ for filter_ in previous_filters
+ if not (
+ previous_binding
+ and previous_binding != new_binding
Review Comment:
<!-- Bito Reply -->
The reviewer's suggestion to add a `new_binding is not None` guard is not
necessary in this context. The current implementation correctly handles the
removal of stale time subjects when a new binding is absent, as the filter
being removed is specifically generated by the mapper rather than an arbitrary
user filter. The existing test suite, specifically the tests covering the
removal of cached temporal filters without a new binding and the preservation
of unrelated filters during rebinding, confirms that the current logic
maintains the intended contract.
--
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]