Conversation
📝 WalkthroughWalkthroughThis PR introduces a "commented" filter feature for the question feed. It adds translation entries in six language files, extends frontend filter components to include a commented-by filter option, and adds backend support in the serializer and feed service to filter posts by user comments. Changes
Sequence DiagramsequenceDiagram
actor User
participant Frontend
participant API/Serializer
participant FeedService
participant Database
User->>Frontend: Select "commented" filter
Frontend->>Frontend: Encode POST_COMMENTED_BY_FILTER in URL params
Frontend->>API/Serializer: POST request with commented_by user_id
API/Serializer->>API/Serializer: Validate commented_by field
API/Serializer->>FeedService: Call get_posts_feed(commented_by=user_id)
FeedService->>FeedService: Filter queryset by comments__author_id
FeedService->>FeedService: Apply distinct() to avoid duplicates
FeedService->>Database: Query posts with matching comments
Database-->>FeedService: Return filtered results
FeedService-->>API/Serializer: Return post list
API/Serializer-->>Frontend: Return serialized posts
Frontend-->>User: Display filtered questions
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 Preview EnvironmentYour preview environment is ready!
Details
ℹ️ Preview Environment InfoIsolation:
Limitations:
Cleanup:
|
|
@coderabbitai review again |
|
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Fix all issues with AI agents
In `@front_end/messages/cs.json`:
- 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.
In `@front_end/messages/en.json`:
- 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.
In `@front_end/messages/es.json`:
- 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.
In `@front_end/messages/pt.json`:
- 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).
In `@front_end/messages/zh-TW.json`:
- 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.
In `@front_end/messages/zh.json`:
- 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.
🧹 Nitpick comments (1)
posts/services/feed.py (1)
51-51: Nit: PEP 484 discourages implicitOptional.Static analysis (RUF013) flags
commented_by: int = None— the modern annotation isint | None = None. This is a pre-existing pattern across all parameters in this function, so no need to fix it in this PR alone.
| "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", |
There was a problem hiding this comment.
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.
| "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.
| "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", |
There was a problem hiding this comment.
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.
| "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.
| "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", |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
fd -e json . front_end/messages/ | head -20Repository: Metaculus/metaculus
Length of output: 260
🏁 Script executed:
grep -n '"commented"' front_end/messages/es.jsonRepository: Metaculus/metaculus
Length of output: 126
🏁 Script executed:
sed -n '110,120p' front_end/messages/es.jsonRepository: Metaculus/metaculus
Length of output: 574
🏁 Script executed:
sed -n '398,405p' front_end/messages/es.jsonRepository: Metaculus/metaculus
Length of output: 454
🏁 Script executed:
grep -E '"search.*?": "' front_end/messages/es.json | head -10Repository: Metaculus/metaculus
Length of output: 472
🏁 Script executed:
sed -n '395,410p' front_end/messages/es.jsonRepository: Metaculus/metaculus
Length of output: 927
🏁 Script executed:
grep -n '"authored"\|"upvoted"\|"moderating"' front_end/messages/es.jsonRepository: Metaculus/metaculus
Length of output: 165
🏁 Script executed:
sed -n '110,125p' front_end/messages/es.json | cat -nRepository: 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 -cRepository: 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.jsonRepository: 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.tsxRepository: Metaculus/metaculus
Length of output: 240
🏁 Script executed:
rg -B2 -A2 '"commented"' front_end/src/components/comment_feed/comment.tsxRepository: Metaculus/metaculus
Length of output: 254
🏁 Script executed:
rg -B2 -A2 '"commented"' front_end/src/app/\(main\)/questions/helpers/filters.tsRepository: 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 395Repository: Metaculus/metaculus
Length of output: 105
🏁 Script executed:
sed -n '395,415p' front_end/messages/es.jsonRepository: 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
doneRepository: 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 549es.json: lines 114 and 401cs.json: lines 114 and 394pt.json: lines 132 and 426zh-TW.json: lines 150 and 454zh.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.
| "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", |
There was a problem hiding this comment.
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.
| "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).
| "includeBotsTooltip": "對於此問題,機器人預測構成社區預測的一部分。<link>瞭解更多關於 AI 基準測試</link>", | ||
| "authored": "著作", | ||
| "upvoted": "點贊", | ||
| "commented": "已評論", |
There was a problem hiding this comment.
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.
| "includeBots": "包括機器人", | ||
| "includeBotsTooltip": "對於這個問題,機器人預測有助於社群預測。<link>了解更多有關 AI 基準測試的資訊</link>", | ||
| "upvoted": "點贊", | ||
| "commented": "已評論", |
There was a problem hiding this comment.
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.
Should close #2377
Summary by CodeRabbit
Release Notes