@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Searching Calendar events by invitee should work now

Summary: Closes T8045, Searching Calendar events by invitee should work now

Test Plan: Open Advanced Search on Calendar, search by invitee, only events with invitee specified should be returned.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T8045

Differential Revision: https://secure.phabricator.com/D12738

+42 -15
+42 -15
src/applications/calendar/query/PhabricatorCalendarEventQuery.php
··· 7 7 private $phids; 8 8 private $rangeBegin; 9 9 private $rangeEnd; 10 - private $invitedPHIDs; 10 + private $inviteePHIDs; 11 11 private $creatorPHIDs; 12 12 private $isCancelled; 13 13 ··· 28 28 } 29 29 30 30 public function withInvitedPHIDs(array $phids) { 31 - $this->invitedPHIDs = $phids; 31 + $this->inviteePHIDs = $phids; 32 32 return $this; 33 33 } 34 34 ··· 48 48 49 49 $data = queryfx_all( 50 50 $conn_r, 51 - 'SELECT * FROM %T %Q %Q %Q', 51 + 'SELECT event.* FROM %T event %Q %Q %Q %Q %Q', 52 52 $table->getTableName(), 53 + $this->buildJoinClause($conn_r), 53 54 $this->buildWhereClause($conn_r), 55 + $this->buildGroupClause($conn_r), 54 56 $this->buildOrderClause($conn_r), 55 57 $this->buildLimitClause($conn_r)); 56 58 57 59 return $table->loadAllFromArray($data); 58 60 } 59 61 62 + protected function buildJoinClauseParts(AphrontDatabaseConnection $conn_r) { 63 + $parts = parent::buildJoinClauseParts($conn_r); 64 + if ($this->inviteePHIDs !== null) { 65 + $parts[] = qsprintf( 66 + $conn_r, 67 + 'JOIN %T invitee ON invitee.eventPHID = event.phid'. 68 + 'AND invitee.status != %s', 69 + id(new PhabricatorCalendarEventInvitee())->getTableName(), 70 + PhabricatorCalendarEventInvitee::STATUS_UNINVITED); 71 + } 72 + return $parts; 73 + } 74 + 60 75 protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 61 76 $where = array(); 62 77 63 78 if ($this->ids) { 64 79 $where[] = qsprintf( 65 80 $conn_r, 66 - 'id IN (%Ld)', 81 + 'event.id IN (%Ld)', 67 82 $this->ids); 68 83 } 69 84 70 85 if ($this->phids) { 71 86 $where[] = qsprintf( 72 87 $conn_r, 73 - 'phid IN (%Ls)', 88 + 'event.phid IN (%Ls)', 74 89 $this->phids); 75 90 } 76 91 77 92 if ($this->rangeBegin) { 78 93 $where[] = qsprintf( 79 94 $conn_r, 80 - 'dateTo >= %d', 95 + 'event.dateTo >= %d', 81 96 $this->rangeBegin); 82 97 } 83 98 84 99 if ($this->rangeEnd) { 85 100 $where[] = qsprintf( 86 101 $conn_r, 87 - 'dateFrom <= %d', 102 + 'event.dateFrom <= %d', 88 103 $this->rangeEnd); 89 104 } 90 105 91 - // TODO: Currently, the creator is always the only invitee, but you can 92 - // query them separately since this won't always be true. 93 - 94 - if ($this->invitedPHIDs) { 106 + if ($this->inviteePHIDs !== null) { 95 107 $where[] = qsprintf( 96 108 $conn_r, 97 - 'userPHID IN (%Ls)', 98 - $this->invitedPHIDs); 109 + 'invitee.inviteePHID IN (%Ls)', 110 + $this->inviteePHIDs); 99 111 } 100 112 101 113 if ($this->creatorPHIDs) { 102 114 $where[] = qsprintf( 103 115 $conn_r, 104 - 'userPHID IN (%Ls)', 116 + 'event.userPHID IN (%Ls)', 105 117 $this->creatorPHIDs); 106 118 } 107 119 108 120 if ($this->isCancelled !== null) { 109 121 $where[] = qsprintf( 110 122 $conn_r, 111 - 'isCancelled = %d', 123 + 'event.isCancelled = %d', 112 124 (int)$this->isCancelled); 113 125 } 114 126 115 127 $where[] = $this->buildPagingClause($conn_r); 116 128 117 129 return $this->formatWhereClause($where); 130 + } 131 + 132 + protected function getPrimaryTableAlias() { 133 + return 'event'; 134 + } 135 + 136 + protected function shouldGroupQueryResultRows() { 137 + if ($this->inviteePHIDs !== null) { 138 + return true; 139 + } 140 + return parent::shouldGroupQueryResultRows(); 141 + } 142 + 143 + protected function getApplicationSearchObjectPHIDColumn() { 144 + return 'event.phid'; 118 145 } 119 146 120 147 public function getQueryApplicationClass() {