Action_Scheduler\Migration

BatchFetcher::get_query_strategies()privateWC 1.0

Generate a list of prioritized of action search parameters.

Method of the class: BatchFetcher{}

No Hooks.

Return

Array.

Usage

// private - for code of main (parent) class only
$result = $this->get_query_strategies( $count );
$count(int) (required)
Number of actions to find.

BatchFetcher::get_query_strategies() code WC 8.6.1

private function get_query_strategies( $count ) {
	$now  = as_get_datetime_object();
	$args = [
		'date'     => $now,
		'per_page' => $count,
		'offset'   => 0,
		'orderby'  => 'date',
		'order'    => 'ASC',
	];

	$priorities = [
		Store::STATUS_PENDING,
		Store::STATUS_FAILED,
		Store::STATUS_CANCELED,
		Store::STATUS_COMPLETE,
		Store::STATUS_RUNNING,
		'', // any other unanticipated status
	];

	foreach ( $priorities as $status ) {
		yield wp_parse_args( [
			'status'       => $status,
			'date_compare' => '<=',
		], $args );
		yield wp_parse_args( [
			'status'       => $status,
			'date_compare' => '>=',
		], $args );
	}
}