Skip to content

Commit

Permalink
Merge pull request #3337 from Roardom/enforce-max-perpage
Browse files Browse the repository at this point in the history
(Update) Enforce max torrents per page
  • Loading branch information
HDVinnie committed Jan 2, 2024
2 parents d64d87b + 5fd8ac8 commit e51d3a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/API/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public function filter(Request $request): TorrentsResource|\Illuminate\Http\Json
->when($request->filled('episodeNumber'), fn ($query) => $query->ofEpisode((int) $request->episodeNumber))
->latest('sticky')
->orderBy($request->input('sortField') ?? $this->sortField, $request->input('sortDirection') ?? $this->sortDirection)
->cursorPaginate($request->input('perPage') ?? $this->perPage);
->cursorPaginate(min($request->input('perPage') ?? $this->perPage, 100));

$movieIds = $torrents->getCollection()->where('meta', '=', 'movie')->pluck('tmdb');
$tvIds = $torrents->getCollection()->where('meta', '=', 'tv')->pluck('tmdb');
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Livewire/TorrentSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ final public function getTorrentsProperty(): \Illuminate\Contracts\Pagination\Le
->where($this->filters())
->latest('sticky')
->orderBy($this->sortField, $this->sortDirection)
->paginate($this->perPage);
->paginate(min($this->perPage, 100));

$movieIds = $torrents->getCollection()->where('meta', '=', 'movie')->pluck('tmdb');
$tvIds = $torrents->getCollection()->where('meta', '=', 'tv')->pluck('tmdb');
Expand Down Expand Up @@ -362,7 +362,7 @@ final public function getGroupedTorrentsProperty()
->groupBy('tmdb', 'meta')
->latest('sticky')
->orderBy($this->sortField, $this->sortDirection)
->paginate($this->perPage);
->paginate(min($this->perPage, 100));

$movieIds = $groups->getCollection()->where('meta', '=', 'movie')->pluck('tmdb');
$tvIds = $groups->getCollection()->where('meta', '=', 'tv')->pluck('tmdb');
Expand Down Expand Up @@ -602,7 +602,7 @@ final public function getGroupedPostersProperty()
->groupBy('tmdb', 'meta')
->latest('sticky')
->orderBy($this->sortField, $this->sortDirection)
->paginate($this->perPage);
->paginate(min($this->perPage, 100));

$movieIds = $groups->getCollection()->where('meta', '=', 'movie')->pluck('tmdb');
$tvIds = $groups->getCollection()->where('meta', '=', 'tv')->pluck('tmdb');
Expand Down

0 comments on commit e51d3a3

Please sign in to comment.