Skip to content

Commit

Permalink
Merge pull request #435 from datafruits/fix-voting-completion-vote-2
Browse files Browse the repository at this point in the history
fix voting completion
  • Loading branch information
mcfiredrill authored Oct 13, 2024
2 parents 2f6800e + 1d946f1 commit 3e2cb35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
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

0 comments on commit 3e2cb35

Please sign in to comment.