Automattic\WooCommerce\Internal\Admin

Analytics::is_batch_pending_or_running │ private static │ WC 1.0

Whether an Action Scheduler job for the given batch hook is currently pending or running.

Detected live from Action Scheduler so a batch that dies never leaves a stuck "in progress" flag behind.

Method of the class: Analytics{}

No Hooks.

Returns

bool.

Usage

$result = Analytics::is_batch_pending_or_running( $hook ): bool;
$hook(string) (required)
Action Scheduler hook name.

Analytics::is_batch_pending_or_running() code WC 11.3.0

private static function is_batch_pending_or_running( string $hook ): bool {
	return ! empty(
		as_get_scheduled_actions(
			array(
				'hook'     => $hook,
				'status'   => array( \ActionScheduler_Store::STATUS_PENDING, \ActionScheduler_Store::STATUS_RUNNING ),
				'per_page' => 1,
				'orderby'  => 'none',
			),
			'ids'
		)
	);
}