WordPress at a glance
function is not described

Automattic\WooCommerce\Admin\API\Reports

DataStore::remove_extra_records() protected WC 1.0

Removes extra records from intervals so that only requested number of records get returned.

{} It's a method of the class: DataStore{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->remove_extra_records( $data, $page_no, $items_per_page, $db_interval_count, $expected_interval_count, $order_by, $order );
$data(stdClass) (required)
Data from whose intervals the records get removed.
$page_no(int) (required)
Offset requested by the user.
$items_per_page(int) (required)
Number of records requested by the user.
$db_interval_count(int) (required)
Database interval count.
$expected_interval_count(int) (required)
Expected interval count on the output.
$order_by(string) (required)
Order by field.
$order(string) (required)
ASC or DESC.

Code of DataStore::remove_extra_records() WC 5.3.0

<?php
protected function remove_extra_records( &$data, $page_no, $items_per_page, $db_interval_count, $expected_interval_count, $order_by, $order ) {
	if ( 'date' === strtolower( $order_by ) ) {
		$offset = 0;
	} else {
		if ( 'asc' === strtolower( $order ) ) {
			$offset = ( $page_no - 1 ) * $items_per_page;
		} else {
			$offset = ( $page_no - 1 ) * $items_per_page - $db_interval_count;
		}
		$offset = $offset < 0 ? 0 : $offset;
	}
	$count = $expected_interval_count - ( $page_no - 1 ) * $items_per_page;
	if ( $count < 0 ) {
		$count = 0;
	} elseif ( $count > $items_per_page ) {
		$count = $items_per_page;
	}
	$data->intervals = array_slice( $data->intervals, $offset, $count );
}