Simplified intervals_missing method of TimeInterval (https://github.com/woocommerce/woocommerce-admin/pull/2919)
This commit is contained in:
parent
1673e3f01f
commit
202fde95b5
|
@ -510,36 +510,22 @@ class TimeInterval {
|
|||
* @return bool
|
||||
*/
|
||||
public static 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 ) {
|
||||
$expected_intervals_on_page = self::expected_intervals_on_page( $expected_interval_count, $items_per_page, $page_no );
|
||||
if ( $intervals_count < $expected_intervals_on_page ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
return $intervals_count < $expected_intervals_on_page;
|
||||
}
|
||||
} else {
|
||||
if ( 'desc' === $order ) {
|
||||
if ( $page_no > floor( $db_records / $items_per_page ) ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
return $page_no > floor( $db_records / $items_per_page );
|
||||
}
|
||||
} elseif ( 'asc' === $order ) {
|
||||
if ( $page_no <= ceil( ( $expected_interval_count - $db_records ) / $items_per_page ) ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
if ( 'asc' === $order ) {
|
||||
return $page_no <= ceil( ( $expected_interval_count - $db_records ) / $items_per_page );
|
||||
}
|
||||
} else {
|
||||
// Invalid ordering.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize "*_between" parameters to "*_min" and "*_max" for numeric values
|
||||
|
|
Loading…
Reference in New Issue