fix(blog): filter profile activity results
Some checks failed
Backend CI/CD / test (push) Has been cancelled
Backend CI/CD / deploy (push) Has been cancelled

This commit is contained in:
2026-06-12 11:20:55 +03:30
parent 029f0c7b8d
commit 36aef98986

View File

@@ -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) @blog_router.get("/me/activity", response=BlogProfileActivitySchema, auth=jwt_auth)
def my_blog_activity(request): def my_blog_activity(request):
comments = ( 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") .select_related("author", "post")
.order_by("-created_at")[:20] .order_by("-created_at")[:20]
) )
return BlogProfileActivitySchema( return {
liked_posts=list(_published_queryset().filter(likes__user=request.auth)[:20]), "liked_posts": list(_published_queryset().filter(likes__user=request.auth)[:20]),
saved_posts=list(_published_queryset().filter(saves__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]), "comments": [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]), "replies": [comment for comment in comments if comment.parent_id is not None],
) }
@blog_router.get("/banners", response=List[BlogBannerSchema]) @blog_router.get("/banners", response=List[BlogBannerSchema])