Full UniFi dashboard snap-in including: - WiFi/client/device stats with time-series snapshots - Client Dashboard with traffic, satisfaction, signal, download charts - Webhook alerting with debounced offline/online detection - AP snapshot collection, client snapshot collection - Device classification (type and OS) from OUI/hostname heuristics - Webhook cooldown, templates, and multi-platform delivery Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
31 lines
995 B
PHP
31 lines
995 B
PHP
<?php
|
|
|
|
namespace Dashboard\Unifi\Console;
|
|
|
|
use App\Models\Setting;
|
|
use Dashboard\Unifi\Models\ApSnapshot;
|
|
use Dashboard\Unifi\Models\ClientSnapshot;
|
|
use Dashboard\Unifi\Models\WebhookLog;
|
|
use Illuminate\Console\Command;
|
|
|
|
class CleanupSnapshots extends Command
|
|
{
|
|
protected $signature = 'unifi:cleanup';
|
|
protected $description = 'Remove old AP snapshots and webhook logs based on retention setting';
|
|
|
|
public function handle(): int
|
|
{
|
|
$days = (int) Setting::get('unifi.retention_days', 30);
|
|
|
|
$cutoff = now()->subDays($days);
|
|
|
|
$snapshots = ApSnapshot::where('captured_at', '<', $cutoff)->delete();
|
|
$clientSnapshots = ClientSnapshot::where('captured_at', '<', $cutoff)->delete();
|
|
$webhookLogs = WebhookLog::where('fired_at', '<', $cutoff)->delete();
|
|
|
|
$this->info("Cleaned up: {$snapshots} AP snapshots, {$clientSnapshots} client snapshots, {$webhookLogs} webhook logs older than {$days} days.");
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|