X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FConsole%2FCommands%2FChatlibDatabase.php;h=b95bb64a06a6dbec47b333c2c9248493e0c8492d;hb=64f5be008ef28c812cb7ed87149f4eb86f6021eb;hp=13c881a902a5589a8b31849c422dbf4259dbbf4a;hpb=771f1761f0abec996838c0ccc71cec0219bad71a;p=alttp.git diff --git a/app/Console/Commands/ChatlibDatabase.php b/app/Console/Commands/ChatlibDatabase.php index 13c881a..b95bb64 100644 --- a/app/Console/Commands/ChatlibDatabase.php +++ b/app/Console/Commands/ChatlibDatabase.php @@ -28,21 +28,31 @@ 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')) + ->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; }