Update
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
use App\Helpers\FirstParty\Credits\CreditsService;
|
||||
use App\Helpers\FirstParty\Meme\MemeGenerator;
|
||||
use App\Models\User;
|
||||
use App\Models\UserMemeGeneration;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -19,10 +18,13 @@ class GenerateMemeJob implements ShouldQueue
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $timeout = 30;
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
protected $userId;
|
||||
|
||||
protected $prompt;
|
||||
|
||||
protected $jobId;
|
||||
|
||||
public function __construct(int $userId, string $prompt, ?string $jobId)
|
||||
@@ -37,7 +39,7 @@ public function handle(): void
|
||||
{
|
||||
$userGeneration = UserMemeGeneration::where('job_id', $this->jobId)->first();
|
||||
|
||||
if (!$userGeneration) {
|
||||
if (! $userGeneration) {
|
||||
throw new \Exception("User generation record not found for job {$this->jobId}");
|
||||
}
|
||||
|
||||
@@ -72,7 +74,7 @@ public function handle(): void
|
||||
Cache::forget("user_active_job_{$this->userId}");
|
||||
} catch (\Exception $e) {
|
||||
// Handle failure with credit refund
|
||||
if (!$userGeneration->credits_are_processed) {
|
||||
if (! $userGeneration->credits_are_processed) {
|
||||
if ($userGeneration->credits_to_be_charged > 0) {
|
||||
CreditsService::depositAlacarte(
|
||||
$userGeneration->user_id,
|
||||
@@ -101,7 +103,7 @@ public function failed(\Throwable $exception): void
|
||||
{
|
||||
$userGeneration = UserMemeGeneration::where('job_id', $this->jobId)->first();
|
||||
|
||||
if ($userGeneration && !$userGeneration->credits_are_processed) {
|
||||
if ($userGeneration && ! $userGeneration->credits_are_processed) {
|
||||
if ($userGeneration->credits_to_be_charged > 0) {
|
||||
CreditsService::depositAlacarte(
|
||||
$userGeneration->user_id,
|
||||
|
||||
Reference in New Issue
Block a user