Created
March 7, 2012 20:04
-
-
Save mgroebner/1995665 to your computer and use it in GitHub Desktop.
ertl bullshit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def recalculate_score | |
reload | |
user_ids = users.collect{|u| u.id } | |
self.score_cache = 0 | |
Category.all(:conditions => {:calculated => true}).each do |c| | |
self.score_cache += category.category_scores.all(:conditions => ["user_id IN (?)", user_ids], :order => "score_cache DESC", :limit => 3).sum(&:score_cache) | |
end | |
save(false) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment