diff --git a/src/CoreBundle/Command/UpdateSessionStatusCommand.php b/src/CoreBundle/Command/UpdateSessionStatusCommand.php index afe0f969a7..26104f7ab3 100644 --- a/src/CoreBundle/Command/UpdateSessionStatusCommand.php +++ b/src/CoreBundle/Command/UpdateSessionStatusCommand.php @@ -50,9 +50,9 @@ class UpdateSessionStatusCommand extends Command $id = $session->getId(); $start = $session->getDisplayStartDate(); $end = $session->getDisplayEndDate(); - $userCount = $this->sessionRepository->countUsersBySession($session->getId()); + $studentCount = $this->sessionRepository->countUsersBySession($session->getId()); - $status = $this->determineSessionStatus($start, $end, $userCount, $now); + $status = $this->determineSessionStatus($start, $end, $studentCount, $now); if ($debug) { $startFormatted = $start ? $start->format('Y-m-d H:i:s') : 'N/A'; diff --git a/src/CoreBundle/Repository/SessionRepository.php b/src/CoreBundle/Repository/SessionRepository.php index 38423bdfb2..18dec328f5 100644 --- a/src/CoreBundle/Repository/SessionRepository.php +++ b/src/CoreBundle/Repository/SessionRepository.php @@ -464,13 +464,15 @@ class SessionRepository extends ServiceEntityRepository return array_filter($sessions, $filterSessions); } - public function countUsersBySession(int $sessionId): int + public function countUsersBySession(int $sessionId, int $relationType = Session::STUDENT): int { $qb = $this->createQueryBuilder('s'); $qb->select('COUNT(sru.id)') ->innerJoin('s.users', 'sru') ->where('s.id = :sessionId') - ->setParameter('sessionId', $sessionId); + ->andWhere('sru.relationType = :relationType') + ->setParameter('sessionId', $sessionId) + ->setParameter('relationType', $relationType); return (int) $qb->getQuery()->getSingleScalarResult(); }