X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FConsole%2FCommands%2FChatlibDatabase.php;h=bfe0135c4b8e00e684a9f2974faf862f447296fd;hb=c2cc99020eee56f7790d1358abb44df078f2e655;hp=13c881a902a5589a8b31849c422dbf4259dbbf4a;hpb=771f1761f0abec996838c0ccc71cec0219bad71a;p=alttp.git diff --git a/app/Console/Commands/ChatlibDatabase.php b/app/Console/Commands/ChatlibDatabase.php index 13c881a..bfe0135 100644 --- a/app/Console/Commands/ChatlibDatabase.php +++ b/app/Console/Commands/ChatlibDatabase.php @@ -28,20 +28,35 @@ 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) { + ->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(); + $en->compile(); + $this->line(''); for ($i = 0; $i < 50; ++$i) { - $this->line($db->generate()); + $this->line($de->generate()); + } + $this->line(''); + for ($i = 0; $i < 50; ++$i) { + $this->line($en->generate()); } return 0;