Simplified intervals_missing method of DataStore class (https://github.com/woocommerce/woocommerce-admin/pull/2920)
* Simplified intervals_missing method of DataStore class * Fixed a little typo
This commit is contained in:
parent
e4817567e7
commit
1673e3f01f
|
@ -267,36 +267,22 @@ class DataStore {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function intervals_missing( $expected_interval_count, $db_records, $items_per_page, $page_no, $order, $order_by, $intervals_count ) {
|
protected function intervals_missing( $expected_interval_count, $db_records, $items_per_page, $page_no, $order, $order_by, $intervals_count ) {
|
||||||
if ( $expected_interval_count > $db_records ) {
|
if ( $expected_interval_count <= $db_records ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if ( 'date' === $order_by ) {
|
if ( 'date' === $order_by ) {
|
||||||
$expected_intervals_on_page = $this->expected_intervals_on_page( $expected_interval_count, $items_per_page, $page_no );
|
$expected_intervals_on_page = $this->expected_intervals_on_page( $expected_interval_count, $items_per_page, $page_no );
|
||||||
if ( $intervals_count < $expected_intervals_on_page ) {
|
return $intervals_count < $expected_intervals_on_page;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if ( 'desc' === $order ) {
|
if ( 'desc' === $order ) {
|
||||||
if ( $page_no > floor( $db_records / $items_per_page ) ) {
|
return $page_no > floor( $db_records / $items_per_page );
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} elseif ( 'asc' === $order ) {
|
if ( 'asc' === $order ) {
|
||||||
if ( $page_no <= ceil( ( $expected_interval_count - $db_records ) / $items_per_page ) ) {
|
return $page_no <= ceil( ( $expected_interval_count - $db_records ) / $items_per_page );
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Invalid ordering.
|
// Invalid ordering.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the LIMIT query part for Intervals query of the report.
|
* Updates the LIMIT query part for Intervals query of the report.
|
||||||
|
@ -305,7 +291,7 @@ class DataStore {
|
||||||
* to fetch correct records.
|
* to fetch correct records.
|
||||||
*
|
*
|
||||||
* @param array $intervals_query Array with clauses for the Intervals SQL query.
|
* @param array $intervals_query Array with clauses for the Intervals SQL query.
|
||||||
* @param array $query_args Query arguements.
|
* @param array $query_args Query arguments.
|
||||||
* @param int $db_interval_count Database interval count.
|
* @param int $db_interval_count Database interval count.
|
||||||
* @param int $expected_interval_count Expected interval count on the output.
|
* @param int $expected_interval_count Expected interval count on the output.
|
||||||
* @param string $table_name Name of the db table relevant for the date constraint.
|
* @param string $table_name Name of the db table relevant for the date constraint.
|
||||||
|
|
Loading…
Reference in New Issue