3 namespace App\Console\Commands;
5 use App\Models\ChatLog;
6 use Illuminate\Console\Command;
8 class ReevaluateChatCommand extends Command {
11 * The name and signature of the console command.
15 protected $signature = 'chat:reevaluate';
18 * The console command description.
22 protected $description = 'Reevaluate chat log entries';
25 * Execute the console command.
29 public function handle() {
32 ChatLog::whereIn('type', ['chat', 'error'])
33 ->where('banned', false)
34 ->orderBy('created_at')
35 ->chunk(5000, function ($logs) use (&$good, &$bad) {
36 foreach ($logs as $line) {
39 if ($line->isDirty()) {
40 $line->evaluated_at = now();
44 } catch (\Exception $e) {
46 $this->error('unable to evaluate line '.$line->id.': '.$e->getMessage());
47 $line->type = 'error';
48 $line->text_content = $e->getMessage();
49 $line->evaluated_at = now();
55 echo ' +', $bad, ' errors';
60 return Command::SUCCESS;