LisaHusband commented on code in PR #34694: URL: https://github.com/apache/superset/pull/34694#discussion_r2304088800
########## superset/views/datasource/utils.py: ########## @@ -44,6 +44,35 @@ def get_limit_clause(page: Optional[int], per_page: Optional[int]) -> dict[str, return {"row_offset": offset, "row_limit": limit} +def replace_verbose_with_column( + filters: list[dict[str, Any]], + columns: Iterable[Any], + verbose_attr: str = "verbose_name", + column_attr: str = "column_name", +) -> None: + """ + Replace filter 'col' values that match column verbose_name with the column_name. + Operates in-place on the filters list. + + Args: + filters: List of filter dicts, each must have 'col' key. + columns: Iterable of column objects with verbose_name and column_name. + verbose_attr: Attribute name for verbose/label. + column_attr: Attribute name for actual column name. + """ + for f in filters: + match = next( + ( + getattr(col, column_attr) + for col in columns + if getattr(col, verbose_attr) == f["col"] + ), + None, + ) + if match: + f["col"] = match + + Review Comment: of course -- 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: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org