--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use App\Events\ResultChanged;
+use App\Models\Round;
+use Illuminate\Console\Command;
+
+class RoundSeedCleanup extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'round:seed-cleanup';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Retrofit seeds to results where available';
+
+ /**
+ * Execute the console command.
+ */
+ public function handle()
+ {
+ $rounds = Round::query()->where('locked', '=', '0')->get();
+ foreach ($rounds as $round) {
+ $missing = $round->results()->whereNull('got_seed_at')->get();
+ foreach ($missing as $result) {
+ $entry = $round->protocols()
+ ->where('user_id', '=', $result->user_id)
+ ->where('type', '=', 'round.getseed')
+ ->oldest()
+ ->first();
+ if ($entry) {
+ $result->got_seed_at = $entry->created_at;
+ $result->save();
+ ResultChanged::dispatch($result);
+ }
+ }
+ }
+ return 0;
+ }
+}
Schedule::command('chat:evaluate 100')->everyMinute()->runInBackground();
Schedule::command('guessing:clean')->everyFifteenMinutes();
+Schedule::command('round:seed-cleanup')->everyFifteenMinutes();