3 namespace App\Console\Commands;
5 use App\Models\ChatLog;
6 use Illuminate\Console\Command;
8 class EvaluateChatCommand extends Command {
11 * The name and signature of the console command.
15 protected $signature = 'chat:evaluate {amount=1}';
18 * The console command description.
22 protected $description = 'Evaluate chat log entries';
25 * Execute the console command.
29 public function handle() {
30 $amount = $this->argument('amount');
32 $logs = ChatLog::whereNull('evaluated_at')->orderBy('created_at')->limit($amount)->get();
34 foreach ($logs as $line) {
37 $line->evaluated_at = now();
39 } catch (\Exception $e) {
40 $this->error('unable to evaluate line '.$line->id.': '.$e->getMessage());
41 $line->type = 'error';
42 $line->text_content = $e->getMessage();
43 $line->evaluated_at = now();
48 return Command::SUCCESS;