doConnect() !== true) { $this->error('❌ Unable to connect to usenet server'); return Command::FAILURE; } $this->info('📡 Getting first/last for all active groups...'); try { $data = $nntp->getGroups(); if ($nntp->isError($data)) { $this->error('❌ Failed to getGroups() from NNTP server'); return Command::FAILURE; } $this->info('🔄 Updating short_groups table...'); // Truncate and rebuild DB::statement('TRUNCATE TABLE short_groups'); // Get all active groups $activeGroups = Arr::pluck( UsenetGroup::query() ->where('active', '=', 1) ->orWhere('backfill', '=', 1) ->get(['name']), 'name' ); $updated = 0; $bar = $this->output->createProgressBar(count($data)); $bar->start(); foreach ($data as $newgroup) { if (\in_array($newgroup['group'], $activeGroups, false)) { ShortGroup::query()->insert([ 'name' => $newgroup['group'], 'first_record' => $newgroup['first'], 'last_record' => $newgroup['last'], 'updated' => now(), ]); $updated++; } $bar->advance(); } $bar->finish(); $this->newLine(2); $elapsed = now()->diffInSeconds($start, true); $this->info("✅ Updated {$updated} groups"); $this->info("⏱️ Running time: {$elapsed} seconds"); return Command::SUCCESS; } catch (\Exception $e) { $this->error('❌ Update failed: '.$e->getMessage()); return Command::FAILURE; } } }