|
@@ -158,4 +158,30 @@ class FilmRepository extends ServiceEntityRepository
|
|
|
->getResult()
|
|
|
;
|
|
|
}
|
|
|
+
|
|
|
+ public function nbFilmSeenBy(int $userId)
|
|
|
+ {
|
|
|
+ $qb = $this->createQueryBuilder('f');
|
|
|
+ return $qb
|
|
|
+ ->leftJoin('f.usersWantToView', 'wan')
|
|
|
+ ->where($qb->expr()->in('wan', ':user'))
|
|
|
+ ->setParameter('user', $userId)
|
|
|
+ ->select('COUNT(f.id)')
|
|
|
+ ->getQuery()
|
|
|
+ ->getSingleScalarResult()
|
|
|
+ ;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function nbFilmToSeeBy(int $userId)
|
|
|
+ {
|
|
|
+ $qb = $this->createQueryBuilder('f');
|
|
|
+ return $qb
|
|
|
+ ->leftJoin('f.usersWhoSeen', 'wan')
|
|
|
+ ->where($qb->expr()->in('wan', ':user'))
|
|
|
+ ->setParameter('user', $userId)
|
|
|
+ ->select('COUNT(f.id)')
|
|
|
+ ->getQuery()
|
|
|
+ ->getSingleScalarResult()
|
|
|
+ ;
|
|
|
+ }
|
|
|
}
|