| @@ -65,8 +65,27 @@ | ||
| 65 | 65 | { |
| 66 | 66 | return $this->getCountJobs(['status' => 'processing']) > 0; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | + public function getProductUpdateStatus(): array | |
| 70 | + { | |
| 71 | + $quickJob = $this->getJob(['job_type' => 'sync_basalam_bulk_update_products', 'status' => 'processing']) | |
| 72 | + ?: $this->getJob(['job_type' => 'sync_basalam_bulk_update_products', 'status' => 'pending']); | |
| 73 | + $fullJob = $this->getJob(['job_type' => 'sync_basalam_update_all_products', 'status' => 'processing']) | |
| 74 | + ?: $this->getJob(['job_type' => 'sync_basalam_update_all_products', 'status' => 'pending']); | |
| 75 | + $singleCount = $this->getCountJobs([ | |
| 76 | + 'job_type' => 'sync_basalam_update_single_product', | |
| 77 | + 'status' => ['pending', 'processing'], | |
| 78 | + ]); | |
| 79 | + | |
| 80 | + return [ | |
| 81 | + 'active' => (bool) ($quickJob || $fullJob || $singleCount > 0), | |
| 82 | + 'type' => $quickJob ? 'quick' : (($fullJob || $singleCount > 0) ? 'full' : ''), | |
| 83 | + 'status' => $quickJob ? $quickJob->status : ($fullJob ? $fullJob->status : ''), | |
| 84 | + 'count' => $singleCount, | |
| 85 | + ]; | |
| 86 | + } | |
| 87 | + | |
| 69 | 88 | public function hasPendingOrStaleProcessingJobs(int $staleProcessingTimeoutSeconds = 120): bool |
| 70 | 89 | { |
| 71 | 90 | global $wpdb; |
| 72 | 91 | |