Upload beautify
This commit is contained in:
47
app/Jobs/RegenerateUserRecommendationCacheJob.php
Normal file
47
app/Jobs/RegenerateUserRecommendationCacheJob.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Services\Recommendations\PersonalizedFeedService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
final class RegenerateUserRecommendationCacheJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
public int $tries = 3;
|
||||
|
||||
/** @var array<int, int> */
|
||||
public array $backoff = [10, 60, 180];
|
||||
|
||||
public function __construct(
|
||||
public readonly int $userId,
|
||||
public readonly string $algoVersion
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(PersonalizedFeedService $feedService): void
|
||||
{
|
||||
try {
|
||||
$feedService->regenerateCacheForUser($this->userId, $this->algoVersion);
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('RegenerateUserRecommendationCacheJob failed', [
|
||||
'user_id' => $this->userId,
|
||||
'algo_version' => $this->algoVersion,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user