perf: optimize statistics exports - cache task history and slim down Livewire payload
- Cache getTaskHistoryProperty() with 30s TTL to avoid Proxmox API calls on every render - Move networkAnalysis heavy arrays (connections, topConnections, topPorts) out of Livewire public property into server-side cache only - Store only counts and metadata in the Livewire payload instead of thousands of connection objects - Pagination and export methods now read from cache instead of public property - Reduce wire:poll intervals from 10s to 30s on task history and lifecycle events cards - Dramatically reduces JSON payload size on every Livewire request
This commit is contained in:
@@ -1081,7 +1081,7 @@
|
||||
@php
|
||||
$taskHistoryExportRows = [];
|
||||
@endphp
|
||||
<div class="bg-background-secondary border border-neutral rounded-xl overflow-hidden" wire:poll.10s="$refresh" id="task-history-card">
|
||||
<div class="bg-background-secondary border border-neutral rounded-xl overflow-hidden" wire:poll.30s="$refresh" id="task-history-card">
|
||||
<div class="p-6 border-b border-neutral flex items-center justify-between gap-3">
|
||||
<h2 class="text-lg font-semibold flex items-center gap-2">
|
||||
<x-ri-task-line class="size-5" />
|
||||
@@ -1576,7 +1576,7 @@
|
||||
@php
|
||||
$lifecycleEventsExportRows = [];
|
||||
@endphp
|
||||
<div class="bg-background-secondary border border-neutral rounded-xl overflow-hidden" wire:poll.10s="$refresh" id="lifecycle-events-card">
|
||||
<div class="bg-background-secondary border border-neutral rounded-xl overflow-hidden" wire:poll.30s="$refresh" id="lifecycle-events-card">
|
||||
<div class="p-6 border-b border-neutral flex items-center justify-between gap-3">
|
||||
<h2 class="text-lg font-semibold flex items-center gap-2">
|
||||
<x-ri-shut-down-line class="size-5" />
|
||||
@@ -2462,7 +2462,7 @@
|
||||
@else
|
||||
<div style="width: 100%; min-width: 100%; display: flex; flex-direction: column; box-sizing: border-box;">
|
||||
<div x-show="tab === 'connections'" style="width: 100%; min-width: 100%; flex-shrink: 0; box-sizing: border-box;">
|
||||
@if(empty($networkAnalysis['connections']))
|
||||
@if(($networkAnalysis['connectionCount'] ?? 0) == 0)
|
||||
<div class="text-center py-6 text-sm text-base/60">No matching connections tracked for this server.</div>
|
||||
@else
|
||||
<div x-data="tableFilterSort('network-connections-table')" style="width: 100%;">
|
||||
@@ -2928,7 +2928,7 @@
|
||||
</div>
|
||||
|
||||
{{-- Connections Pagination Controls --}}
|
||||
@if(count($networkAnalysis['connections']) > 0)
|
||||
@if(($networkAnalysis['connectionCount'] ?? 0) > 0)
|
||||
<div class="p-4 border-t border-neutral flex flex-col sm:flex-row items-center justify-between gap-4">
|
||||
{{-- Records per page selector --}}
|
||||
<div class="flex items-center gap-3">
|
||||
@@ -2946,7 +2946,7 @@
|
||||
{{-- Page info and navigation --}}
|
||||
<div class="flex items-center gap-4">
|
||||
<span class="text-sm text-base/60">
|
||||
Showing {{ (($connectionsCurrentPage - 1) * $connectionsPerPage) + 1 }} - {{ min($connectionsCurrentPage * $connectionsPerPage, count($networkAnalysis['connections'])) }} of {{ count($networkAnalysis['connections']) }} connections
|
||||
Showing {{ (($connectionsCurrentPage - 1) * $connectionsPerPage) + 1 }} - {{ min($connectionsCurrentPage * $connectionsPerPage, $networkAnalysis['connectionCount'] ?? 0) }} of {{ $networkAnalysis['connectionCount'] ?? 0 }} connections
|
||||
</span>
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
@@ -3023,7 +3023,7 @@
|
||||
</div>
|
||||
|
||||
<div x-show="tab === 'top-connections'" style="width: 100%; min-width: 100%; flex-shrink: 0; box-sizing: border-box;">
|
||||
@if(empty($networkAnalysis['topConnections']))
|
||||
@if(($networkAnalysis['topConnectionCount'] ?? 0) == 0)
|
||||
<div class="text-center py-6 text-sm text-base/60">No connection data available.</div>
|
||||
@else
|
||||
<div x-data="tableFilterSort('top-peers-table')" style="width: 100%;">
|
||||
@@ -3251,7 +3251,7 @@
|
||||
</div>
|
||||
|
||||
{{-- Top Connections Pagination Controls --}}
|
||||
@if(count($networkAnalysis['topConnections']) > 0)
|
||||
@if(($networkAnalysis['topConnectionCount'] ?? 0) > 0)
|
||||
<div class="p-4 border-t border-neutral flex flex-col sm:flex-row items-center justify-between gap-4">
|
||||
{{-- Records per page selector --}}
|
||||
<div class="flex items-center gap-3">
|
||||
@@ -3269,7 +3269,7 @@
|
||||
{{-- Page info and navigation --}}
|
||||
<div class="flex items-center gap-4">
|
||||
<span class="text-sm text-base/60">
|
||||
Showing {{ (($topConnectionsCurrentPage - 1) * $topConnectionsPerPage) + 1 }} - {{ min($topConnectionsCurrentPage * $topConnectionsPerPage, count($networkAnalysis['topConnections'])) }} of {{ count($networkAnalysis['topConnections']) }} peers
|
||||
Showing {{ (($topConnectionsCurrentPage - 1) * $topConnectionsPerPage) + 1 }} - {{ min($topConnectionsCurrentPage * $topConnectionsPerPage, $networkAnalysis['topConnectionCount'] ?? 0) }} of {{ $networkAnalysis['topConnectionCount'] ?? 0 }} peers
|
||||
</span>
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
@@ -3346,7 +3346,7 @@
|
||||
</div>
|
||||
|
||||
<div x-show="tab === 'ports'" style="width: 100%; min-width: 100%; flex-shrink: 0; box-sizing: border-box;">
|
||||
@if(empty($networkAnalysis['topPorts']))
|
||||
@if(($networkAnalysis['topPortCount'] ?? 0) == 0)
|
||||
<div class="text-center py-6 text-sm text-base/60">No port statistics are available.</div>
|
||||
@else
|
||||
<div x-data="tableFilterSort('top-ports-table')" style="width: 100%;">
|
||||
@@ -3464,7 +3464,7 @@
|
||||
</div>
|
||||
|
||||
{{-- Top Ports Pagination Controls --}}
|
||||
@if(count($networkAnalysis['topPorts']) > 0)
|
||||
@if(($networkAnalysis['topPortCount'] ?? 0) > 0)
|
||||
<div class="p-4 border-t border-neutral flex flex-col sm:flex-row items-center justify-between gap-4">
|
||||
{{-- Records per page selector --}}
|
||||
<div class="flex items-center gap-3">
|
||||
@@ -3482,7 +3482,7 @@
|
||||
{{-- Page info and navigation --}}
|
||||
<div class="flex items-center gap-4">
|
||||
<span class="text-sm text-base/60">
|
||||
Showing {{ (($topPortsCurrentPage - 1) * $topPortsPerPage) + 1 }} - {{ min($topPortsCurrentPage * $topPortsPerPage, count($networkAnalysis['topPorts'])) }} of {{ count($networkAnalysis['topPorts']) }} ports
|
||||
Showing {{ (($topPortsCurrentPage - 1) * $topPortsPerPage) + 1 }} - {{ min($topPortsCurrentPage * $topPortsPerPage, $networkAnalysis['topPortCount'] ?? 0) }} of {{ $networkAnalysis['topPortCount'] ?? 0 }} ports
|
||||
</span>
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
|
||||
Reference in New Issue
Block a user