Skip to content

refactor(votes): one tally module for score - #501

Open
chiptus wants to merge 3 commits into
mainfrom
feat-13/vote-tally-module
Open

chiptus wants to merge 3 commits into
mainfrom
feat-13/vote-tally-module

Conversation

@chiptus

@chiptus chiptus commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Consolidates the three diverging vote-aggregation formulas (mean rating, Won't-Go-blind popularity, and the Set-detail net-score badge) into one pure tallyVotes() module (src/lib/votes/score.ts), so every caller reads counts and score from one place instead of re-deriving vote_type literals. Replaces the rating-desc/popularity-desc sorts with a single default "Top Score" (score-desc) sort, drops the (mathematically unreachable) Minimum Rating filter, and deletes useVoteCount.

UPL-13

Verification

  • On a set's Votes tab, sort by "Top Score" and confirm it matches the sum shown in the badge/vote-button counts (Must Go = +2, Interested = +1, Won't Go = -1).
  • Open a set detail page; the "Score: +N" badge still renders and matches the vote button counts below it.
  • Load an old bookmarked URL with sort=rating-desc, sort=popularity-desc, or minRating=2; the page loads with the new default sort instead of erroring.
  • pnpm test (664 tests) and pnpm run typecheck pass; pnpm run lint is clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LkfRGkbSUEtCTNWyfaPSKF


Generated by Claude Code

… lib/votes

One vote metric everywhere: Score = 2·MustGo + Interested − WontGo, computed
by the new pure tallyVotes() in src/lib/votes/score.ts (weights from the vote
config, which moves to src/lib/votes/config.ts). Replaces the three diverging
hand-rolled formulas (SetDetails net score, VoteTab rating/popularity), the
rating-desc/popularity-desc sorts (now a single default "Top Score" /
score-desc sort), the half-broken Minimum Rating filter, and the
useVoteCount hook. Old sort/minRating URLs degrade gracefully via the
existing zod .catch. See docs/adr/0010-single-vote-score.md.

UPL-13

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LkfRGkbSUEtCTNWyfaPSKF
vote() belongs below the describe block per the repo's file-structure
convention, and the group-scoped-subset test used a subset that happened
to score the same as the full set, so it couldn't actually catch a
scoping bug.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LkfRGkbSUEtCTNWyfaPSKF
Copilot AI lite review requested due to automatic review settings September 15, 2026 05:22
@vercel

vercel Bot commented Sep 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
upline Ready Ready Preview Sep 15, 2026 5:29am UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Fix the broken E2E import, add legacy-URL regression coverage, and update stale design-document references.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR centralizes vote scoring and counting through tallyVotes(), replaces legacy ranking with “Top Score,” and updates related consumers.

Changes:

  • Added shared scoring/configuration modules and tests.
  • Updated voting UIs, badges, filters, URL handling, and documentation.
  • Removed Minimum Rating filtering and useVoteCount.
File summaries
File Summary
src/routes/festivals/$festivalSlug/editions/$editionSlug/sets/$setSlug.tsx Uses shared score tallying.
src/routes/festivals/$festivalSlug/editions/$editionSlug/explore.tsx Updates vote config import.
src/pages/SetDetails/SetVotingButtons.tsx Uses centralized vote counts.
src/pages/SetDetails/SetInfoCard.tsx Renders the shared score.
src/pages/SetDetails/SetGroupVoting.tsx Uses centralized group counts.
src/pages/SetDetails/NonMusicSetDetail/NonMusicSetDetail.tsx Passes the renamed score prop.
src/pages/SetDetails/NonMusicSetDetail/NonMusicSetBanner.tsx Renders the renamed score prop.
src/pages/SetDetails/MultiArtistSetInfoCard.tsx Renders the shared score.
src/pages/ExploreSetPage/VotingActions.tsx Updates vote config import.
src/pages/ExploreSetPage/VotingActions.test.tsx Updates test imports.
src/pages/EditionView/tabs/VoteTab/useSetFiltering.ts Sorts by shared score.
src/pages/EditionView/tabs/VoteTab/SetCard/SetVotingButtons.tsx Uses centralized counts.
src/pages/EditionView/tabs/VoteTab/filters/SortControls.tsx Replaces legacy sort explanations.
src/pages/EditionView/tabs/VoteTab/filters/MobileFilters.tsx Removes Minimum Rating UI.
src/pages/EditionView/tabs/VoteTab/filters/FilterSortControls.tsx Removes rating filter state.
src/pages/EditionView/tabs/VoteTab/filters/DesktopFilters.tsx Removes Minimum Rating UI.
src/pages/EditionView/tabs/VoteTab/filters/constants.ts Defines the Top Score sort.
src/pages/EditionView/tabs/ScheduleTab/VoteFilterChips.tsx Updates vote config import.
src/pages/EditionView/tabs/ScheduleTab/VoteButtons.tsx Uses centralized counts.
src/pages/EditionView/tabs/ScheduleTab/horizontal/OverviewStageRow.tsx Updates vote config import.
src/lib/votes/score.ts Adds the shared tally implementation.
src/lib/votes/score.test.ts Tests tally behavior.
src/lib/votes/config.ts Relocates vote configuration. Critical (3 votes): update the broken E2E import; Nit (1 vote): update stale design-document paths.
src/lib/votes/config.test.ts Updates configuration tests.
src/lib/searchSchemas.ts Updates sort defaults and removes rating state. Moderate (2 votes): add legacy-URL regression coverage.
src/lib/scheduleFilter.ts Updates vote config import.
src/hooks/useVoteCount.ts Removes the obsolete hook.
src/hooks/useTimelineUrlState.ts Updates vote type imports.
src/components/onboarding/steps/VotingExplanationStep.tsx Updates vote config import.
docs/adr/0010-single-vote-score.md Documents the unified score model.
CONTEXT.md Updates domain terminology.
Review details
  • Files reviewed: 30/31 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lib/searchSchemas.ts
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

Playwright test results

passed  65 passed

Details

stats  65 tests across 21 suites
duration  1 minute, 25 seconds
commit  3df993e

…y-URL test

tests/e2e/voting.spec.ts still imported from the old src/lib/voteConfig
path, breaking the e2e build (my earlier import sweep only covered src/).
Also repoints two design docs at the new path and adds regression coverage
for the legacy sort/minRating URL params degrading via the zod .catch.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LkfRGkbSUEtCTNWyfaPSKF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants