implement bookmarks total counter

This commit is contained in:
ghost 2023-10-08 20:37:50 +03:00
parent 3d74818303
commit 5b0a7bcb69
5 changed files with 62 additions and 52 deletions

View file

@ -21,7 +21,7 @@ class TorrentBookmarkRepository extends ServiceEntityRepository
parent::__construct($registry, TorrentBookmark::class);
}
public function findUserLastTorrentBookmark(
public function findTorrentBookmark(
int $torrentId,
int $userId
): ?TorrentBookmark
@ -37,4 +37,17 @@ class TorrentBookmarkRepository extends ServiceEntityRepository
->getOneOrNullResult()
;
}
public function findTorrentBookmarksTotalByTorrentId(
int $torrentId
): int
{
return $this->createQueryBuilder('tb')
->select('count(tb.id)')
->where('tb.torrentId = :torrentId')
->setParameter('torrentId', $torrentId)
->getQuery()
->getSingleScalarResult()
;
}
}