Added fetching of db intervals for later use in zero-filling.
This commit is contained in:
parent
1c09b6836d
commit
4c8a95cb89
|
@ -145,23 +145,24 @@ class WC_Admin_Reports_Taxes_Stats_Data_Store extends WC_Admin_Reports_Data_Stor
|
|||
$intervals_query = array();
|
||||
$this->update_sql_query_params( $query_args, $totals_query, $intervals_query );
|
||||
|
||||
$db_records_count = (int) $wpdb->get_var(
|
||||
"SELECT COUNT(*) FROM (
|
||||
SELECT
|
||||
{$intervals_query['select_clause']} AS time_interval
|
||||
FROM
|
||||
{$table_name}
|
||||
{$intervals_query['from_clause']}
|
||||
WHERE
|
||||
1=1
|
||||
{$intervals_query['where_time_clause']}
|
||||
{$intervals_query['where_clause']}
|
||||
GROUP BY
|
||||
time_interval
|
||||
) AS t"
|
||||
$db_intervals = $wpdb->get_col(
|
||||
"SELECT
|
||||
{$intervals_query['select_clause']} AS time_interval
|
||||
FROM
|
||||
{$table_name}
|
||||
{$intervals_query['from_clause']}
|
||||
WHERE
|
||||
1=1
|
||||
{$intervals_query['where_time_clause']}
|
||||
{$intervals_query['where_clause']}
|
||||
GROUP BY
|
||||
time_interval"
|
||||
); // WPCS: cache ok, DB call ok, unprepared SQL ok.
|
||||
|
||||
$total_pages = (int) ceil( $db_records_count / $intervals_query['per_page'] );
|
||||
$db_interval_count = count( $db_intervals );
|
||||
$expected_interval_count = WC_Admin_Reports_Interval::intervals_between( $query_args['after'], $query_args['before'], $query_args['interval'] );
|
||||
$total_pages = (int) ceil( $expected_interval_count / $intervals_query['per_page'] );
|
||||
|
||||
if ( $query_args['page'] < 1 || $query_args['page'] > $total_pages ) {
|
||||
return $data;
|
||||
}
|
||||
|
@ -219,7 +220,7 @@ class WC_Admin_Reports_Taxes_Stats_Data_Store extends WC_Admin_Reports_Data_Stor
|
|||
$data = (object) array(
|
||||
'totals' => $totals,
|
||||
'intervals' => $intervals,
|
||||
'total' => $db_records_count,
|
||||
'total' => $expected_interval_count,
|
||||
'pages' => $total_pages,
|
||||
'page_no' => (int) $query_args['page'],
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue