Merge pull request #3125 from Roardom/fix-extra-movie-api-call

(Fix) Redundant movie db query for tv api calls
This commit is contained in:
HDVinnie
2023-09-09 20:39:37 -04:00
committed by GitHub
2 changed files with 4 additions and 3 deletions
@@ -459,11 +459,11 @@ class TorrentController extends BaseController
$torrents = $torrents->through(function ($torrent) use ($movies, $tv) {
switch ($torrent->meta) {
case 'movie':
$torrent->setRelation('movie', $movies[$torrent->tmdb] ?? collect());
$torrent->setRelation('work', $movies[$torrent->tmdb] ?? collect());
break;
case 'tv':
$torrent->setRelation('tv', $tv[$torrent->tmdb] ?? collect());
$torrent->setRelation('work', $tv[$torrent->tmdb] ?? collect());
break;
}
+2 -1
View File
@@ -25,7 +25,8 @@ class TorrentResource extends JsonResource
*/
public function toArray($request): array
{
$meta = $this->movie ?? $this->tv;
/** @phpstan-ignore-next-line */
$meta = $this->work;
return [
'type' => 'torrent',