Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions front_end/messages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@
"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>",
"authored": "Vytvořeno",
"upvoted": "Kladně hodnoceno",
"commented": "Komentováno",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Duplicate "commented" key overwrites the earlier translation.

Line 394 introduces a second "commented" entry (the file already defines "commented": "komentovali" around Line 114). JSON will keep the last value, which can silently change other UI strings. Please use a distinct key for the filter label (e.g., searchOptionCommented) and update the UI to reference it.

🔧 Suggested key rename
-  "commented": "Komentováno",
+  "searchOptionCommented": "Komentováno",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"commented": "Komentováno",
"searchOptionCommented": "Komentováno",
🤖 Prompt for AI Agents
In `@front_end/messages/cs.json` at line 394, The JSON contains a duplicate
"commented" key that overwrites the earlier translation ("komentovali"); rename
the new entry to a unique key such as "searchOptionCommented" (or another clear
name) and update any UI code that references the filter label to use
"searchOptionCommented" instead of "commented"; also verify the original
"commented" key (value "komentovali") remains unchanged and update any tests or
components that expected the previous overwritten value to use the new distinct
key.

"moderating": "Moderování",
"visibility": "Viditelnost",
"public": "Veřejné",
Expand Down
1 change: 1 addition & 0 deletions front_end/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@
"includeBotsInAggregatesExplanation": "When enabled, bot forecasts will be included in aggregate calculations for this question and will affect scoring. Otherwise, they will affect neither.",
"authored": "Authored",
"upvoted": "Upvoted",
"commented": "Commented",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Avoid duplicate “commented” key collisions.
Line 549 redefines an existing key already present at Line 214. In most JSON loaders, the later value overrides the earlier one, so existing UI strings may change casing unexpectedly. Please use a distinct key for the filter label (e.g., commentedFilter) and update references accordingly.

🔧 Suggested fix
-  "commented": "Commented",
+  "commentedFilter": "Commented",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"commented": "Commented",
"commentedFilter": "Commented",
🤖 Prompt for AI Agents
In `@front_end/messages/en.json` at line 549, The JSON contains a duplicate
"commented" key which overrides the earlier entry; change this duplicate key to
a distinct name such as "commentedFilter" and update any code/UI references that
read the filter label to use "commentedFilter" (search for usages of the
"commented" key that relate to filter labels and replace them to avoid key
collision); ensure the original "commented" key remains unchanged so
casing/values elsewhere are preserved.

"moderating": "Moderating",
"moderatedBy": "Moderated by",
"visibility": "Visibility",
Expand Down
1 change: 1 addition & 0 deletions front_end/messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
"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>",
"authored": "Autoría",
"upvoted": "Votado positivamente",
"commented": "Comentado",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

fd -e json . front_end/messages/ | head -20

Repository: Metaculus/metaculus

Length of output: 260


🏁 Script executed:

grep -n '"commented"' front_end/messages/es.json

Repository: Metaculus/metaculus

Length of output: 126


🏁 Script executed:

sed -n '110,120p' front_end/messages/es.json

Repository: Metaculus/metaculus

Length of output: 574


🏁 Script executed:

sed -n '398,405p' front_end/messages/es.json

Repository: Metaculus/metaculus

Length of output: 454


🏁 Script executed:

grep -E '"search.*?": "' front_end/messages/es.json | head -10

Repository: Metaculus/metaculus

Length of output: 472


🏁 Script executed:

sed -n '395,410p' front_end/messages/es.json

Repository: Metaculus/metaculus

Length of output: 927


🏁 Script executed:

grep -n '"authored"\|"upvoted"\|"moderating"' front_end/messages/es.json

Repository: Metaculus/metaculus

Length of output: 165


🏁 Script executed:

sed -n '110,125p' front_end/messages/es.json | cat -n

Repository: Metaculus/metaculus

Length of output: 915


🏁 Script executed:

# Check if "commented" key is used elsewhere in the codebase
rg '"commented"' front_end/ --type json --type js --type ts -c

Repository: Metaculus/metaculus

Length of output: 397


🏁 Script executed:

# Verify the exact structure - is this really a JSON object with duplicate keys?
head -5 front_end/messages/es.json && echo "..." && tail -5 front_end/messages/es.json

Repository: Metaculus/metaculus

Length of output: 414


🏁 Script executed:

# Check how "commented" is used in the codebase
rg -B2 -A2 '"commented"' front_end/src/components/tournament_filters.tsx

Repository: Metaculus/metaculus

Length of output: 240


🏁 Script executed:

rg -B2 -A2 '"commented"' front_end/src/components/comment_feed/comment.tsx

Repository: Metaculus/metaculus

Length of output: 254


🏁 Script executed:

rg -B2 -A2 '"commented"' front_end/src/app/\(main\)/questions/helpers/filters.ts

Repository: Metaculus/metaculus

Length of output: 230


🏁 Script executed:

# Check the structure of line 401-402 context more clearly with broader range
sed -n '395,415p' front_end/messages/es.json | nl -v 395

Repository: Metaculus/metaculus

Length of output: 105


🏁 Script executed:

sed -n '395,415p' front_end/messages/es.json

Repository: Metaculus/metaculus

Length of output: 1275


🏁 Script executed:

# Check all locale files for duplicate "commented" key
for f in front_end/messages/*.json; do
  count=$(grep -c '"commented"' "$f")
  echo "$(basename $f): $count occurrences"
  grep -n '"commented"' "$f"
  echo
done

Repository: Metaculus/metaculus

Length of output: 600


Duplicate JSON key "commented" breaks existing translations across all locale files.

Both line 114 and line 401 define the same key "commented", causing the second occurrence to override the first at parse time. This affects all seven locale files identically:

  • en.json: lines 214 and 549
  • es.json: lines 114 and 401
  • cs.json: lines 114 and 394
  • pt.json: lines 132 and 426
  • zh-TW.json: lines 150 and 454
  • zh.json: lines 112 and 398

Line 114's lowercase values ("comentado", "commented", etc.) are used for activity feed display (e.g., "replied", "commented" actions). Line 401's capitalized values are filter labels. The second occurrence silently overwrites the first, breaking activity notifications.

Use a distinct key for the filter option, following the naming convention: "searchOptionCommented".

🤖 Prompt for AI Agents
In `@front_end/messages/es.json` at line 401, Duplicate JSON key "commented" is
defined twice causing the filter label to overwrite the activity-feed value;
change the filter occurrence (the capitalized label currently using the second
"commented" key) to a distinct key name following convention, e.g.,
"searchOptionCommented", update the value to the capitalized label and mirror
the same key rename across all locale files (en.json, es.json, cs.json, pt.json,
zh-TW.json, zh.json) so the activity-feed "commented" key remains the lowercase
activity string and the new "searchOptionCommented" key is used for the filter
label.

"moderating": "Moderando",
"visibility": "Visibilidad",
"public": "Público",
Expand Down
1 change: 1 addition & 0 deletions front_end/messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@
"includeBotsTooltip": "Para esta pergunta, previsões de bots contribuem para a Previsão da Comunidade. <link>Saiba mais sobre Benchmarking de IA</link>",
"authored": "Criado",
"upvoted": "Curtido",
"commented": "Comentado",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Duplicate "commented" key overwrites the earlier translation.

This file already defines "commented": "comentou" (around Line 132). Adding a second "commented" at Line 426 will override the earlier value. Please use a distinct key for the filter label (e.g., searchOptionCommented) and update the UI to reference it.

🔧 Suggested key rename
-  "commented": "Comentado",
+  "searchOptionCommented": "Comentado",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"commented": "Comentado",
"searchOptionCommented": "Comentado",
🤖 Prompt for AI Agents
In `@front_end/messages/pt.json` at line 426, The duplicate JSON key "commented"
overwrites the earlier translation; replace the second occurrence with a
distinct key (e.g., "searchOptionCommented") and update any UI code that uses
the filter label to reference "searchOptionCommented" instead of "commented";
ensure you keep the original "commented": "comentou" entry intact, add
"searchOptionCommented": "Comentado" (or appropriate translation) where the
filter label is needed, and search for usages of the "commented" key in
components to update references to the new key (e.g., in filter components or
i18n lookup calls).

"moderating": "Moderando",
"moderatedBy": "Moderado por",
"visibility": "Visibilidade",
Expand Down
1 change: 1 addition & 0 deletions front_end/messages/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@
"includeBotsTooltip": "對於此問題,機器人預測構成社區預測的一部分。<link>瞭解更多關於 AI 基準測試</link>",
"authored": "著作",
"upvoted": "點贊",
"commented": "已評論",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Duplicate “commented” key overrides existing translation.
Line 454 repeats a key already defined at Line 150, which will override the earlier value in most JSON parsers. Please use a distinct key for the filter label (e.g., commentedFilter) and update references accordingly.

🔧 Suggested fix
-  "commented": "已評論",
+  "commentedFilter": "已評論",
🤖 Prompt for AI Agents
In `@front_end/messages/zh-TW.json` at line 454, The JSON file contains a
duplicate key "commented" (second occurrence at the reviewed diff) that will
override the earlier translation; rename this duplicate key to a distinct
identifier such as "commentedFilter" and update all places that reference this
translation key (e.g., UI components or i18n lookups that currently use
"commented") to use the new key name; ensure the new key's value remains "已評論"
(or an appropriate filter label) and run the i18n build/validation to confirm no
other duplicate keys remain.

"moderating": "管理中",
"moderatedBy": "由...管理",
"visibility": "可見性",
Expand Down
1 change: 1 addition & 0 deletions front_end/messages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
"includeBots": "包括機器人",
"includeBotsTooltip": "對於這個問題,機器人預測有助於社群預測。<link>了解更多有關 AI 基準測試的資訊</link>",
"upvoted": "點贊",
"commented": "已評論",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Duplicate “commented” key overrides existing translation.
Line 398 repeats a key already defined at Line 112, which will override the earlier value in most JSON parsers. Please use a distinct key for the filter label (e.g., commentedFilter) and update references accordingly.

🔧 Suggested fix
-  "commented": "已評論",
+  "commentedFilter": "已評論",
🤖 Prompt for AI Agents
In `@front_end/messages/zh.json` at line 398, The translation file contains a
duplicate key "commented" which overrides the earlier entry; rename the filter
label key to a distinct name (for example "commentedFilter") in the JSON and
update all code references that read the translation (e.g., any usages of the
"commented" key in UI components, i18n lookup calls, or filter label renderers)
to use the new key "commentedFilter" so both translations coexist without
conflict.

"moderating": "管理中",
"visibility": "可見性",
"public": "公開",
Expand Down
7 changes: 7 additions & 0 deletions front_end/src/app/(main)/questions/helpers/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
],
};
}
Expand Down
7 changes: 7 additions & 0 deletions front_end/src/components/tournament_filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
},
],
});
}
Expand Down
1 change: 1 addition & 0 deletions posts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions posts/services/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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)
Expand Down