diff --git a/app/Http/Livewire/TorrentSearch.php b/app/Http/Livewire/TorrentSearch.php index ba6b5fc578..62d59cdd3f 100644 --- a/app/Http/Livewire/TorrentSearch.php +++ b/app/Http/Livewire/TorrentSearch.php @@ -423,6 +423,7 @@ final public function torrents(): \Illuminate\Contracts\Pagination\LengthAwarePa // Whitelist which columns are allowed to be ordered by if (!\in_array($this->sortField, [ 'name', + 'rating', 'size', 'seeders', 'leechers', diff --git a/app/Models/Torrent.php b/app/Models/Torrent.php index 903f8683a0..2c7506be74 100644 --- a/app/Models/Torrent.php +++ b/app/Models/Torrent.php @@ -282,6 +282,28 @@ protected function casts(): array WHERE torrents.resolution_id = resolutions.id LIMIT 1 ) AS json_resolution, + ( + SELECT vote_average + FROM movies + WHERE + torrents.tmdb = movies.id + AND torrents.category_id in ( + SELECT id + FROM categories + WHERE movie_meta = 1 + ) + UNION + SELECT vote_average + FROM tv + WHERE + torrents.tmdb = tv.id + AND torrents.category_id in ( + SELECT id + FROM categories + WHERE tv_meta = 1 + ) + LIMIT 1 + ) AS rating, ( SELECT JSON_OBJECT( 'id', movies.id, @@ -290,6 +312,7 @@ protected function casts(): array 'poster', movies.poster, 'original_language', movies.original_language, 'adult', movies.adult != 0, + 'rating', movies.vote_average, 'companies', ( SELECT COALESCE(JSON_ARRAYAGG(JSON_OBJECT( 'id', companies.id, @@ -344,6 +367,7 @@ protected function casts(): array 'year', YEAR(tv.first_air_date), 'poster', tv.poster, 'original_language', tv.original_language, + 'rating', tv.vote_average, 'companies', ( SELECT COALESCE(JSON_ARRAYAGG(JSON_OBJECT( 'id', companies.id, @@ -831,6 +855,7 @@ public function toSearchableArray(): array 'region_id', 'personal_release', 'info_hash', + 'rating', 'json_user', 'json_type', 'json_category', @@ -901,6 +926,7 @@ public function toSearchableArray(): array 'region_id' => $torrent->region_id, 'personal_release' => (bool) $torrent->personal_release, 'info_hash' => bin2hex($torrent->info_hash), + 'rating' => (float) $torrent->rating, /** @phpstan-ignore property.notFound (This property is selected in the query but doesn't exist on the model) */ 'user' => json_decode($torrent->json_user ?? 'null'), 'type' => json_decode($torrent->json_type ?? 'null'), 'category' => json_decode($torrent->json_category ?? 'null'), diff --git a/config/scout.php b/config/scout.php index 2854824810..71eb199f51 100644 --- a/config/scout.php +++ b/config/scout.php @@ -218,6 +218,7 @@ ], 'sortableAttributes' => [ 'name', + 'rating', 'size', 'seeders', 'leechers', diff --git a/resources/sass/pages/_torrents.scss b/resources/sass/pages/_torrents.scss index 6734d285ca..ac9e277b14 100644 --- a/resources/sass/pages/_torrents.scss +++ b/resources/sass/pages/_torrents.scss @@ -124,7 +124,7 @@ .torrent-search--list__row { display: grid; grid-template-rows: auto; - grid-template-columns: 60px 100px 1fr 150px 60px 100px 50px 50px 50px 120px; + grid-template-columns: 60px 100px 1fr 150px 68px 100px 50px 50px 50px 120px; grid-template-areas: 'poster format overview buttons rating size seeders leechers completed age'; } @@ -132,7 +132,7 @@ .torrent-search--list__no-poster-row { display: grid; grid-template-rows: auto; - grid-template-columns: 100px 1fr 150px 60px 100px 50px 50px 50px 120px; + grid-template-columns: 100px 1fr 150px 68px 100px 50px 50px 50px 120px; grid-template-areas: 'format overview buttons rating size seeders leechers completed age'; } @@ -292,6 +292,7 @@ } .torrent-search--list__name-header, + .torrent-search--list__ratings-header, .torrent-search--list__size-header, .torrent-search--list__seeders-header, .torrent-search--list__leechers-header, @@ -302,8 +303,7 @@ .torrent-search--list__poster-header, .torrent-search--list__format-header, - .torrent-search--list__actions-header, - .torrent-search--list__ratings-header { + .torrent-search--list__actions-header { display: none; } diff --git a/resources/views/livewire/torrent-search.blade.php b/resources/views/livewire/torrent-search.blade.php index 5c53053f0b..c1a62b7ce4 100644 --- a/resources/views/livewire/torrent-search.blade.php +++ b/resources/views/livewire/torrent-search.blade.php @@ -836,7 +836,14 @@ class="torrent-search--list__name-header" {{ __('common.actions') }} - Rating + + Rating + @include('livewire.includes._sort-icon', ['field' => 'rating']) +