show story downvoting usernames to moderators to detect problems
such as voting rings or users downvoting things instead of filtering tags
This commit is contained in:
parent
57748f9839
commit
3a60d3abba
|
@ -401,15 +401,25 @@ class Story < ActiveRecord::Base
|
|||
self.url.blank? ? self.comments_url : self.url
|
||||
end
|
||||
|
||||
def vote_summary
|
||||
def vote_summary_for(user)
|
||||
r_counts = {}
|
||||
r_whos = {}
|
||||
Vote.where(:story_id => self.id, :comment_id => nil).each do |v|
|
||||
r_counts[v.reason.to_s] ||= 0
|
||||
r_counts[v.reason.to_s] += v.vote
|
||||
if user && user.is_moderator?
|
||||
r_whos[v.reason.to_s] ||= []
|
||||
r_whos[v.reason.to_s].push v.user.username
|
||||
end
|
||||
end
|
||||
|
||||
r_counts.keys.sort.map{|k|
|
||||
k == "" ? "+#{r_counts[k]}" : "#{r_counts[k]} #{Vote::STORY_REASONS[k]}"
|
||||
if k == ""
|
||||
"+#{r_counts[k]}"
|
||||
else
|
||||
"#{r_counts[k]} #{Vote::STORY_REASONS[k]}" +
|
||||
(user && user.is_moderator?? " (#{r_whos[k].join(", ")})" : "")
|
||||
end
|
||||
}.join(", ")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -78,7 +78,7 @@ class="story <%= story.vote == 1 ? "upvoted" : (story.vote == -1 ?
|
|||
|
||||
<% if defined?(single_story) && single_story %>
|
||||
<% if story.downvotes > 0 %>
|
||||
| <%= story.vote_summary.downcase %>
|
||||
| <%= story.vote_summary_for(@user).downcase %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in a new issue