Sync refactor tweaks (https://github.com/woocommerce/woocommerce-admin/pull/3504)
* add check for in progress actions * add check for AS get_date() function * incorporate review feedback * remove unnecessary else
This commit is contained in:
parent
76e5483cf2
commit
d1f198b21f
|
@ -38,8 +38,18 @@ abstract class ImportScheduler {
|
||||||
'group' => self::$group,
|
'group' => self::$group,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
if ( empty( $pending_jobs ) ) {
|
||||||
|
$in_progress = self::queue()->search(
|
||||||
|
array(
|
||||||
|
'status' => 'in-progress',
|
||||||
|
'per_page' => 1,
|
||||||
|
'search' => 'import',
|
||||||
|
'group' => self::$group,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return ! empty( $pending_jobs );
|
return ! empty( $pending_jobs ) || ! empty( $in_progress );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -234,7 +234,11 @@ trait SchedulerTraits {
|
||||||
if ( is_array( $blocking_jobs ) ) {
|
if ( is_array( $blocking_jobs ) ) {
|
||||||
foreach ( $blocking_jobs as $blocking_job ) {
|
foreach ( $blocking_jobs as $blocking_job ) {
|
||||||
$blocking_job_hook = $blocking_job->get_hook();
|
$blocking_job_hook = $blocking_job->get_hook();
|
||||||
$next_job_schedule = $blocking_job->get_schedule()->next();
|
if ( method_exists( $blocking_job->get_schedule(), 'get_date' ) ) {
|
||||||
|
$next_job_schedule = $blocking_job->get_schedule()->get_date();
|
||||||
|
} else {
|
||||||
|
$next_job_schedule = $blocking_job->get_schedule()->next();
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure that the next schedule is a DateTime (it can be null).
|
// Ensure that the next schedule is a DateTime (it can be null).
|
||||||
if ( is_a( $next_job_schedule, 'DateTime' ) ) {
|
if ( is_a( $next_job_schedule, 'DateTime' ) ) {
|
||||||
|
|
Loading…
Reference in New Issue