This is an automated email from the ASF dual-hosted git repository. suddjian pushed a commit to branch dashboard-bootstrap in repository https://gitbox.apache.org/repos/asf/superset.git
commit eecefc5a698704e3e1a5bf88da8ef06e3fef261c Author: David Aaron Suddjian <[email protected]> AuthorDate: Tue Jan 19 15:18:40 2021 -0800 feat(dashboard): get endpoint for a dashboard's charts --- superset/dashboards/api.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ superset/dashboards/dao.py | 6 ++++++ 2 files changed, 52 insertions(+) diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py index 61b56b1..6366688 100644 --- a/superset/dashboards/api.py +++ b/superset/dashboards/api.py @@ -210,6 +210,52 @@ class DashboardRestApi(BaseSupersetModelRestApi): self.include_route_methods = self.include_route_methods | {"thumbnail"} super().__init__() + @expose("/<pk>/charts/", methods=["GET"]) + @protect() + @safe + @statsd_metrics + @event_logger.log_this_with_context( + action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get_charts", + log_to_statsd=False, + ) + def get_charts(self, pk: int) -> Response: + """Change this later + --- + post: + description: >- + Create a new Dashboard. + requestBody: + description: Dashboard schema + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/{{self.__class__.__name__}}.post' + responses: + 201: + description: Dashboard added + content: + application/json: + schema: + type: object + properties: + id: + type: number + result: + $ref: '#/components/schemas/{{self.__class__.__name__}}.post' + 302: + description: Redirects to the current digest + 400: + $ref: '#/components/responses/400' + 401: + $ref: '#/components/responses/401' + 404: + $ref: '#/components/responses/404' + 500: + $ref: '#/components/responses/500' + """ + DashboardDAO.get_charts_for_dashboard(pk) + @expose("/", methods=["POST"]) @protect() @safe diff --git a/superset/dashboards/dao.py b/superset/dashboards/dao.py index 65bdc69..aae75c8 100644 --- a/superset/dashboards/dao.py +++ b/superset/dashboards/dao.py @@ -23,6 +23,7 @@ from sqlalchemy.exc import SQLAlchemyError from superset.dao.base import BaseDAO from superset.dashboards.filters import DashboardFilter from superset.extensions import db +from superset.models.slice import Slice from superset.models.core import FavStar, FavStarClassName from superset.models.dashboard import Dashboard from superset.models.slice import Slice @@ -36,6 +37,11 @@ class DashboardDAO(BaseDAO): base_filter = DashboardFilter @staticmethod + def get_charts_for_dashboard(dashboard_id: int) -> List[Slice]: + query = db.session.query(Dashboard).filter(Dashboard.id == dashboard_id) + logger.info(query.__dict__) + + @staticmethod def validate_slug_uniqueness(slug: str) -> bool: if not slug: return True
