Skip to content

Commit a875c48

Browse files
committed
Add support for filtering on commented_by current user
1 parent 1f8cbce commit a875c48

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

front_end/src/app/(main)/questions/helpers/filters.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ export function getFilterSectionParticipation({
350350
active: !!params.get(POST_UPVOTED_BY_FILTER),
351351
isPersisted: true,
352352
},
353+
{
354+
id: POST_COMMENTED_BY_FILTER,
355+
label: t("commented"),
356+
value: user.id.toString(),
357+
active: !!params.get(POST_COMMENTED_BY_FILTER),
358+
isPersisted: true,
359+
},
353360
],
354361
};
355362
}

front_end/src/components/tournament_filters.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from "@/components/popover_filter/types";
1515
import PostsFilters from "@/components/posts_filters";
1616
import {
17+
POST_COMMENTED_BY_FILTER,
1718
POST_FOLLOWING_FILTER,
1819
POST_FORECASTER_ID_FILTER,
1920
POST_NOT_FORECASTER_ID_FILTER,
@@ -225,6 +226,12 @@ function getTournamentPostsFilters({
225226
value: "true",
226227
active: !!params.get(POST_FOLLOWING_FILTER),
227228
},
229+
{
230+
id: POST_COMMENTED_BY_FILTER,
231+
label: t("commented"),
232+
value: user.id.toString(),
233+
active: !!params.get(POST_COMMENTED_BY_FILTER),
234+
},
228235
],
229236
});
230237
}

posts/serializers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class Access(models.TextChoices):
226226
not_forecaster_id = serializers.IntegerField(required=False, allow_null=True)
227227
similar_to_post_id = serializers.IntegerField(required=False, allow_null=True)
228228
upvoted_by = serializers.IntegerField(required=False, allow_null=True)
229+
commented_by = serializers.IntegerField(required=False, allow_null=True)
229230

230231
search = serializers.CharField(required=False, allow_null=True)
231232
for_main_feed = serializers.BooleanField(required=False, allow_null=True)

posts/services/feed.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def get_posts_feed(
4848
show_on_homepage: bool = None,
4949
following: bool = None,
5050
upvoted_by: int = None,
51+
commented_by: int = None,
5152
**kwargs,
5253
) -> Post.objects:
5354
"""
@@ -217,6 +218,9 @@ def get_posts_feed(
217218
votes__direction=Vote.VoteDirection.UP,
218219
)
219220

221+
if commented_by:
222+
qs = qs.filter(comments__author_id=commented_by).distinct()
223+
220224
# Followed posts
221225
if user and user.is_authenticated and following:
222226
qs = qs.annotate_user_is_following(user=user).filter(user_is_following=True)

0 commit comments

Comments
 (0)