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/06 18:27:54 UTC

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

craig-rueda commented on code in PR #19434:
URL: https://github.com/apache/superset/pull/19434#discussion_r844260179


##########
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:
   One nit here - Ideally, we wouldn't access DAO methods statically as one of the benefits of DAOs is that they should improve composability of apps. i.e. you might want to implement several variations of a given DAO (one might use SQLA, whereas the other just uses SQL.exec, for example). Static references force us to find all references and update inline and don't allow for composability without import aliasing, etc.
   
   I totally get that this is just a simple use case, and adding a command here (one more indirection layer) seems a bit overkill.



-- 
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