Skip to content

Commit edde2ac

Browse files
committed
Add support for filtering on commented_by current user
1 parent d7ad2b9 commit edde2ac

10 files changed

Lines changed: 25 additions & 0 deletions

File tree

front_end/messages/cs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@
391391
"includeBotsTooltip": "U této otázky přispívají předpovědi robotů k předpovědi komunity. <link>Další informace o srovnávání AI</link>",
392392
"authored": "Vytvořeno",
393393
"upvoted": "Kladně hodnoceno",
394+
"commented": "Komentováno",
394395
"moderating": "Moderování",
395396
"visibility": "Viditelnost",
396397
"public": "Veřejné",

front_end/messages/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@
546546
"includeBotsInAggregatesExplanation": "When enabled, bot forecasts will be included in aggregate calculations for this question and will affect scoring. Otherwise, they will affect neither.",
547547
"authored": "Authored",
548548
"upvoted": "Upvoted",
549+
"commented": "Commented",
549550
"moderating": "Moderating",
550551
"moderatedBy": "Moderated by",
551552
"visibility": "Visibility",

front_end/messages/es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@
398398
"includeBotsTooltip": "Para esta pregunta, los pronósticos de los bots contribuyen a la predicción de la comunidad. <link>Obtenga más información sobre la evaluación comparativa de IA</link>",
399399
"authored": "Autoría",
400400
"upvoted": "Votado positivamente",
401+
"commented": "Comentado",
401402
"moderating": "Moderando",
402403
"visibility": "Visibilidad",
403404
"public": "Público",

front_end/messages/pt.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@
423423
"includeBotsTooltip": "Para esta pergunta, previsões de bots contribuem para a Previsão da Comunidade. <link>Saiba mais sobre Benchmarking de IA</link>",
424424
"authored": "Criado",
425425
"upvoted": "Curtido",
426+
"commented": "Comentado",
426427
"moderating": "Moderando",
427428
"moderatedBy": "Moderado por",
428429
"visibility": "Visibilidade",

front_end/messages/zh-TW.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@
451451
"includeBotsTooltip": "對於此問題,機器人預測構成社區預測的一部分。<link>瞭解更多關於 AI 基準測試</link>",
452452
"authored": "著作",
453453
"upvoted": "點贊",
454+
"commented": "已評論",
454455
"moderating": "管理中",
455456
"moderatedBy": "由...管理",
456457
"visibility": "可見性",

front_end/messages/zh.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@
395395
"includeBots": "包括機器人",
396396
"includeBotsTooltip": "對於這個問題,機器人預測有助於社群預測。<link>了解更多有關 AI 基準測試的資訊</link>",
397397
"upvoted": "點贊",
398+
"commented": "已評論",
398399
"moderating": "管理中",
399400
"visibility": "可見性",
400401
"public": "公開",

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)