Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit ad39af06663780f01f6d5d4a242779a37d7b0605 1 parent 9629aff
@romul authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  app/models/promotions.rb
View
2  app/models/promotions.rb
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.