<?php

namespace App\Filament\Widgets;

use App\Models\Order;
use App\Models\Scan;
use App\Models\Tag;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class StatsOverview extends BaseWidget
{
    protected function getStats(): array
    {
        return [
            Stat::make("Tags", Tag::count())
                ->description(Tag::where("status", "unset")->count() . " unset · " .
                    Tag::where("status", "active")->count() . " active · " .
                    Tag::where("status", "suspended")->count() . " suspended"),
            Stat::make("Scans (24h)", Scan::where("scanned_at", ">", now()->subDay())->count()),
            Stat::make("Alerts sent (24h)", Scan::where("alert_sent", true)->where("scanned_at", ">", now()->subDay())->count()),
            Stat::make("Lapsed orders", Order::where("status", "lapsed")->count()),
        ];
    }
}
