28 lines
959 B
PHP
28 lines
959 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Serp\Operations\SerpOperationsMetrics;
|
|
use Illuminate\Console\Command;
|
|
|
|
class SerpOperationsSnapshotCommand extends Command
|
|
{
|
|
protected $signature = 'serp:operations:snapshot {--window=24h} {--json}';
|
|
|
|
protected $description = 'Scrub edilmiş SERP operasyon özetini gösterir';
|
|
|
|
public function handle(SerpOperationsMetrics $metrics): int
|
|
{
|
|
if ($this->option('window') !== '24h') {
|
|
$this->error('Desteklenen pencere: 24h');
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$data = $metrics->summary() + ['window' => '24h', 'generated_at' => now('UTC')->toAtomString()];
|
|
$this->option('json') ? $this->line(json_encode($data, JSON_THROW_ON_ERROR)) : $this->table(['Alan', 'Değer'], collect($data)->except('budget')->map(fn ($v, $k) => [$k, is_scalar($v) || $v === null ? (string) $v : json_encode($v)])->values()->all());
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|