fix(blog): filter profile activity results
This commit is contained in:
@@ -507,16 +507,23 @@ def delete_post_asset(request, post_id: int, asset_id: int):
|
||||
@blog_router.get("/me/activity", response=BlogProfileActivitySchema, auth=jwt_auth)
|
||||
def my_blog_activity(request):
|
||||
comments = (
|
||||
Comment.objects.filter(author=request.auth)
|
||||
Comment.objects.filter(
|
||||
author=request.auth,
|
||||
is_approved=True,
|
||||
is_hidden=False,
|
||||
is_deleted=False,
|
||||
post__status=Post.StatusChoices.PUBLISHED,
|
||||
post__is_deleted=False,
|
||||
)
|
||||
.select_related("author", "post")
|
||||
.order_by("-created_at")[:20]
|
||||
)
|
||||
return BlogProfileActivitySchema(
|
||||
liked_posts=list(_published_queryset().filter(likes__user=request.auth)[:20]),
|
||||
saved_posts=list(_published_queryset().filter(saves__user=request.auth)[:20]),
|
||||
comments=list([comment for comment in comments if comment.parent_id is None]),
|
||||
replies=list([comment for comment in comments if comment.parent_id is not None]),
|
||||
)
|
||||
return {
|
||||
"liked_posts": list(_published_queryset().filter(likes__user=request.auth)[:20]),
|
||||
"saved_posts": list(_published_queryset().filter(saves__user=request.auth)[:20]),
|
||||
"comments": [comment for comment in comments if comment.parent_id is None],
|
||||
"replies": [comment for comment in comments if comment.parent_id is not None],
|
||||
}
|
||||
|
||||
|
||||
@blog_router.get("/banners", response=List[BlogBannerSchema])
|
||||
|
||||
Reference in New Issue
Block a user