From 833cc7a1c273db638517f6c6704d783987e341f9 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Wed, 7 Aug 2019 16:12:47 -0300 Subject: [PATCH] convert zero last active date to null in customer query --- .../client/analytics/report/customers/table.js | 10 +++++++--- .../class-wc-admin-reports-customers-data-store.php | 3 +-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/woocommerce-admin/client/analytics/report/customers/table.js b/plugins/woocommerce-admin/client/analytics/report/customers/table.js index 6b25eb51b9e..53dd429aaf2 100644 --- a/plugins/woocommerce-admin/client/analytics/report/customers/table.js +++ b/plugins/woocommerce-admin/client/analytics/report/customers/table.js @@ -134,6 +134,12 @@ export default class CustomersReportTable extends Component { name ); + const dateLastActive = date_last_active ? ( + + ) : ( + '—' + ); + const dateRegistered = date_registered ? ( ) : ( @@ -159,9 +165,7 @@ export default class CustomersReportTable extends Component { value: username, }, { - display: date_last_active && ( - - ), + display: dateLastActive, value: date_last_active, }, { diff --git a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-customers-data-store.php b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-customers-data-store.php index 1d721f5befb..2e971e54518 100644 --- a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-customers-data-store.php +++ b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-customers-data-store.php @@ -48,7 +48,7 @@ class WC_Admin_Reports_Customers_Data_Store extends WC_Admin_Reports_Data_Store 'state' => 'state', 'postcode' => 'postcode', 'date_registered' => 'date_registered', - 'date_last_active' => 'date_last_active', + 'date_last_active' => 'IF( date_last_active < 1, NULL, date_last_active ) AS date_last_active', 'orders_count' => 'SUM( CASE WHEN parent_id = 0 THEN 1 ELSE 0 END ) as orders_count', 'total_spend' => 'SUM( gross_total ) as total_spend', 'avg_order_value' => '( SUM( gross_total ) / COUNT( order_id ) ) as avg_order_value', @@ -391,7 +391,6 @@ class WC_Admin_Reports_Customers_Data_Store extends WC_Admin_Reports_Data_Store if ( $query_args['page'] < 1 || $query_args['page'] > $total_pages ) { return $data; } - $customer_data = $wpdb->get_results( "SELECT {$selections}