X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FConsole%2FCommands%2FChatlibDatabase.php;h=280d4a0c6351e29fd04a2ee0d31c4d0a68fe1712;hb=26d47ca368d8e7c2690cec49f6ae2ad509a0428d;hp=13c881a902a5589a8b31849c422dbf4259dbbf4a;hpb=771f1761f0abec996838c0ccc71cec0219bad71a;p=alttp.git diff --git a/app/Console/Commands/ChatlibDatabase.php b/app/Console/Commands/ChatlibDatabase.php index 13c881a..280d4a0 100644 --- a/app/Console/Commands/ChatlibDatabase.php +++ b/app/Console/Commands/ChatlibDatabase.php @@ -28,21 +28,33 @@ class ChatlibDatabase extends Command { * @return int */ public function handle() { - $db = new ChatLib(); + $de = new ChatLib(); + $en = new ChatLib(); - ChatLog::where('banned', '=', false) + ChatLog::where('type', '=', 'chat') + ->where('banned', '=', false) ->whereNotNull('evaluated_at') - ->chunk(500, function ($msgs) use ($db) { + ->where('created_at', '<', now()->sub(7, 'day')) + ->whereNotIn('classification', ['gg', 'gl', 'number', 'o7']) + ->whereRaw('LENGTH(`text_content`) > 12') + ->chunk(5000, function ($msgs) use ($de, $en) { foreach ($msgs as $msg) { - $db->addMessage($msg); + if ($msg->detected_language === 'de') { + $de->addMessage($msg); + } else if ($msg->detected_language === 'en') { + $en->addMessage($msg); + } else if (is_null($msg->detected_language)) { + $de->addMessage($msg); + $en->addMessage($msg); + } } }); - $db->compile(); + $de->compile(); + $de->saveAs('de'); - for ($i = 0; $i < 50; ++$i) { - $this->line($db->generate()); - } + $en->compile(); + $en->saveAs('en'); return 0; }