Skip to content

Commit

Permalink
Merge pull request #4259 from Roardom/torrent-trump-search
Browse files Browse the repository at this point in the history
(Fix) Add torrent trump filtering to meilisearch search
  • Loading branch information
HDVinnie authored Oct 21, 2024
2 parents af6dc92 + 3c7d94d commit c1c8288
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/DTO/TorrentSearchFiltersDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ final public function toMeilisearchFilter(): array
$filters[] = 'internal = true';
}

if ($this->trumpable) {
$filters[] = 'trumpable = true';
}

if ($this->personalRelease) {
$filters[] = 'personal_release = true';
}
Expand Down
7 changes: 7 additions & 0 deletions app/Models/Torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ protected function casts(): array
)
LIMIT 1
) AS rating,
EXISTS(
SELECT *
FROM torrent_trumps
WHERE torrents.id = torrent_trumps.torrent_id
) AS trumpable,
(
SELECT JSON_OBJECT(
'id', movies.id,
Expand Down Expand Up @@ -857,6 +862,7 @@ public function toSearchableArray(): array
'region_id',
'personal_release',
'info_hash',
'trumpable',
'rating',
'json_user',
'json_type',
Expand Down Expand Up @@ -929,6 +935,7 @@ public function toSearchableArray(): array
'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) */
'trumpable' => (bool) $torrent->trumpable, /** @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'),
Expand Down
1 change: 1 addition & 0 deletions config/scout.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
'internal',
'deleted_at',
'personal_release',
'trumpable',
'info_hash',
'history_seeders.user_id',
'history_leechers.user_id',
Expand Down

0 comments on commit c1c8288

Please sign in to comment.