fabianmenges commented on a change in pull request #3518: Full Annotation 
Framework
URL: 
https://github.com/apache/incubator-superset/pull/3518#discussion_r157349873
 
 

 ##########
 File path: superset/views/core.py
 ##########
 @@ -1644,9 +1701,51 @@ def created_dashboards(self, user_id):
 
     @api
     @has_access_api
+    @expose('/user_slices', methods=['GET'])
+    @expose('/user_slices/<user_id>/', methods=['GET'])
+    def user_slices(self, user_id=None):
+        """List of slices a user created, or faved"""
+        if not user_id:
+            user_id = g.user.id
+        Slice = models.Slice  # noqa
+        FavStar = models.FavStar # noqa
+        qry = (
+            db.session.query(Slice,
+                             FavStar.dttm).join(
+                models.FavStar,
+                sqla.and_(
+                    models.FavStar.user_id == int(user_id),
+                    models.FavStar.class_name == 'slice',
+                    models.Slice.id == models.FavStar.obj_id,
+                ),
+                isouter=True).filter(
+                sqla.or_(
+                    Slice.created_by_fk == user_id,
+                    Slice.changed_by_fk == user_id,
+                    FavStar.user_id == user_id,
+                ),
+            )
+            .order_by(Slice.slice_name.asc())
+        )
+        payload = [{
 
 Review comment:
   I'm just following the way its done in the other endpoints:
   
https://github.com/apache/incubator-superset/blob/master/superset/views/core.py#L1698
   
https://github.com/apache/incubator-superset/blob/master/superset/views/core.py#L1667
   
   I'm happy to refactor this, but would prefer doing that in a different PR. 
I'm also not sure what you mean with using `Slice.data`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to