Path: blob/master/src/applications/conpherence/query/ConpherenceParticipantCountQuery.php
12256 views
<?php12final class ConpherenceParticipantCountQuery3extends PhabricatorOffsetPagedQuery {45private $participantPHIDs;6private $unread;78public function withParticipantPHIDs(array $phids) {9$this->participantPHIDs = $phids;10return $this;11}1213public function withUnread($unread) {14$this->unread = $unread;15return $this;16}1718public function execute() {19$thread = new ConpherenceThread();20$table = new ConpherenceParticipant();21$conn = $table->establishConnection('r');2223$rows = queryfx_all(24$conn,25'SELECT COUNT(*) as count, participantPHID26FROM %T participant JOIN %T thread27ON participant.conpherencePHID = thread.phid %Q %Q %Q',28$table->getTableName(),29$thread->getTableName(),30$this->buildWhereClause($conn),31$this->buildGroupByClause($conn),32$this->buildLimitClause($conn));3334return ipull($rows, 'count', 'participantPHID');35}3637protected function buildWhereClause(AphrontDatabaseConnection $conn) {38$where = array();3940if ($this->participantPHIDs !== null) {41$where[] = qsprintf(42$conn,43'participant.participantPHID IN (%Ls)',44$this->participantPHIDs);45}4647if ($this->unread !== null) {48if ($this->unread) {49$where[] = qsprintf(50$conn,51'participant.seenMessageCount < thread.messageCount');52} else {53$where[] = qsprintf(54$conn,55'participant.seenMessageCount >= thread.messageCount');56}57}5859return $this->formatWhereClause($conn, $where);60}6162private function buildGroupByClause(AphrontDatabaseConnection $conn) {63return qsprintf(64$conn,65'GROUP BY participantPHID');66}6768}697071