mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-01-31 08:19:49 -06:00
add: torrent health counts to torrent search
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -715,6 +715,13 @@
|
||||
<header class="panel__header">
|
||||
<h2 class="panel__heading">{{ __('torrent.torrents') }}</h2>
|
||||
<div class="panel__actions">
|
||||
<div class="panel__action">
|
||||
<span class="panel__action-text">
|
||||
{{ __('common.total') }}: {{ $torrents->total }} |
|
||||
{{ __('common.alive') }}: {{ $torrents->alive }} |
|
||||
{{ __('common.dead') }}: {{ $torrents->dead }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="panel__action">
|
||||
<div class="form__group">
|
||||
<select id="view" class="form__select" wire:model.live="view" required>
|
||||
|
||||
Reference in New Issue
Block a user