Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix voting completion #435

Merged
merged 2 commits into from
Oct 13, 2024
Merged
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
2 changes: 1 addition & 1 deletion app/models/shrimpo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def create_entries_zip

def voting_completion user
voted_count = ShrimpoVote.where(user: user).where("shrimpo_entry_id in (?)", self.shrimpo_entries.pluck(:id)).select(:shrimpo_entry_id).distinct.count
total_count = self.shrimpo_entries.count
total_count = self.shrimpo_entries.count - 1 # subtract 1 cuz can't vote on own shrimpo
((voted_count.to_f / total_count.to_f) * 100).round(2)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/shrimpo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
entry4.shrimpo_votes.create! score: 2, user: dj2
entry3.shrimpo_votes.create! score: 6, user: dj2

expect(shrimpo.voting_completion(dj2)).to eq 75.0
expect(shrimpo.voting_completion(dj2)).to eq 100.0
end

it 'cant vote on own entry' do
Expand Down
Loading