Skip to content

Count own votes and skip deleted and hidden entities in votesStats - #5481

Merged
tspenov merged 1 commit into
masterfrom
fix-user-votes-stats
Dec 4, 2026
Merged

tspenov merged 1 commit into
masterfrom
fix-user-votes-stats

Conversation

@tspenov

@tspenov tspenov commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #5480.

Problem

After #5480, votesStats.totalVotes still differed from the sum of votes.totalVotes over the user's entities (getMostRecent(currentUserDataOnly: true)):

  • votesStats left out the owner's own votes, while each entity's votes.totalVotes includes them.
  • votesStats counted votes on deleted and hidden entities, which the entity lists leave out.

Fix

In Sanbase.Vote.user_total_votes/1:

  • The owner's own votes are counted, as in each entity's votes.totalVotes.
  • Votes on entities with is_deleted or is_hidden set are not counted.

To compare, use getMostRecent(currentUserDataOnly: true) with all entity types, including DASHBOARD and QUERY, and sum votes.totalVotes.

Tests

test/sanbase_web/graphql/user/user_votes_stats_api_test.exs: the own-votes test now expects them counted, and a new test covers deleted and hidden insights, a deleted watchlist and a hidden dashboard. Both failed before the change and pass after.

🤖 Generated with Claude Code

Each entity's votes.totalVotes includes the owner's votes, so votesStats
now counts them too and matches the sum over the user's entities. Votes
on deleted or hidden entities are left out, as the entity lists do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@tspenov
tspenov marked this pull request as ready for review December 4, 2026 11:01
@tspenov
tspenov requested a review from IvanIvanoff as a code owner December 4, 2026 11:01
@tspenov
tspenov merged commit 32029ba into master Dec 4, 2026
3 checks passed
@tspenov
tspenov deleted the fix-user-votes-stats branch December 4, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant