Skip to content

Commit e3f123a

Browse files
Merge pull request #5927 from christianbeeznest/ofaj-22197
Internal: Filter student count in session status update script - refs BT#22197
2 parents 8ce283e + 9b27a44 commit e3f123a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/CoreBundle/Command/UpdateSessionStatusCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5050
$id = $session->getId();
5151
$start = $session->getDisplayStartDate();
5252
$end = $session->getDisplayEndDate();
53-
$userCount = $this->sessionRepository->countUsersBySession($session->getId());
53+
$studentCount = $this->sessionRepository->countUsersBySession($session->getId());
5454

55-
$status = $this->determineSessionStatus($start, $end, $userCount, $now);
55+
$status = $this->determineSessionStatus($start, $end, $studentCount, $now);
5656

5757
if ($debug) {
5858
$startFormatted = $start ? $start->format('Y-m-d H:i:s') : 'N/A';

src/CoreBundle/Repository/SessionRepository.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,13 +464,15 @@ public function getSubscribedSessionsOfUserInUrl(
464464
return array_filter($sessions, $filterSessions);
465465
}
466466

467-
public function countUsersBySession(int $sessionId): int
467+
public function countUsersBySession(int $sessionId, int $relationType = Session::STUDENT): int
468468
{
469469
$qb = $this->createQueryBuilder('s');
470470
$qb->select('COUNT(sru.id)')
471471
->innerJoin('s.users', 'sru')
472472
->where('s.id = :sessionId')
473-
->setParameter('sessionId', $sessionId);
473+
->andWhere('sru.relationType = :relationType')
474+
->setParameter('sessionId', $sessionId)
475+
->setParameter('relationType', $relationType);
474476

475477
return (int) $qb->getQuery()->getSingleScalarResult();
476478
}

0 commit comments

Comments
 (0)