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