X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FConsole%2FCommands%2FChatlibDatabase.php;h=b95bb64a06a6dbec47b333c2c9248493e0c8492d;hb=a45648fa8ecf7712c7fd00eb2b93e862b5264f04;hp=cb7978f6e92bb84074c183354dc85f04766d1d36;hpb=f18af7cfb219ab9c07635ea8bbae80f2a9cee78e;p=alttp.git diff --git a/app/Console/Commands/ChatlibDatabase.php b/app/Console/Commands/ChatlibDatabase.php index cb7978f..b95bb64 100644 --- a/app/Console/Commands/ChatlibDatabase.php +++ b/app/Console/Commands/ChatlibDatabase.php @@ -28,22 +28,31 @@ class ChatlibDatabase extends Command { * @return int */ public function handle() { - $db = new ChatLib(); + $de = new ChatLib(); + $en = new ChatLib(); 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; }