Simplified intervals_missing method of TimeInterval (https://github.com/woocommerce/woocommerce-admin/pull/2919)
This commit is contained in:
parent
1673e3f01f
commit
202fde95b5
|
@ -510,35 +510,21 @@ 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 ( '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;
|
||||
}
|
||||
} else {
|
||||
if ( 'desc' === $order ) {
|
||||
if ( $page_no > floor( $db_records / $items_per_page ) ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} elseif ( 'asc' === $order ) {
|
||||
if ( $page_no <= ceil( ( $expected_interval_count - $db_records ) / $items_per_page ) ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Invalid ordering.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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 );
|
||||
return $intervals_count < $expected_intervals_on_page;
|
||||
}
|
||||
if ( 'desc' === $order ) {
|
||||
return $page_no > floor( $db_records / $items_per_page );
|
||||
}
|
||||
if ( 'asc' === $order ) {
|
||||
return $page_no <= ceil( ( $expected_interval_count - $db_records ) / $items_per_page );
|
||||
}
|
||||
// Invalid ordering.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue