Merge pull request woocommerce/woocommerce-admin#2764 from woocommerce/fix/2746

convert zero last active date to null in customer query
This commit is contained in:
Ron Rennick 2019-08-09 08:40:57 -03:00 committed by GitHub
commit 9a42f00477
2 changed files with 8 additions and 5 deletions

View File

@ -134,6 +134,12 @@ export default class CustomersReportTable extends Component {
name name
); );
const dateLastActive = date_last_active ? (
<Date date={ date_last_active } visibleFormat={ defaultTableDateFormat } />
) : (
'—'
);
const dateRegistered = date_registered ? ( const dateRegistered = date_registered ? (
<Date date={ date_registered } visibleFormat={ defaultTableDateFormat } /> <Date date={ date_registered } visibleFormat={ defaultTableDateFormat } />
) : ( ) : (
@ -159,9 +165,7 @@ export default class CustomersReportTable extends Component {
value: username, value: username,
}, },
{ {
display: date_last_active && ( display: dateLastActive,
<Date date={ date_last_active } visibleFormat={ defaultTableDateFormat } />
),
value: date_last_active, value: date_last_active,
}, },
{ {

View File

@ -48,7 +48,7 @@ class WC_Admin_Reports_Customers_Data_Store extends WC_Admin_Reports_Data_Store
'state' => 'state', 'state' => 'state',
'postcode' => 'postcode', 'postcode' => 'postcode',
'date_registered' => 'date_registered', 'date_registered' => 'date_registered',
'date_last_active' => 'date_last_active', 'date_last_active' => 'IF( date_last_active <= "0000-00-00 00:00:00", NULL, date_last_active ) AS date_last_active',
'orders_count' => 'SUM( CASE WHEN parent_id = 0 THEN 1 ELSE 0 END ) as orders_count', 'orders_count' => 'SUM( CASE WHEN parent_id = 0 THEN 1 ELSE 0 END ) as orders_count',
'total_spend' => 'SUM( gross_total ) as total_spend', 'total_spend' => 'SUM( gross_total ) as total_spend',
'avg_order_value' => '( SUM( gross_total ) / COUNT( order_id ) ) as avg_order_value', '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 ) { if ( $query_args['page'] < 1 || $query_args['page'] > $total_pages ) {
return $data; return $data;
} }
$customer_data = $wpdb->get_results( $customer_data = $wpdb->get_results(
"SELECT "SELECT
{$selections} {$selections}