From 7b40e39ae37294bba1b6c05660a6c1fa9d462651 Mon Sep 17 00:00:00 2001 From: Tony Miller Date: Sat, 12 Oct 2024 20:26:20 -0700 Subject: [PATCH 1/2] fix voting completion account for not being able to vote on own shrimpo --- app/models/shrimpo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/shrimpo.rb b/app/models/shrimpo.rb index 13d1323d..52e28a12 100644 --- a/app/models/shrimpo.rb +++ b/app/models/shrimpo.rb @@ -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 From 1d946f18e251cdc5e4b519667eba9ae602504b21 Mon Sep 17 00:00:00 2001 From: Tony Miller Date: Sat, 12 Oct 2024 20:34:13 -0700 Subject: [PATCH 2/2] fix shrimpo_spec --- spec/models/shrimpo_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/shrimpo_spec.rb b/spec/models/shrimpo_spec.rb index ba33e074..ee00f195 100644 --- a/spec/models/shrimpo_spec.rb +++ b/spec/models/shrimpo_spec.rb @@ -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