Update votes for issues and merge requests
Created by: riyad
Votes for issues and merge requests are updated.
- downvotes are also recognized
- instead of just counting votes, a bar with up vs. down votes is displayed
- buttons on the issue details page are now also colored and the same size as those on the MR details page
Merge request reports
Activity
- app/roles/votes.rb 0 → 100644
1 module Votes 2 # Return the number of +1 comments (upvotes) 3 def upvotes 4 notes.select(&:upvote?).size 5 end 6 7 def upvotes_in_percent 8 if votes_count.zero? 9 0 10 else 11 100.0 / votes_count * upvotes 12 end - app/roles/votes.rb 0 → 100644
11 100.0 / votes_count * upvotes 12 end 13 end 14 15 # Return the number of -1 comments (downvotes) 16 def downvotes 17 notes.select(&:downvote?).size 18 end 19 20 def downvotes_in_percent 21 if votes_count.zero? 22 0 23 else 24 100.0 - upvotes_in_percent 25 end 26 end - app/roles/votes.rb 0 → 100644
1 module Votes 2 # Return the number of +1 comments (upvotes) 3 def upvotes 4 notes.select(&:upvote?).size 5 end 6 7 def upvotes_in_percent 8 if votes_count.zero? 9 0 10 else 11 100.0 / votes_count * upvotes 12 end Created by: riyad
Actually, this was deliberate. :) I explicitly try to avoid the ternary operator in Ruby ... I think they are bad style. It generally hurts legebility, especially if you have a
foo?
call or handle:symbols
.I might agree on the use of spaces though. ;)
By Administrator on 2012-09-11T21:42:56 (imported from GitLab project)
By Administrator on 2012-09-11T21:42:56 (imported from GitLab)
- app/roles/votes.rb 0 → 100644
1 module Votes 2 # Return the number of +1 comments (upvotes) 3 def upvotes 4 notes.select(&:upvote?).size 5 end 6 7 def upvotes_in_percent 8 if votes_count.zero? 9 0 10 else 11 100.0 / votes_count * upvotes 12 end Created by: NARKOZ
I explicitly try to avoid the ternary operator in Ruby ... I think they are bad style.
Don't worry about it. It's a good practice in Ruby, tho.
By Administrator on 2012-09-12T05:28:57 (imported from GitLab project)
By Administrator on 2012-09-12T05:28:57 (imported from GitLab)