From 7ab3d2ee5a9239d0690596d9c875a98b7a5c6f64 Mon Sep 17 00:00:00 2001 From: brchristian Date: Wed, 27 Feb 2019 12:48:26 -0800 Subject: [PATCH] Count only completed orders In the backend `User#index` action, we use the [`display_lifetime_value`](https://github.com/solidusio/solidus/blob/master/core/app/models/concerns/spree/user_reporting.rb#L8-L10) helper to get the total value of all _completed_ orders. However, we display the count of _all_ orders, which is inconsistent. This commit changes this behavior and uses the existing [`order_count`](https://github.com/solidusio/solidus/blob/master/core/app/models/concerns/spree/user_reporting.rb#L12-L14) helper. Note that one strange aspect of the current `order_count` helper is that it converts the count to a decimal unnecessarily, which will appear strangely, (e.g., `1.0`) in the backend view. This is fixed in a separate PR by https://github.com/solidusio/solidus/pull/3124. --- backend/app/views/spree/admin/users/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/app/views/spree/admin/users/index.html.erb b/backend/app/views/spree/admin/users/index.html.erb index c05997e45d3..de948adfc6c 100644 --- a/backend/app/views/spree/admin/users/index.html.erb +++ b/backend/app/views/spree/admin/users/index.html.erb @@ -82,7 +82,7 @@ <%=link_to user.email, edit_admin_user_url(user) %> <%= user.spree_roles.map(&:name).to_sentence %> - <%= link_to user.orders.count, spree.orders_admin_user_path(user) %> + <%= link_to user.order_count, spree.orders_admin_user_path(user) %> <%= link_to user.display_lifetime_value, spree.items_admin_user_path(user) %> <%= l user.created_at.to_date %>