codeant-ai-for-open-source[bot] commented on code in PR #45991: URL: https://github.com/apache/superset/pull/45991#discussion_r4460023802
########## superset/dashboards/export_info.py: ########## @@ -0,0 +1,101 @@ +# 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. +"""Describe a dashboard export (title, permalink, filters, chart links).""" + +from __future__ import annotations + +from typing import Any + +from superset_core.exports.types import AppliedFilter, DashboardExportInfo + +from superset import security_manager +from superset.commands.dashboard.exceptions import DashboardNotFoundError +from superset.commands.dashboard.permalink.create import ( + CreateDashboardPermalinkCommand, +) +from superset.daos.dashboard import DashboardDAO +from superset.dashboards.excel_export.layout import get_charts_in_layout_order +from superset.utils.urls import get_url_path + + +def _is_empty(value: Any) -> bool: + return value is None or value == [] or value == "" + + +def _display_value(filter_state: dict[str, Any]) -> str: + label = filter_state.get("label") + if isinstance(label, str) and label: + return label + value = filter_state["value"] + if isinstance(value, list): + return ", ".join(str(item) for item in value) + return str(value) + + +def describe_dashboard_export( + dashboard_id: int, active_data_mask: dict[str, Any] +) -> DashboardExportInfo: + """ + Describe a dashboard export for an extension's "About" tab. + + Raises DashboardNotFoundError for a missing dashboard and + SupersetSecurityException when the current user cannot access it. + """ + dashboard = DashboardDAO.find_by_id(dashboard_id) + if dashboard is None: + raise DashboardNotFoundError(str(dashboard_id)) + security_manager.raise_for_access(dashboard=dashboard) + + key = CreateDashboardPermalinkCommand( + dashboard_id=str(dashboard_id), state={"dataMask": active_data_mask} + ).run() + permalink_url = get_url_path( + "Superset.dashboard_permalink", user_friendly=True, key=key + ) + + charts = get_charts_in_layout_order(dashboard) + native_names = { + config["id"]: config["name"] + for config in dashboard.params_dict.get("native_filter_configuration", []) + if "id" in config and "name" in config + } + + applied_filters: list[AppliedFilter] = [] + for filter_id in sorted(active_data_mask): Review Comment: **Suggestion:** `chart_result` applies a filter's saved `defaultDataMask` when its ID is absent here, but this loop omits it, so export metadata contradicts the exported data. **Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Incomplete implementation` [](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9009e1c09295459eb3085a7d58732e1a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=9009e1c09295459eb3085a7d58732e1a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) <details> <summary><b>Prompt for AI Agent ๐ค </b></summary> ```mdx This is a comment left during a code review. **Path:** superset/dashboards/export_info.py **Line:** 78:78 **Comment:** *Incomplete Implementation: `chart_result` applies a filter's saved `defaultDataMask` when its ID is absent here, but this loop omits it, so export metadata contradicts the exported data. Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45991&comment_hash=44e2594575dd01a9904d7a36aa5ca02717abed41e571b17903eb69c79fef9e49&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45991&comment_hash=44e2594575dd01a9904d7a36aa5ca02717abed41e571b17903eb69c79fef9e49&reaction=dislike'>๐</a> -- 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]
