Permalink
Browse files

Reduce SQL-queries count, because now all products have variants.

  • Loading branch information...
1 parent 9629aff commit ad39af06663780f01f6d5d4a242779a37d7b0605 @romul committed Sep 6, 2009
Showing with 1 addition and 1 deletion.
  1. +1 −1 app/models/promotions.rb
View
@@ -5,7 +5,7 @@ def self.random_subset(n)
# randomize a small list, courtesy of
# http://redcorundum.blogspot.com/2006/12/randomizing-array-and-other-faqs.html
promos = n <= 0 ? [] : Promotions.find(:all).sort_by {rand}[0..n-1]
- Product.all(:conditions => ["id IN (?)", promos.map {|p| p.product_id }], :include => :images)
+ Product.all(:conditions => ["id IN (?)", promos.map {|p| p.product_id }], :include => [:variants, :images])
end
def self.best_sellers(n, start = 1.week.ago, finish = Time.now)

0 comments on commit ad39af0

Please sign in to comment.