diff --git a/app/Http/Livewire/TorrentSearch.php b/app/Http/Livewire/TorrentSearch.php index ac9d9050e..0edde35fd 100644 --- a/app/Http/Livewire/TorrentSearch.php +++ b/app/Http/Livewire/TorrentSearch.php @@ -37,6 +37,7 @@ use Livewire\Component; use Livewire\WithPagination; use Illuminate\Pagination\LengthAwarePaginator; use Meilisearch\Client; +use Illuminate\Support\Facades\DB; class TorrentSearch extends Component { @@ -230,6 +231,20 @@ class TorrentSearch extends Component #[Url(except: 'list')] public string $view = 'list'; + /** + * Get torrent health statistics. + */ + #[Computed(seconds: 3600, cache: true)] + final public function torrentHealth(): object + { + return DB::table('torrents') + ->whereNull('deleted_at') + ->selectRaw('COUNT(*) AS total') + ->selectRaw('SUM(seeders > 0) AS alive') + ->selectRaw('SUM(seeders = 0) AS dead') + ->first(); + } + final public function mount(Request $request): void { if ($request->missing('sortField')) { @@ -899,6 +914,7 @@ class TorrentSearch extends Component 'poster' => $this->groupedPosters, default => $this->torrents, }, + 'torrentHealth' => $this->torrentHealth, ]); } } diff --git a/lang/en/common.php b/lang/en/common.php index 5b34cf13a..8cd735918 100644 --- a/lang/en/common.php +++ b/lang/en/common.php @@ -30,6 +30,7 @@ return [ 'active-warning' => 'Active Warning', 'add' => 'Add', 'added' => 'Added', + 'alive' => 'Alive', 'amount' => 'Amount', 'and' => 'and', 'anonymous' => 'Anonymous', @@ -64,6 +65,7 @@ return [ 'created_at' => 'Created at', 'date' => 'Date', 'day' => 'Day', + 'dead' => 'Dead', 'delete' => 'Delete', 'delete-your-comment' => 'Delete your Comment', 'description' => 'Description', @@ -215,6 +217,7 @@ return [ 'top-bountied' => 'Top Bountied', 'top-10' => 'Top 10', 'topics' => 'Topics', + 'total' => 'Total', 'tracker-codes' => 'Tracker Codes', 'type' => 'Type', 'type-verb' => 'Type', diff --git a/resources/views/livewire/torrent-search.blade.php b/resources/views/livewire/torrent-search.blade.php index 27413e88b..88c03799a 100644 --- a/resources/views/livewire/torrent-search.blade.php +++ b/resources/views/livewire/torrent-search.blade.php @@ -715,6 +715,13 @@

{{ __('torrent.torrents') }}

+
+ + {{ __('common.total') }}: {{ $torrents->total }} | + {{ __('common.alive') }}: {{ $torrents->alive }} | + {{ __('common.dead') }}: {{ $torrents->dead }} + +