Permalink
Browse files

fixed query problem in best sellers from previous fix

  • Loading branch information...
paulccarey committed Oct 23, 2010
1 parent 5d35ccf commit 0bda2a6c8a8fd12b63ef1885268a68fbaaa8cf03
Showing with 2 additions and 1 deletion.
  1. +2 −1 app/models/product_decorator.rb
@@ -21,7 +21,8 @@ def self.best_sellers(n, start = 1.week.ago, finish = Time.now)
best_n = Order.between(start,finish).find(:all,
:joins => "INNER JOIN checkouts ON orders.id = checkouts.order_id AND checkouts.state = 'complete'" +
" INNER JOIN line_items ON orders.id = line_items.order_id" +
- " INNER JOIN variants ON variant_id = variants.id",
+ " INNER JOIN variants ON variant_id = variants.id" +
+ " INNER JOIN products ON variants.product_id = products.id ",
:select => "product_id, SUM(quantity) sum",
:conditions => "products.deleted_at IS NULL",
:group => "product_id ORDER BY sum DESC",

0 comments on commit 0bda2a6

Please sign in to comment.