spree_dash 0.60.4 → 0.60.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,9 +53,9 @@ class Admin::OverviewController < Admin::BaseController
53
53
 
54
54
  def conditions(params)
55
55
  if params.key? :to
56
- ["completed_at >= ? AND completed_at <= ?", params[:from], params[:to]]
56
+ ["completed_at >= ? AND completed_at <= ? AND state <> 'canceled'", params[:from], params[:to]]
57
57
  else
58
- ["completed_at >= ?", params[:from]]
58
+ ["completed_at >= ? AND state <> 'canceled'", params[:from]]
59
59
  end
60
60
  end
61
61
 
@@ -99,7 +99,7 @@ class Admin::OverviewController < Admin::BaseController
99
99
  end
100
100
 
101
101
  def best_selling_variants
102
- li = LineItem.includes(:order).where("orders.state = 'complete'").sum(:quantity, :group => :variant_id, :limit => 5)
102
+ li = LineItem.includes(:order).where("orders.state = 'complete'").sum(:quantity, :group => :variant_id, :order => 'sum(quantity) desc', :limit => 5)
103
103
  variants = li.map do |v|
104
104
  variant = Variant.find(v[0])
105
105
  [variant.name, v[1] ]
@@ -108,11 +108,10 @@ class Admin::OverviewController < Admin::BaseController
108
108
  end
109
109
 
110
110
  def top_grossing_variants
111
- quantity = LineItem.includes(:order).where("orders.state = 'complete'").sum(:quantity, :group => :variant_id, :limit => 5)
112
- prices = LineItem.includes(:order).where("orders.state = 'complete'").sum(:price, :group => :variant_id, :limit => 5)
113
- variants = quantity.map do |v|
111
+ prices = LineItem.includes(:order).where("orders.state = 'complete'").sum("price * quantity", :group => :variant_id, :order => 'sum(price * quantity) desc', :limit => 5)
112
+ variants = prices.map do |v|
114
113
  variant = Variant.find(v[0])
115
- [variant.name, v[1] * prices[v[0]]]
114
+ [variant.name, v[1]]
116
115
  end
117
116
 
118
117
  variants.sort { |x,y| y[1] <=> x[1] }
@@ -126,7 +125,7 @@ class Admin::OverviewController < Admin::BaseController
126
125
  end
127
126
 
128
127
  def last_five_orders
129
- orders = Order.includes(:line_items).where("completed_at IS NOT NULL").order("completed_at DESC").limit(5)
128
+ orders = Order.includes(:line_items).where("completed_at IS NOT NULL AND state <> 'canceled'").order("completed_at DESC").limit(5)
130
129
  orders.map do |o|
131
130
  qty = o.line_items.inject(0) {|sum,li| sum + li.quantity}
132
131
 
@@ -135,7 +134,7 @@ class Admin::OverviewController < Admin::BaseController
135
134
  end
136
135
 
137
136
  def biggest_spenders
138
- spenders = Order.sum(:total, :group => :user_id, :limit => 5, :order => "sum(total) desc", :conditions => "completed_at is not null and user_id is not null")
137
+ spenders = Order.sum(:total, :group => :user_id, :limit => 5, :order => "sum(total) desc", :conditions => "completed_at is not null and state <> 'canceled' and user_id is not null")
139
138
  spenders = spenders.map do |o|
140
139
  orders = User.find(o[0]).orders
141
140
  qty = orders.size
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_dash
3
3
  version: !ruby/object:Gem::Version
4
- hash: 231
4
+ hash: 229
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 60
9
- - 4
10
- version: 0.60.4
9
+ - 5
10
+ version: 0.60.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Quinn
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-21 00:00:00 Z
18
+ date: 2012-03-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -23,12 +23,12 @@ dependencies:
23
23
  requirements:
24
24
  - - "="
25
25
  - !ruby/object:Gem::Version
26
- hash: 231
26
+ hash: 229
27
27
  segments:
28
28
  - 0
29
29
  - 60
30
- - 4
31
- version: 0.60.4
30
+ - 5
31
+ version: 0.60.5
32
32
  requirement: *id001
33
33
  type: :runtime
34
34
  prerelease: false