Merge pull request woocommerce/woocommerce-admin#1664 from woocommerce/add/action-scheduler-group
add action scheduler group
This commit is contained in:
commit
39226c8c2c
|
@ -41,6 +41,11 @@ class WC_Admin_Reports_Sync {
|
||||||
*/
|
*/
|
||||||
const SINGLE_ORDER_ACTION = 'wc-admin_process_order';
|
const SINGLE_ORDER_ACTION = 'wc-admin_process_order';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action hook for processing a batch of orders.
|
||||||
|
*/
|
||||||
|
const QUEUE_GROUP = 'wc-admin-data';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue instance.
|
* Queue instance.
|
||||||
*
|
*
|
||||||
|
@ -145,6 +150,7 @@ class WC_Admin_Reports_Sync {
|
||||||
'per_page' => 1,
|
'per_page' => 1,
|
||||||
'claimed' => false,
|
'claimed' => false,
|
||||||
'search' => "[{$order_id}]",
|
'search' => "[{$order_id}]",
|
||||||
|
'group' => self::QUEUE_GROUP,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -308,13 +314,14 @@ class WC_Admin_Reports_Sync {
|
||||||
self::queue()->schedule_single(
|
self::queue()->schedule_single(
|
||||||
$action_timestamp,
|
$action_timestamp,
|
||||||
self::QUEUE_BATCH_ACTION,
|
self::QUEUE_BATCH_ACTION,
|
||||||
array( $batch_start, $batch_end, $single_batch_action )
|
array( $batch_start, $batch_end, $single_batch_action ),
|
||||||
|
self::QUEUE_GROUP
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, queue the single batches.
|
// Otherwise, queue the single batches.
|
||||||
for ( $i = $range_start; $i <= $range_end; $i++ ) {
|
for ( $i = $range_start; $i <= $range_end; $i++ ) {
|
||||||
self::queue()->schedule_single( $action_timestamp, $single_batch_action, array( $i ) );
|
self::queue()->schedule_single( $action_timestamp, $single_batch_action, array( $i ), self::QUEUE_GROUP );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,6 +342,7 @@ class WC_Admin_Reports_Sync {
|
||||||
'per_page' => 1,
|
'per_page' => 1,
|
||||||
'claimed' => false,
|
'claimed' => false,
|
||||||
'search' => $prerequisite_action, // search is used instead of hook to find queued batch creation.
|
'search' => $prerequisite_action, // search is used instead of hook to find queued batch creation.
|
||||||
|
'group' => self::QUEUE_GROUP,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -357,10 +365,11 @@ class WC_Admin_Reports_Sync {
|
||||||
self::queue()->schedule_single(
|
self::queue()->schedule_single(
|
||||||
$next_job_schedule->getTimestamp() + 5,
|
$next_job_schedule->getTimestamp() + 5,
|
||||||
self::QUEUE_DEPEDENT_ACTION,
|
self::QUEUE_DEPEDENT_ACTION,
|
||||||
array( $action, $action_args, $prerequisite_action )
|
array( $action, $action_args, $prerequisite_action ),
|
||||||
|
self::QUEUE_GROUP
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
self::queue()->schedule_single( time() + 5, $action, $action_args );
|
self::queue()->schedule_single( time() + 5, $action, $action_args, self::QUEUE_GROUP );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ class WC_Tests_Reports_Regenerate_Batching extends WC_REST_Unit_Test_Case {
|
||||||
WC_Admin_Reports_Sync::set_queue( null );
|
WC_Admin_Reports_Sync::set_queue( null );
|
||||||
|
|
||||||
// insert a blocking job.
|
// insert a blocking job.
|
||||||
WC_Admin_Reports_Sync::queue()->schedule_single( time(), 'blocking_job', array( 'stuff' ) );
|
WC_Admin_Reports_Sync::queue()->schedule_single( time(), 'blocking_job', array( 'stuff' ), WC_Admin_Reports_Sync::QUEUE_GROUP );
|
||||||
// queue an action that depends on blocking job.
|
// queue an action that depends on blocking job.
|
||||||
WC_Admin_Reports_Sync::queue_dependent_action( 'dependent_action', array(), 'blocking_job' );
|
WC_Admin_Reports_Sync::queue_dependent_action( 'dependent_action', array(), 'blocking_job' );
|
||||||
// verify that the action was properly blocked.
|
// verify that the action was properly blocked.
|
||||||
|
|
Loading…
Reference in New Issue