--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use App\Models\ChatLog;
+use Illuminate\Console\Command;
+
+class EvaluateChatCommand extends Command {
+
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'chat:reevaluate';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Reevaluate chat log entries';
+
+ /**
+ * Execute the console command.
+ *
+ * @return int
+ */
+ public function handle() {
+ $good = 0;
+ $bad = 0;
+ ChatLog::where('type', '=', 'chat')
+ ->where('banned', false)
+ ->orderBy('created_at')
+ ->chunk(10000, function ($logs) use (&$good, &$bad) {
+ foreach ($logs as $line) {
+ try {
+ $line->evaluate();
+ $line->evaluated_at = now();
+ $line->save();
+ ++$good;
+ } catch (\Exception $e) {
+ ++$bad;
+ $this->error('unable to evaluate line '.$line->id.': '.$e->getMessage());
+ $line->type = 'error';
+ $line->text_content = $e->getMessage();
+ $line->evaluated_at = now();
+ $line->save();
+ }
+ }
+ echo $good;
+ if ($bad) {
+ echo ' +', $bad, ' errors';
+ }
+ echo PHP_EOL;
+ });
+
+ return Command::SUCCESS;
+ }
+
+}