You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/04/07 07:32:30 UTC

[GitHub] [superset] villebro commented on a diff in pull request #19434: feat: deprecate old API and create new API for dashes created by me

villebro commented on code in PR #19434:
URL: https://github.com/apache/superset/pull/19434#discussion_r844809845


##########
superset/views/core.py:
##########
@@ -1587,16 +1587,24 @@ def fave_dashboards(self, user_id: int) -> FlaskResponse:
     @event_logger.log_this
     @expose("/created_dashboards/<int:user_id>/", methods=["GET"])
     def created_dashboards(self, user_id: int) -> FlaskResponse:
+        logging.warning(
+            "%s.select_star "
+            "This API endpoint is deprecated and will be removed in version 3.0.0",
+            self.__class__.__name__,
+        )

Review Comment:
   nit:
   ```suggestion
           logging.warning(
               "%s.created_dashboards "
               "This API endpoint is deprecated and will be removed in version 3.0.0",
               self.__class__.__name__,
           )
   ```



##########
superset/dashboards/api.py:
##########
@@ -455,6 +453,43 @@ def get_charts(self, id_or_slug: str) -> Response:
         except DashboardNotFoundError:
             return self.response_404()
 
+    @expose("/created_by_me/", methods=["GET"])
+    @protect()
+    @safe
+    @statsd_metrics
+    @event_logger.log_this_with_context(
+        action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get",
+        log_to_statsd=False,
+    )
+    def created_by_me(self) -> Response:
+        """Gets all dashboards created by the current user
+        ---
+        get:
+          description: >-
+            Gets all dashboards created by the current user
+          responses:
+            200:
+              description: Dashboard
+              content:
+                application/json:
+                  schema:
+                    type: object
+                    properties:
+                      result:
+                        type: array
+                        items:
+                          $ref: '#/components/schemas/DashboardCreatedByMeResponseSchema'
+            401:
+              $ref: '#/components/responses/401'
+            403:
+              $ref: '#/components/responses/403'
+            404:
+              $ref: '#/components/responses/404'
+        """
+        dashboards = DashboardDAO.get_dashboards_created_by(g.user.id)

Review Comment:
   I agree with @eschutho , leveraging the existing GET with a custom filter does seem like the cleanest solution.



-- 
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-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org