option('chunk')); $all = (bool) $this->option('all'); $query = PressRelease::query() ->withoutGlobalScope(PortalScope::class) ->withTrashed() ->select(['id', 'title', 'text', 'content_hash']) ->when(! $all, fn (Builder $q) => $q->whereNull('content_hash')); $total = (clone $query)->toBase()->getCountForPagination(); if ($total === 0) { $this->info('Alle Meldungen tragen eine Prüfsumme — nichts zu tun.'); return self::SUCCESS; } $this->info(sprintf('%s: %d Meldungen.', $all ? 'Neu berechnet' : 'Ergänzt', $total)); $bar = $this->output->createProgressBar($total); $done = 0; $query->chunkById($chunk, function ($releases) use (&$done, $bar): void { foreach ($releases as $release) { $hash = ContentFingerprint::hash($release->title, $release->text); if ($hash !== $release->content_hash) { DB::table('press_releases')->where('id', $release->id)->update(['content_hash' => $hash]); } } $done += $releases->count(); $bar->advance($releases->count()); }); $bar->finish(); $this->newLine(2); $this->info("Fertig: {$done} Meldungen geprüft."); return self::SUCCESS; } }