feat: top-level questions count on tournament pages + Tooltip variant consolidation and restyle#4877
feat: top-level questions count on tournament pages + Tooltip variant consolidation and restyle#4877aseckin wants to merge 4 commits into
Conversation
…rnament pages questions_count now counts question posts (group = 1, conditional = 1) instead of every question row. The old total is exposed as questions_count_including_subquestions and shown in a hover tooltip on the View Questions button when subquestions exist. Cache key bumped to v2 for the new value shape. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The light tooltip theme (blue border, gray-0 background, gray-800 text) was copy-pasted across 8 call sites via tooltipClassName. Move it into a variant="light" option on the shared Tooltip component; default "dark" variant is unchanged. Call-site overrides still win via tailwind-merge. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adopt the chamber-control tooltip styling as the shared base: rounded-md, px-4 py-3, text-base, shadow-lg, borderless. Default variant becomes bg-blue-800/text-gray-0 (navy bubble, white text) with inverted dark-mode colors; the light variant now carries its own border. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds structured question counts that include subquestions through model annotations, caching, serializers, and API responses; extends frontend types and i18n keys; conditionally shows a “including subquestions” light tooltip in the tournament navigation; introduces tooltip variant support and updates usages; adds tests validating both counts. ChangesSubquestions Count Display Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@projects/services/cache.py`:
- Line 7: The constant QUESTIONS_COUNT_CACHE_TIMEOUT is set to 1 * 3600 (one
hour) but the inline comment incorrectly says "3 hour"; update the comment to
accurately reflect one hour (e.g., change comment to "# 1 hour") next to
QUESTIONS_COUNT_CACHE_TIMEOUT so the code and comment match.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f87ab637-ef53-434f-acc3-9fb98f6430e3
📒 Files selected for processing (24)
front_end/messages/cs.jsonfront_end/messages/en.jsonfront_end/messages/es.jsonfront_end/messages/pt.jsonfront_end/messages/zh-TW.jsonfront_end/messages/zh.jsonfront_end/src/app/(main)/(leaderboards)/leaderboard/components/aggregation_rank_tooltip.tsxfront_end/src/app/(main)/(leaderboards)/leaderboard/components/excluded_entry_tooltop.tsxfront_end/src/app/(main)/(leaderboards)/leaderboard/components/prize_unfinalized_tooltip.tsxfront_end/src/app/(main)/(tournaments)/tournament/components/navigation_block.tsxfront_end/src/app/(main)/labor-hub/components/definition_tooltip.tsxfront_end/src/app/(main)/labor-hub/components/question_cards/multi_line_chart.tsxfront_end/src/app/(main)/questions/[id]/components/sidebar/sidebar_tooltip.tsxfront_end/src/components/forecast_maker/continuous_group_accordion/group_forecast_accordion_item.tsxfront_end/src/components/forecast_maker/continuous_input/continuous_input_container.tsxfront_end/src/components/truncated_text_tooltip.tsxfront_end/src/components/ui/tooltip.tsxfront_end/src/types/projects.tsprojects/models.pyprojects/serializers/common.pyprojects/services/cache.pyprojects/services/common.pyprojects/views/common.pytests/unit/test_projects/test_models.py
ncarazon
left a comment
There was a problem hiding this comment.
FE code looks good to me, but this should be also reviewed by BE eng
Co-authored-by: aseckin <aseckin@users.noreply.github.com>
Closes #4823
What
1. Tournament pages: show top-level questions count (+ subquestions tooltip)
The "View Questions (N)" button counted every
Questionrow — a group post with 10subquestions contributed 10, a conditional pair contributed 2 — which overstated
tournament size. Now:
questions_countcounts question posts: a single question, a question group, ora conditional pair each count as 1 (notebooks count 0). Applies everywhere the field
is shown (tournament grid cards, services cards, minibench, OG images).
questions_count_including_subquestionsfield.6 locales), rendered only when the tournament actually has subquestions.
Backend details:
annotate_questions_count()derives both counts from shared filter objects(approved posts,
question_weight > 0, not ambiguous/annulled), so they can't drift.No new SQL joins — the new
Count(distinct posts__id)reuses the existing join tree.v1 → v2for the new value shape (dict of bothcounts); old keys just expire via their 1h TTL.
/tournamentslisting sorts byquestions_count, so group-heavytournaments move down slightly — intended.
2. Tooltip:
variantprop consolidating the copy-pasted light themeThe light tooltip theme (blue border /
gray-0background /gray-800text) wasduplicated across 8 call sites via
tooltipClassName. The sharedTooltipcomponentnow takes
variant="dark" | "light"(defaultdark), and the 8 sites(leaderboard info icons, labor-hub chart legend,
DefinitionTooltip,sidebar/CDF tooltips, group forecast accordion) were migrated, keeping their
site-specific classes.
TruncatedTextTooltippassesvariantthrough.Call-site
tooltipClassNameoverrides still win via tailwind-merge.Verified with a tailwind-merge equivalence script: merged class sets are identical
for all migrated sites except two accepted normalizations — dead border classes that
!importantwas already beating at runtime, and the sidebar/CDF tooltips picking upthe standard light-theme text color (
gray-800/gray-800-dark) they previouslylacked (near-imperceptible:
#fbfbfc → #e4e7e9in dark mode).3. Tooltip: restyle base to match the Midterms Dashboard tooltip
The base styling now matches the congress-control tooltip from
midterms-2026(
chamber_row_tooltip.tsx):rounded-md,px-4 py-3,text-base,shadow-lg,borderless. The default variant becomes a navy bubble with white text
(
bg-blue-800 text-gray-0, inverted in dark mode); the light variant keeps itspalette and carries its own border now.
Audited every consumer that overrides background without setting text color
(medal-rank tooltip, score-data table, salmon "resolved" chips) — all set explicit
text colors in their content, so the inverted base palette can't strand invisible
text. Not ported on purpose:
text-center(alignment left to call sites) and thepositioning classes (floating-ui handles placement).
Test plan
test_annotate_questions_count(single + group + conditional +notebook/draft/annulled/zero-weight exclusions) — passes
tests/unit/test_projectspass (40/40)questions_count: 45,questions_count_including_subquestions: 95; button renders 45 with tooltip;tournament without subquestions renders no tooltip
sidebar, settings notifications, midterms dashboard (unaffected — has its own
component), forecast maker "resolved" chips
Summary by CodeRabbit
New Features
Refactor
Tests