doConnect() !== true) { exit(ColorCLI::error('Unable to connect to usenet.')); } ColorCLI::doEcho(ColorCLI::header('Getting first/last for all your active groups.')); $data = $nntp->getGroups(); if ($nntp->isError($data)) { exit(ColorCLI::error('Failed to getGroups() from nntp server.')); } ColorCLI::doEcho(ColorCLI::header('Inserting new values into short_groups table.')); DB::unprepared('TRUNCATE TABLE short_groups'); DB::commit(); // Put into an array all active groups $result = array_pluck(Group::query()->where('active', '=', 1)->orWhere('backfill', '=', 1)->get(['name']), 'name'); foreach ($data as $newgroup) { if (\in_array($newgroup['group'], $result, false)) { ShortGroup::query()->insert([ 'name' => $newgroup['group'], 'first_record' => $newgroup['first'], 'last_record' => $newgroup['last'], 'updated' => now(), ]); ColorCLI::doEcho(ColorCLI::primary('Updated '.$newgroup['group'])); } } ColorCLI::doEcho(ColorCLI::header('Running time: '.$consoleTools->convertTimer(time() - $start)));