From a875c4855b79a8c5586f1708f31d877cebc0584d Mon Sep 17 00:00:00 2001 From: Vasile Popescu Date: Fri, 13 Feb 2026 14:29:15 +0100 Subject: [PATCH] Add support for filtering on commented_by current user --- front_end/src/app/(main)/questions/helpers/filters.ts | 7 +++++++ front_end/src/components/tournament_filters.tsx | 7 +++++++ posts/serializers.py | 1 + posts/services/feed.py | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/front_end/src/app/(main)/questions/helpers/filters.ts b/front_end/src/app/(main)/questions/helpers/filters.ts index 4333345e33..9e83d793bb 100644 --- a/front_end/src/app/(main)/questions/helpers/filters.ts +++ b/front_end/src/app/(main)/questions/helpers/filters.ts @@ -350,6 +350,13 @@ export function getFilterSectionParticipation({ active: !!params.get(POST_UPVOTED_BY_FILTER), isPersisted: true, }, + { + id: POST_COMMENTED_BY_FILTER, + label: t("commented"), + value: user.id.toString(), + active: !!params.get(POST_COMMENTED_BY_FILTER), + isPersisted: true, + }, ], }; } diff --git a/front_end/src/components/tournament_filters.tsx b/front_end/src/components/tournament_filters.tsx index c22cfbf188..3203163b92 100644 --- a/front_end/src/components/tournament_filters.tsx +++ b/front_end/src/components/tournament_filters.tsx @@ -14,6 +14,7 @@ import { } from "@/components/popover_filter/types"; import PostsFilters from "@/components/posts_filters"; import { + POST_COMMENTED_BY_FILTER, POST_FOLLOWING_FILTER, POST_FORECASTER_ID_FILTER, POST_NOT_FORECASTER_ID_FILTER, @@ -225,6 +226,12 @@ function getTournamentPostsFilters({ value: "true", active: !!params.get(POST_FOLLOWING_FILTER), }, + { + id: POST_COMMENTED_BY_FILTER, + label: t("commented"), + value: user.id.toString(), + active: !!params.get(POST_COMMENTED_BY_FILTER), + }, ], }); } diff --git a/posts/serializers.py b/posts/serializers.py index b617a18eb0..bb5b5015a2 100644 --- a/posts/serializers.py +++ b/posts/serializers.py @@ -226,6 +226,7 @@ class Access(models.TextChoices): not_forecaster_id = serializers.IntegerField(required=False, allow_null=True) similar_to_post_id = serializers.IntegerField(required=False, allow_null=True) upvoted_by = serializers.IntegerField(required=False, allow_null=True) + commented_by = serializers.IntegerField(required=False, allow_null=True) search = serializers.CharField(required=False, allow_null=True) for_main_feed = serializers.BooleanField(required=False, allow_null=True) diff --git a/posts/services/feed.py b/posts/services/feed.py index 683f415fb1..3abe6e11eb 100644 --- a/posts/services/feed.py +++ b/posts/services/feed.py @@ -48,6 +48,7 @@ def get_posts_feed( show_on_homepage: bool = None, following: bool = None, upvoted_by: int = None, + commented_by: int = None, **kwargs, ) -> Post.objects: """ @@ -217,6 +218,9 @@ def get_posts_feed( votes__direction=Vote.VoteDirection.UP, ) + if commented_by: + qs = qs.filter(comments__author_id=commented_by).distinct() + # Followed posts if user and user.is_authenticated and following: qs = qs.annotate_user_is_following(user=user).filter(user_is_following=True)