update (kernel): fix pickup logic

This commit is contained in:
charlesteh
2023-10-02 12:22:18 +08:00
committed by GitHub
parent 5e6f50afe5
commit 51f035c0a2

View File

@@ -34,10 +34,16 @@ protected function schedule(Schedule $schedule)
if ($currentTime->gte($nextRun->next_run_time)) {
$shopee_seller_category = ShopeeSellerCategory::where('category_id', $category->id)->where(function($query) {
$query->whereNull('last_ai_written_at')
->orWhere('last_ai_written_at', '=', ShopeeSellerCategory::whereNotNull('last_ai_written_at')->orderBy('last_ai_written_at', 'asc')->value('last_ai_written_at'));
})->first();
$shopee_seller_category = ShopeeSellerCategory::where('category_id', $category->id)
->orderByRaw('ISNULL(last_ai_written_at) DESC')
->orderBy('last_ai_written_at', 'asc')
->orderBy('id', 'asc')
->first();
// $shopee_seller_category = ShopeeSellerCategory::where('category_id', $category->id)->where(function($query) {
// $query->whereNull('last_ai_written_at')
// ->orWhere('last_ai_written_at', '=', ShopeeSellerCategory::whereNotNull('last_ai_written_at')->orderBy('last_ai_written_at', 'asc')->value('last_ai_written_at'));
// })->first();
$task = ShopeeSellerTopProductScraperJob::dispatch($shopee_seller_category->seller, $category->country_locale->country_iso, $category)
->onQueue('default')