]> git.localhorst.tv Git - alttp.git/commitdiff
clean up forgotten guessing games
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 28 Mar 2024 10:03:41 +0000 (11:03 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 28 Mar 2024 10:03:41 +0000 (11:03 +0100)
app/Console/Commands/GuessingClean.php [new file with mode: 0644]
app/Console/Kernel.php

diff --git a/app/Console/Commands/GuessingClean.php b/app/Console/Commands/GuessingClean.php
new file mode 100644 (file)
index 0000000..d26b3e9
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Models\Channel;
+use Illuminate\Console\Command;
+use Illuminate\Http\Client\RequestException;
+use Illuminate\Support\Facades\Http;
+
+class GuessingClean extends Command {
+
+       /**
+        * The name and signature of the console command.
+        *
+        * @var string
+        */
+       protected $signature = 'guessing:clean';
+
+       /**
+        * The console command description.
+        *
+        * @var string
+        */
+       protected $description = 'Cancel orphaned guessing games';
+
+       /**
+        * Execute the console command.
+        *
+        * @return int
+        */
+       public function handle()
+       {
+               $channels = Channel
+                       ::whereNotNull('guessing_start')
+                       ->where('guessing_start', '<', now()
+                       ->sub(4, 'hour'))
+                       ->get();
+               foreach ($channels as $channel) {
+                       $this->line($channel->title);
+                       $channel->guessing_start = null;
+                       $channel->guessing_end = null;
+                       $channel->save();
+               }
+               return Command::SUCCESS;
+       }
+
+}
index bbb747d3d614fbdc9e52828f021fd87247466ce5..32e5c8a0afad44f0309ebe55e7fb4995c90ddc45 100644 (file)
@@ -22,6 +22,7 @@ class Kernel extends ConsoleKernel
                $schedule->command('sync:avatars')->everyFiveMinutes();
                $schedule->command('sync:racetime')->everyFiveMinutes();
                $schedule->command('chat:evaluate 100')->everyMinute();
+               $schedule->command('guessing:clean')->everyFifteenMinutes();
     }
 
     /**