presseportale/resources/views/livewire/admin/reports/slow-requests.blade.php
Kevin Adametz a000238ca8 User Panel: Phase-8-Abschluss, Titelbild/Lizenzen/Zeitzonen und KI-Pruef-Pipeline
Phase 8 (Rest) + Umbauten vom 10./11.06.:
- Ein Titelbild pro PM (Cover 1280x580), SVG-Platzhalter-Set + Picker,
  PressReleaseCoverImage-Resolver
- Lizenz-/Rechteformular nach "Lizenztyp Bildupload" (7 Lizenztypen,
  Personen-/Sachrechte-Status, bedingte Pflichtfelder, Risikohinweise)
- Veroeffentlichungs-Box vereinfacht (Embargo aus der Form-UI entfernt),
  geplante Termine in Europe/Berlin (Speicherung UTC, DISPLAY_TIMEZONE)
- Quota-Stub (users.press_release_quota) + monatlicher Reset-Command
- Einreichungs-Modal einheitlich in Show/Create/Edit; Ghost-Buttons auf
  filled; PM-Editor-Layout responsive entkoppelt (.pr-editor-layout)

KI-Pruef-Pipeline (Phasen 1-5 des Entwicklungsplans):
- API-Haertung: status nicht mehr per API setzbar, eigene Submit-Route
  durch denselben Funnel (Blacklist, Quota, Status-Log)
- Klassifikation Rot/Gelb/Gruen asynchron (Queue classification,
  OpenAI-Treiber + deterministischer Fallback), ki_audits-Audit-Log
- Routing: Rot -> rejected + Mail, Gelb -> Review-Queue, Gruen ->
  Auto-Publish; Scheduler publiziert nur gruene faellige PMs
- Content-Score 0-100 -> Stufe (Standard/Geprueft/Hochwertig) inkl.
  Editor-Panel und Badges; Re-Klassifikation/-Score bei Aenderung
- Admin: KI-Badge + Filter, On-Demand-Pruefung mit Anbieter-Override

Suite: 442 passed, 4 skipped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 08:30:13 +00:00

280 lines
14 KiB
PHP

<?php
use App\Services\Admin\AdminSlowRequestReporter;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Title;
use Livewire\Volt\Component;
new #[Layout('components.layouts.app'), Title('Performance Reports')] class extends Component
{
public string $from = '';
public string $to = '';
public string $routeFilter = '';
public string $pathFilter = '';
public string $statusFilter = '';
public ?int $minDurationMs = null;
public int $limit = 25;
public function resetFilters(): void
{
$this->from = '';
$this->to = '';
$this->routeFilter = '';
$this->pathFilter = '';
$this->statusFilter = '';
$this->minDurationMs = null;
$this->limit = 25;
}
public function with(AdminSlowRequestReporter $reporter): array
{
return [
'report' => $reporter->report(
filters: [
'from' => $this->from !== '' ? $this->from : null,
'to' => $this->to !== '' ? $this->to : null,
'route' => $this->routeFilter !== '' ? $this->routeFilter : null,
'path' => $this->pathFilter !== '' ? $this->pathFilter : null,
'status' => $this->statusFilter !== '' ? (int) $this->statusFilter : null,
'min_duration_ms' => $this->minDurationMs,
],
top: 10,
limit: $this->limit,
),
];
}
}; ?>
<div class="space-y-8">
{{-- ============== PAGE HEADER ============== --}}
<header class="grid items-end gap-8" style="grid-template-columns:1fr auto;">
<div class="min-w-0">
<div class="flex items-center gap-3 mb-3 flex-nowrap whitespace-nowrap">
<span class="badge hub dot">{{ __('Admin Backend') }}</span>
<span class="eyebrow muted">{{ __('Administration · Reports') }}</span>
</div>
<h1 class="text-[30px] font-bold tracking-[-0.6px] leading-[1.15] m-0 text-[color:var(--color-ink)]">
{{ __('Performance Reports') }}
</h1>
<p class="text-[13px] leading-[1.55] mt-2 m-0 max-w-[640px] text-[color:var(--color-ink-2)]">
{{ __('Auswertung der Slow-Admin-Request-Logs aus dem admin_slow Log-Kanal.') }}
</p>
</div>
<div class="flex items-center gap-2 flex-shrink-0">
<span class="badge hub">{{ __('Logdateien') }}: {{ $report['summary']['files'] }}</span>
</div>
</header>
{{-- ============== FILTER-PANEL ============== --}}
<article class="panel">
<div class="panel-head">
<span class="section-eyebrow">{{ __('Filter') }}</span>
<flux:button size="sm" variant="filled" icon="arrow-path" wire:click="resetFilters">
{{ __('Filter zurücksetzen') }}
</flux:button>
</div>
<div class="p-5 space-y-4">
<div class="grid gap-4 md:grid-cols-2 xl:grid-cols-6">
<flux:field>
<flux:label>{{ __('Von') }}</flux:label>
<flux:input type="datetime-local" wire:model.live.debounce.500ms="from" />
</flux:field>
<flux:field>
<flux:label>{{ __('Bis') }}</flux:label>
<flux:input type="datetime-local" wire:model.live.debounce.500ms="to" />
</flux:field>
<flux:field>
<flux:label>{{ __('Route') }}</flux:label>
<flux:input wire:model.live.debounce.500ms="routeFilter" placeholder="admin.users" />
</flux:field>
<flux:field>
<flux:label>{{ __('Pfad') }}</flux:label>
<flux:input wire:model.live.debounce.500ms="pathFilter" placeholder="/admin/users" />
</flux:field>
<flux:field>
<flux:label>{{ __('Status') }}</flux:label>
<flux:select wire:model.live="statusFilter">
<option value="">{{ __('Alle') }}</option>
<option value="200">200</option>
<option value="302">302</option>
<option value="403">403</option>
<option value="422">422</option>
<option value="500">500</option>
</flux:select>
</flux:field>
<flux:field>
<flux:label>{{ __('Min. Dauer') }}</flux:label>
<flux:input type="number" min="0" wire:model.live.debounce.500ms="minDurationMs" placeholder="ms" />
</flux:field>
</div>
<div class="flex items-center justify-end gap-3 pt-2 border-t border-[color:var(--color-bg-rule)]">
<flux:field class="max-w-36">
<flux:label>{{ __('Detailzeilen') }}</flux:label>
<flux:select wire:model.live="limit">
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</flux:select>
</flux:field>
</div>
</div>
</article>
{{-- ============== KPI-Reihe ============== --}}
<section class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-4">
<x-portal.stat-card variant="primary" :label="__('Requests')" :value="number_format($report['summary']['total_requests'])">
<x-slot:meta>{{ __('im Sample') }}</x-slot:meta>
<x-slot:trend>{{ __('Slow-Log') }}</x-slot:trend>
</x-portal.stat-card>
<x-portal.stat-card variant="muted" :label="__('Ø Dauer')" :value="number_format($report['summary']['average_duration_ms'], 2, ',', '.').' ms'">
<x-slot:meta>{{ __('Mittelwert') }}</x-slot:meta>
<x-slot:trend>{{ __('alle Requests') }}</x-slot:trend>
</x-portal.stat-card>
<x-portal.stat-card variant="warn" :label="__('Max. Dauer')" :value="number_format($report['summary']['max_duration_ms']).' ms'">
<x-slot:meta>{{ __('Spitze') }}</x-slot:meta>
<x-slot:trend>{{ __('schlechtester Wert') }}</x-slot:trend>
</x-portal.stat-card>
<x-portal.stat-card variant="warn" :label="__('Max. Queries')" :value="number_format($report['summary']['max_query_count'])">
<x-slot:meta>{{ __('je Request') }}</x-slot:meta>
<x-slot:trend>{{ __('N+1-Indikator') }}</x-slot:trend>
</x-portal.stat-card>
</section>
<div class="grid gap-6 xl:grid-cols-2">
<article class="panel overflow-hidden">
<div class="panel-head">
<span class="section-eyebrow">{{ __('Top Routen') }}</span>
</div>
@include('livewire.admin.reports.slow-requests-table', ['rows' => $report['top_routes'], 'label' => __('Route')])
</article>
<article class="panel overflow-hidden">
<div class="panel-head">
<span class="section-eyebrow">{{ __('Top Pfade') }}</span>
</div>
@include('livewire.admin.reports.slow-requests-table', ['rows' => $report['top_paths'], 'label' => __('Pfad')])
</article>
</div>
<article class="panel overflow-hidden">
<div class="panel-head">
<span class="section-eyebrow">{{ __('Langsamste Requests') }}</span>
</div>
<flux:table>
<flux:table.columns>
<flux:table.column>{{ __('Zeit') }}</flux:table.column>
<flux:table.column>{{ __('Route') }}</flux:table.column>
<flux:table.column>{{ __('Pfad') }}</flux:table.column>
<flux:table.column>{{ __('Status') }}</flux:table.column>
<flux:table.column>{{ __('Dauer') }}</flux:table.column>
<flux:table.column>{{ __('DB') }}</flux:table.column>
<flux:table.column>{{ __('Queries') }}</flux:table.column>
</flux:table.columns>
<flux:table.rows>
@forelse ($report['slowest_requests'] as $entry)
<flux:table.row :key="$entry['timestamp'].'-'.$entry['route_name'].'-'.$entry['duration_ms']">
<flux:table.cell><span class="text-[12px] text-[color:var(--color-ink-3)] font-mono">{{ $entry['timestamp'] }}</span></flux:table.cell>
<flux:table.cell><span class="text-[12px] text-[color:var(--color-ink)] font-mono">{{ $entry['route_name'] }}</span></flux:table.cell>
<flux:table.cell><span class="text-[12px] text-[color:var(--color-ink-2)] font-mono">{{ $entry['path'] }}</span></flux:table.cell>
<flux:table.cell><span class="badge hub">{{ $entry['status_code'] }}</span></flux:table.cell>
<flux:table.cell><span class="text-[12.5px] font-semibold text-[color:var(--color-ink)] tabular-nums">{{ number_format($entry['duration_ms']) }} ms</span></flux:table.cell>
<flux:table.cell><span class="text-[12px] text-[color:var(--color-ink-2)] tabular-nums">{{ number_format($entry['database_time_ms'], 2, ',', '.') }} ms</span></flux:table.cell>
<flux:table.cell><span class="text-[12px] text-[color:var(--color-ink)] tabular-nums">{{ number_format($entry['query_count']) }}</span></flux:table.cell>
</flux:table.row>
@empty
<flux:table.row>
<flux:table.cell colspan="7">
<div class="py-8 text-center text-[12px] text-[color:var(--color-ink-3)]">{{ __('Keine Slow-Admin-Requests gefunden.') }}</div>
</flux:table.cell>
</flux:table.row>
@endforelse
</flux:table.rows>
</flux:table>
</article>
<article class="panel overflow-hidden">
<div class="panel-head">
<span class="section-eyebrow">{{ __('Häufige Slow Queries') }}</span>
</div>
<flux:table>
<flux:table.columns>
<flux:table.column>{{ __('SQL') }}</flux:table.column>
<flux:table.column>{{ __('Vorkommen') }}</flux:table.column>
<flux:table.column>{{ __('Ø Zeit') }}</flux:table.column>
<flux:table.column>{{ __('Max. Zeit') }}</flux:table.column>
</flux:table.columns>
<flux:table.rows>
@forelse ($report['slow_queries'] as $query)
<flux:table.row :key="md5($query['sql'])">
<flux:table.cell><span class="text-[12px] text-[color:var(--color-ink-2)] font-mono">{{ str($query['sql'])->limit(160) }}</span></flux:table.cell>
<flux:table.cell><span class="text-[12.5px] text-[color:var(--color-ink)] tabular-nums">{{ number_format($query['occurrences']) }}</span></flux:table.cell>
<flux:table.cell><span class="text-[12px] text-[color:var(--color-ink-2)] tabular-nums">{{ number_format($query['average_time_ms'], 2, ',', '.') }} ms</span></flux:table.cell>
<flux:table.cell><span class="text-[12px] text-[color:var(--color-ink-2)] tabular-nums">{{ number_format($query['max_time_ms'], 2, ',', '.') }} ms</span></flux:table.cell>
</flux:table.row>
@empty
<flux:table.row>
<flux:table.cell colspan="4">
<div class="py-8 text-center text-[12px] text-[color:var(--color-ink-3)]">{{ __('Keine einzelnen Slow Queries im Sample gefunden.') }}</div>
</flux:table.cell>
</flux:table.row>
@endforelse
</flux:table.rows>
</flux:table>
</article>
<article class="panel overflow-hidden">
<div class="panel-head">
<span class="section-eyebrow">{{ __('EXPLAIN Top Slow Queries') }}</span>
</div>
<div class="p-5 space-y-6">
@forelse ($report['explain_plans'] as $explain)
<div class="space-y-3">
<div class="text-[12px] text-[color:var(--color-ink-2)] font-mono">{{ str($explain['sql'])->limit(180) }}</div>
@if ($explain['error'])
<span class="badge warn dot">{{ $explain['error'] }}</span>
@elseif ($explain['plan'] === [])
<p class="text-[12px] text-[color:var(--color-ink-3)] m-0">{{ __('Kein Explain-Plan zurückgegeben.') }}</p>
@else
<div class="overflow-x-auto rounded-[5px] border border-[color:var(--color-bg-rule)]">
<table class="w-full text-left text-[11.5px]">
<thead class="border-b border-[color:var(--color-bg-rule)] bg-[color:var(--color-bg-elev)] text-[10.5px] uppercase tracking-[0.5px] text-[color:var(--color-ink-3)]">
<tr>
@foreach (array_keys($explain['plan'][0]) as $column)
<th class="px-3 py-2 font-semibold">{{ $column }}</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach ($explain['plan'] as $planRow)
<tr class="border-b border-[color:var(--color-bg-rule)] last:border-b-0">
@foreach ($planRow as $value)
<td class="px-3 py-2 font-mono text-[color:var(--color-ink-2)]">{{ is_scalar($value) || $value === null ? (string) $value : json_encode($value) }}</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
@empty
<div class="py-8 text-center text-[12px] text-[color:var(--color-ink-3)]">{{ __('Keine Slow Queries für EXPLAIN vorhanden.') }}</div>
@endforelse
</div>
</article>
</div>