make common methods optimization

This commit is contained in:
ghost 2023-10-09 20:04:52 +03:00
parent 8d258c677b
commit 285a5104e2
10 changed files with 91 additions and 201 deletions

View file

@ -21,23 +21,6 @@ class TorrentDownloadMagnetRepository extends ServiceEntityRepository
parent::__construct($registry, TorrentDownloadMagnet::class);
}
public function findTorrentDownloadMagnet(
int $torrentId,
int $userId
): ?TorrentDownloadMagnet
{
return $this->createQueryBuilder('tdm')
->where('tdm.torrentId = :torrentId')
->andWhere('tdm.userId = :userId')
->setParameter('torrentId', $torrentId)
->setParameter('userId', $userId)
->orderBy('tdm.id', 'DESC') // same to ts.added
->setMaxResults(1)
->getQuery()
->getOneOrNullResult()
;
}
public function findTorrentDownloadMagnetsTotalByTorrentId(
int $torrentId
): int