ActionScheduler_DBStore::get_claim_countpublicWC 1.0

Get the number of active claims.

Method of the class: ActionScheduler_DBStore{}

No Hooks.

Returns

Int.

Usage

$ActionScheduler_DBStore = new ActionScheduler_DBStore();
$ActionScheduler_DBStore->get_claim_count();

ActionScheduler_DBStore::get_claim_count() code WC 11.0.1

public function get_claim_count() {
	global $wpdb;

	$sql = "
		SELECT COUNT(*)
		FROM {$wpdb->actionscheduler_claims} c
		WHERE EXISTS (
			SELECT 1
			FROM {$wpdb->actionscheduler_actions} a
			WHERE a.claim_id = c.claim_id
			AND a.status IN ( %s, %s )
		)
	";
	$sql = $wpdb->prepare( $sql, array( self::STATUS_PENDING, self::STATUS_RUNNING ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared

	return (int) $wpdb->get_var( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}