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() {
36 ChatLog::where('type', '=', 'chat')
37 ->where('banned', '=', false)
38 ->whereNotNull('evaluated_at')
39 ->where('created_at', '<', now()->sub(7, 'day'))
40 ->whereNotIn('classification', ['gg', 'gl', 'number', 'o7'])
41 ->whereRaw('LENGTH(`text_content`) > 12')
42 ->chunk(5000, function ($msgs) use (&$count, $de, $en) {
43 foreach ($msgs as $msg) {
44 if ($msg->detected_language === 'de') {
45 $de->addMessage($msg);
46 } else if ($msg->detected_language === 'en') {
47 $en->addMessage($msg);
48 } else if (is_null($msg->detected_language)) {
49 $de->addMessage($msg);
50 $en->addMessage($msg);