Permalink
Browse files

Updating votes for broken group by query

  • Loading branch information...
1 parent b0ae7b6 commit 3c378f072d3871f1ca3abfe25885c6c367d43bb3 @chewbranca chewbranca committed Feb 29, 2012
Showing with 5 additions and 1 deletion.
  1. +4 −0 app/models/vote.rb
  2. +1 −1 app/views/shared/sidebar/_who_liked.html.haml
View
@@ -49,6 +49,10 @@ def self.top_items limit = 5, range = nil, min_items = nil
end
end
+ def self.item_voices item
+ for_voteable(item).select('distinct voter_id').map {|vid| User.active.find(vid.voter_id) }
+ end
+
private
def update_voteable_count
@@ -1,7 +1,7 @@
-# @expects: local 'item'
- cache "#{item.cache_key}_who_liked", :expires_in => 60.minute do
-# user_list ||= item.voters_who_voted.uniq[0,40]
- - user_list ||= Vote.find(:all, :group => :voter_id, :conditions => ["voteable_type = ? AND voteable_id = ?", item.class.name, item.id], :order => "rand()", :limit => 40)
+ - user_list ||= Vote.item_voices(item)
%div{:class => "panel-1 #{defined?(widget_page) ? widget_page.css_class : ''}"}
.panel-bar
%h2= t('who_liked.title', :user_count => user_list.size)

0 comments on commit 3c378f0

Please sign in to comment.