diff options
author | Joas Schilling <coding@schilljs.com> | 2021-02-12 11:03:41 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-02-12 12:46:35 +0300 |
commit | 9e55a41e0880219eb993c5690198f159120ccdd5 (patch) | |
tree | 2a01c5b2d432e83fbdc9fd74c4131bbaca35b244 /lib/Model | |
parent | e9bc0ad78aa1a3f530ea4c1a52d34ea05e45e707 (diff) |
Count guests from attendees instead of the fixed value which bumps up on reconnects
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Model')
-rw-r--r-- | lib/Model/AttendeeMapper.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Model/AttendeeMapper.php b/lib/Model/AttendeeMapper.php index 13d7d6d07..8bce0422f 100644 --- a/lib/Model/AttendeeMapper.php +++ b/lib/Model/AttendeeMapper.php @@ -79,6 +79,30 @@ class AttendeeMapper extends QBMapper { /** * @param int $roomId + * @param string $actorType + * @param int|null $lastJoinedCall + * @return int + */ + public function getActorsCountByType(int $roomId, string $actorType, ?int $lastJoinedCall = null): int { + $query = $this->db->getQueryBuilder(); + $query->select($query->func()->count('*', 'num_actors')) + ->from($this->getTableName()) + ->where($query->expr()->eq('room_id', $query->createNamedParameter($roomId, IQueryBuilder::PARAM_INT))) + ->andWhere($query->expr()->eq('actor_type', $query->createNamedParameter($actorType))); + + if ($lastJoinedCall !== null) { + $query->andWhere($query->expr()->gte('last_joined_call', $query->createNamedParameter($lastJoinedCall, IQueryBuilder::PARAM_INT))); + } + + $result = $query->execute(); + $count = (int) $result->fetchOne(); + $result->closeCursor(); + + return $count; + } + + /** + * @param int $roomId * @param int[] $participantType * @return int */ |