diff --git a/app/DTO/TorrentSearchFiltersDTO.php b/app/DTO/TorrentSearchFiltersDTO.php index c49d096965..88750edb3d 100644 --- a/app/DTO/TorrentSearchFiltersDTO.php +++ b/app/DTO/TorrentSearchFiltersDTO.php @@ -308,7 +308,14 @@ final public function toSqlQueryBuilder(): Closure ->when( config('other.freeleech'), fn ($query) => $query->whereBetween('free', [0, 100]), - fn ($query) => $query->whereIntegerInRaw('free', (array) $this->free) + fn ($query) => $query->where( + fn ($query) => $query + ->whereIntegerInRaw('free', (array) $this->free) + ->when( + \in_array(100, $this->free, false), + fn ($query) => $query->orWhere('featured', '=', true) + ) + ) ) ) ->when($this->filename !== '', fn ($query) => $query->whereRelation('files', 'name', '=', $this->filename)) @@ -335,7 +342,14 @@ final public function toSqlQueryBuilder(): Closure ) ) ) - ->when($this->doubleup, fn ($query) => $query->where('doubleup', '=', 1)) + ->when( + $this->doubleup, + fn ($query) => $query->where( + fn ($query) => $query + ->where('doubleup', '=', 1) + ->orWhere('featured', '=', 1) + ) + ) ->when($this->featured, fn ($query) => $query->where('featured', '=', 1)) ->when($this->refundable, fn ($query) => $query->where('refundable', '=', true)) ->when($this->stream, fn ($query) => $query->where('stream', '=', 1)) @@ -542,12 +556,22 @@ final public function toMeilisearchFilter(): array if ($this->free !== []) { if (!config('other.freeleech')) { - $filters[] = 'free IN '.json_encode(array_map('intval', $this->free)); + if (\in_array(100, $this->free, false)) { + $filters[] = [ + 'free IN '.json_encode(array_map('intval', $this->free)), + 'featured = true', + ]; + } else { + $filters[] = 'free IN '.json_encode(array_map('intval', $this->free)); + } } } if ($this->doubleup) { - $filters[] = 'doubleup = true'; + $filters[] = [ + 'doubleup = true', + 'featured = true', + ]; } if ($this->featured) {