coolify/app/Jobs/CleanupInstanceStuffsJob.php

47 lines
1.2 KiB
PHP
Raw Normal View History

2023-08-15 14:11:38 +02:00
<?php
namespace App\Jobs;
use App\Models\Waitlist;
use Illuminate\Bus\Queueable;
2023-09-14 10:12:44 +02:00
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
2023-08-15 14:11:38 +02:00
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
2023-09-14 10:12:44 +02:00
class CleanupInstanceStuffsJob implements ShouldQueue, ShouldBeUnique, ShouldBeEncrypted
2023-08-15 14:11:38 +02:00
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct()
{
}
// public function uniqueId(): string
// {
// return $this->container_name;
// }
public function handle(): void
{
try {
// $this->cleanup_waitlist();
2023-09-11 17:36:30 +02:00
} catch (\Throwable $e) {
send_internal_notification('CleanupInstanceStuffsJob failed with error: ' . $e->getMessage());
2023-08-15 14:11:38 +02:00
ray($e->getMessage());
2023-08-24 21:09:58 +02:00
throw $e;
2023-08-15 14:11:38 +02:00
}
}
private function cleanup_waitlist()
{
2023-08-30 18:23:55 +02:00
$waitlist = Waitlist::whereVerified(false)->where('created_at', '<', now()->subMinutes(config('constants.waitlist.expiration')))->get();
2023-08-15 14:11:38 +02:00
foreach ($waitlist as $item) {
$item->delete();
}
}
}