presseportale/app/Console/Commands/ReportGrowth.php
Kevin Adametz b4870f98bb admin: Reports ▸ Wachstum mit den Abbruchbedingungen, Umami nur lesend angebunden
Roadmap 6.1/6.16: Block 1 bis 3 mit Ist, zeitanteiligem Soll, Schwelle und
Status, Trichter seit 17.09., Transparenzseiten aus Umami. Neue Befehle
growth:report und umami:report. Zugang über UMAMI_API_* (View-only-Benutzer).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:55:29 +00:00

74 lines
2.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Console\Commands;
use App\Services\Growth\GrowthReport;
use Illuminate\Console\Command;
/**
* Stand der Abbruchbedingungen für Block 1 bis 3 (Roadmap 6.1) — dieselben
* Zahlen wie Admin ▸ Reports ▸ Wachstum.
*/
class ReportGrowth extends Command
{
protected $signature = 'growth:report
{--fresh : Umami-Werte neu abfragen statt aus dem Zwischenspeicher}
{--json : Ausgabe als JSON statt als Tabelle}';
protected $description = 'Abbruchbedingungen der Wachstumsblöcke: Ist, Schwelle, Status.';
public function handle(GrowthReport $report): int
{
$data = $report->build((bool) $this->option('fresh'));
if ($this->option('json')) {
$this->line((string) json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
return self::SUCCESS;
}
$period = $data['period'];
$this->info(sprintf(
'Wachstum — Zeitraum %s bis %s, Zwischenblick %s, %d %% der Zeit vergangen',
$period['start']->format('d.m.Y'),
$period['end']->format('d.m.Y'),
$period['review']->format('d.m.Y'),
(int) round($period['elapsed_share'] * 100),
));
foreach ($data['blocks'] as $block) {
$this->newLine();
$this->line("<comment>{$block['title']}</comment>");
$this->table(
['Bedingung', 'Ist', 'Soll heute', 'Schwelle', 'Status'],
array_map(static fn (array $criterion): array => [
$criterion['label'],
$criterion['actual'] ?? '–',
$criterion['expected'] ?? '–',
$criterion['threshold'],
GrowthReport::statusLabel($criterion['status']),
], $block['criteria']),
);
foreach ($block['criteria'] as $criterion) {
if ($criterion['note'] !== null) {
$this->line(' '.$criterion['note']);
}
}
$this->line(' '.$block['consequence']);
}
if ($data['pages'] !== []) {
$this->newLine();
$this->line('<comment>Transparenzseiten, letzte 30 Tage (Umami)</comment>');
$this->table(
['Portal', 'Seite', 'Aufrufe', 'aus der Suche'],
array_map(static fn (array $row): array => [$row['brand'], $row['page'], $row['views'], $row['search_views']], $data['pages']),
);
}
return self::SUCCESS;
}
}