3 namespace App\Console\Commands;
5 use App\Models\ChatLib;
6 use App\Models\ChatLog;
7 use Illuminate\Console\Command;
9 class ChatlibDatabase extends Command {
12 * The name and signature of the console command.
16 protected $signature = 'chatlib:database';
19 * The console command description.
23 protected $description = 'Updates the ChatLib database';
26 * Execute the console command.
30 public function handle() {
34 ChatLog::where('type', '=', 'chat')
35 ->where('banned', '=', false)
36 ->whereNotNull('evaluated_at')
37 ->where('created_at', '<', now()->sub(7, 'day'))
38 ->whereNotIn('classification', ['gg', 'gl', 'number', 'o7'])
39 ->whereRaw('LENGTH(`text_content`) > 12')
40 ->chunk(5000, function ($msgs) use ($de, $en) {
41 foreach ($msgs as $msg) {
42 if ($msg->detected_language === 'de') {
43 $de->addMessage($msg);
44 } else if ($msg->detected_language === 'en') {
45 $en->addMessage($msg);
46 } else if (is_null($msg->detected_language)) {
47 $de->addMessage($msg);
48 $en->addMessage($msg);