Skip to content

Commit 5587abf

Browse files
author
Chad Little
committed
Remove recentParticipants from ConpherenceThread
Summary: We no longer display this any more in the UI, so go ahead and remove the callsites and db column. Test Plan: New Room, with and without participants. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17683
1 parent ce06a05 commit 5587abf

13 files changed

+7
-153
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE {$NAMESPACE}_conpherence.conpherence_thread
2+
DROP COLUMN recentParticipantPHIDs;

src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ public function testOneUserRoomCreate() {
1616

1717
$this->assertTrue((bool)$conpherence->getID());
1818
$this->assertEqual(1, count($conpherence->getParticipants()));
19-
$this->assertEqual(
20-
$participant_phids,
21-
$conpherence->getRecentParticipantPHIDs());
2219
}
2320

2421
public function testNUserRoomCreate() {
@@ -38,9 +35,6 @@ public function testNUserRoomCreate() {
3835

3936
$this->assertTrue((bool)$conpherence->getID());
4037
$this->assertEqual(4, count($conpherence->getParticipants()));
41-
$this->assertEqual(
42-
$participant_phids,
43-
$conpherence->getRecentParticipantPHIDs());
4438
}
4539

4640
public function testRoomParticipantAddition() {
@@ -58,16 +52,11 @@ public function testRoomParticipantAddition() {
5852

5953
$this->assertTrue((bool)$conpherence->getID());
6054
$this->assertEqual(2, count($conpherence->getParticipants()));
61-
$this->assertEqual(
62-
$participant_phids,
63-
$conpherence->getRecentParticipantPHIDs());
6455

6556
// test add by creator
6657
$participant_phids[] = $friend_2->getPHID();
6758
$this->addParticipants($creator, $conpherence, array($friend_2->getPHID()));
68-
$this->assertEqual(
69-
$participant_phids,
70-
$conpherence->getRecentParticipantPHIDs());
59+
$this->assertEqual(3, count($conpherence->getParticipants()));
7160

7261
// test add by other participant, so recent participation should
7362
// meaningfully change
@@ -81,9 +70,7 @@ public function testRoomParticipantAddition() {
8170
$friend_2,
8271
$conpherence,
8372
array($friend_3->getPHID()));
84-
$this->assertEqual(
85-
$participant_phids,
86-
$conpherence->getRecentParticipantPHIDs());
73+
$this->assertEqual(4, count($conpherence->getParticipants()));
8774
}
8875

8976
public function testRoomParticipantDeletion() {

src/applications/conpherence/conduit/ConpherenceQueryThreadConduitAPIMethod.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ protected function execute(ConduitAPIRequest $request) {
7171
'conpherencePHID' => $conpherence->getPHID(),
7272
'conpherenceTitle' => $conpherence->getTitle(),
7373
'messageCount' => $conpherence->getMessageCount(),
74-
'recentParticipantPHIDs' => $conpherence->getRecentParticipantPHIDs(),
7574
'conpherenceURI' => $this->getConpherenceURI($conpherence),
7675
);
7776
}

src/applications/conpherence/controller/ConpherenceColumnViewController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public function handleRequest(AphrontRequest $request) {
1717
->setViewer($user)
1818
->withPHIDs($conpherence_phids)
1919
->needProfileImage(true)
20-
->needParticipantCache(true)
2120
->execute();
2221
$latest_conpherences = mpull($latest_conpherences, null, 'getPHID');
2322
$latest_conpherences = array_select_keys(

src/applications/conpherence/controller/ConpherenceListController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ private function loadConpherenceThreadData($participation) {
159159
->setViewer($user)
160160
->withPHIDs($conpherence_phids)
161161
->needProfileImage(true)
162-
->needParticipantCache(true)
163162
->execute();
164163

165164
// this will re-sort by participation data

src/applications/conpherence/controller/ConpherenceNotificationPanelController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public function handleRequest(AphrontRequest $request) {
2121
->needProfileImage(true)
2222
->needTransactions(true)
2323
->setTransactionLimit(100)
24-
->needParticipantCache(true)
2524
->execute();
2625
}
2726

src/applications/conpherence/controller/ConpherenceUpdateController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ private function loadAndRenderUpdates(
470470
$latest_transaction_id) {
471471

472472
$need_transactions = false;
473-
$need_participant_cache = true;
474473
switch ($action) {
475474
case ConpherenceUpdateActions::METADATA:
476475
case ConpherenceUpdateActions::LOAD:
@@ -491,7 +490,6 @@ private function loadAndRenderUpdates(
491490
->setViewer($user)
492491
->setAfterTransactionID($latest_transaction_id)
493492
->needProfileImage(true)
494-
->needParticipantCache($need_participant_cache)
495493
->needParticipants(true)
496494
->needTransactions($need_transactions)
497495
->withIDs(array($conpherence_id))

src/applications/conpherence/controller/ConpherenceViewController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public function handleRequest(AphrontRequest $request) {
2020
->setViewer($user)
2121
->withIDs(array($conpherence_id))
2222
->needProfileImage(true)
23-
->needParticipantCache(true)
2423
->needTransactions(true)
2524
->setTransactionLimit($this->getMainQueryLimit());
2625

src/applications/conpherence/editor/ConpherenceEditor.php

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ protected function applyInitialEffects(
190190
->setSeenMessageCount($message_count)
191191
->save();
192192
$object->attachParticipants($participants);
193-
$object->setRecentParticipantPHIDs(array_keys($participants));
194193
}
195194
break;
196195
}
@@ -201,39 +200,12 @@ protected function applyCustomInternalTransaction(
201200
PhabricatorLiskDAO $object,
202201
PhabricatorApplicationTransaction $xaction) {
203202

204-
$make_author_recent_participant = true;
205203
switch ($xaction->getTransactionType()) {
206204
case ConpherenceTransaction::TYPE_PARTICIPANTS:
207-
if (!$this->getIsNewObject()) {
208-
$old_map = array_fuse($xaction->getOldValue());
209-
$new_map = array_fuse($xaction->getNewValue());
210-
// if we added people, add them to the end of "recent" participants
211-
$add = array_keys(array_diff_key($new_map, $old_map));
212-
// if we remove people, then definintely remove them from "recent"
213-
// participants
214-
$del = array_keys(array_diff_key($old_map, $new_map));
215-
if ($add || $del) {
216-
$participants = $object->getRecentParticipantPHIDs();
217-
if ($add) {
218-
$participants = array_merge($participants, $add);
219-
}
220-
if ($del) {
221-
$participants = array_diff($participants, $del);
222-
$actor = $this->requireActor();
223-
if (in_array($actor->getPHID(), $del)) {
224-
$make_author_recent_participant = false;
225-
}
226-
}
227-
$participants = array_slice(array_unique($participants), 0, 10);
228-
$object->setRecentParticipantPHIDs($participants);
229-
}
230-
}
205+
if (!$this->getIsNewObject()) {}
231206
break;
232207
}
233208

234-
if ($make_author_recent_participant) {
235-
$this->makeAuthorMostRecentParticipant($object, $xaction);
236-
}
237209
}
238210

239211
protected function applyBuiltinInternalTransaction(
@@ -249,17 +221,6 @@ protected function applyBuiltinInternalTransaction(
249221
return parent::applyBuiltinInternalTransaction($object, $xaction);
250222
}
251223

252-
private function makeAuthorMostRecentParticipant(
253-
PhabricatorLiskDAO $object,
254-
PhabricatorApplicationTransaction $xaction) {
255-
256-
$participants = $object->getRecentParticipantPHIDs();
257-
array_unshift($participants, $xaction->getAuthorPHID());
258-
$participants = array_slice(array_unique($participants), 0, 10);
259-
260-
$object->setRecentParticipantPHIDs($participants);
261-
}
262-
263224
protected function applyCustomExternalTransaction(
264225
PhabricatorLiskDAO $object,
265226
PhabricatorApplicationTransaction $xaction) {

src/applications/conpherence/query/ConpherenceThreadQuery.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@ final class ConpherenceThreadQuery
1010
private $participantPHIDs;
1111
private $needParticipants;
1212
private $needTransactions;
13-
private $needParticipantCache;
1413
private $afterTransactionID;
1514
private $beforeTransactionID;
1615
private $transactionLimit;
1716
private $fulltext;
1817
private $needProfileImage;
1918

20-
public function needParticipantCache($participant_cache) {
21-
$this->needParticipantCache = $participant_cache;
22-
return $this;
23-
}
24-
2519
public function needParticipants($need) {
2620
$this->needParticipants = $need;
2721
return $this;
@@ -101,9 +95,6 @@ protected function loadPage() {
10195
if ($conpherences) {
10296
$conpherences = mpull($conpherences, null, 'getPHID');
10397
$this->loadParticipantsAndInitHandles($conpherences);
104-
if ($this->needParticipantCache) {
105-
$this->loadCoreHandles($conpherences, 'getRecentParticipantPHIDs');
106-
}
10798
if ($this->needParticipants) {
10899
$this->loadCoreHandles($conpherences, 'getParticipantPHIDs');
109100
}

src/applications/conpherence/query/ConpherenceThreadSearchEngine.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public function getApplicationClassName() {
1313

1414
public function newQuery() {
1515
return id(new ConpherenceThreadQuery())
16-
->needParticipantCache(true)
1716
->needProfileImage(true);
1817
}
1918

@@ -92,14 +91,6 @@ public function buildSavedQueryFromBuiltin($query_key) {
9291
return parent::buildSavedQueryFromBuiltin($query_key);
9392
}
9493

95-
protected function getRequiredHandlePHIDsForResultList(
96-
array $conpherences,
97-
PhabricatorSavedQuery $query) {
98-
99-
$recent = mpull($conpherences, 'getRecentParticipantPHIDs');
100-
return array_unique(array_mergev($recent));
101-
}
102-
10394
protected function renderResultList(
10495
array $conpherences,
10596
PhabricatorSavedQuery $query,
@@ -153,7 +144,7 @@ protected function renderResultList(
153144
$list->setUser($viewer);
154145
foreach ($conpherences as $conpherence_phid => $conpherence) {
155146
$created = phabricator_date($conpherence->getDateCreated(), $viewer);
156-
$title = $conpherence->getDisplayTitle($viewer);
147+
$title = $conpherence->getTitle();
157148
$monogram = $conpherence->getMonogram();
158149

159150
$icon_name = $conpherence->getPolicyIconName($policy_objects);

src/applications/conpherence/storage/ConpherenceThread.php

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ final class ConpherenceThread extends ConpherenceDAO
1212
protected $topic;
1313
protected $profileImagePHID;
1414
protected $messageCount;
15-
protected $recentParticipantPHIDs = array();
1615
protected $mailKey;
1716
protected $viewPolicy;
1817
protected $editPolicy;
@@ -39,9 +38,6 @@ public static function initializeNewRoom(PhabricatorUser $sender) {
3938
protected function getConfiguration() {
4039
return array(
4140
self::CONFIG_AUX_PHID => true,
42-
self::CONFIG_SERIALIZATION => array(
43-
'recentParticipantPHIDs' => self::SERIALIZATION_JSON,
44-
),
4541
self::CONFIG_COLUMN_SCHEMA => array(
4642
'title' => 'text255?',
4743
'topic' => 'text255',
@@ -165,72 +161,6 @@ public function getStaticTitle() {
165161
return pht('Private Room');
166162
}
167163

168-
/**
169-
* Get the thread's display title for a user.
170-
*
171-
* If a thread doesn't have a title set, this will return a string describing
172-
* recent participants.
173-
*
174-
* @param PhabricatorUser Viewer.
175-
* @return string Thread title.
176-
*/
177-
public function getDisplayTitle(PhabricatorUser $viewer) {
178-
$title = $this->getTitle();
179-
if (strlen($title)) {
180-
return $title;
181-
}
182-
183-
return $this->getRecentParticipantsString($viewer);
184-
}
185-
186-
187-
/**
188-
* Get recent participants (other than the viewer) as a string.
189-
*
190-
* For example, this method might return "alincoln, htaft, gwashington...".
191-
*
192-
* @param PhabricatorUser Viewer.
193-
* @return string Description of other participants.
194-
*/
195-
private function getRecentParticipantsString(PhabricatorUser $viewer) {
196-
$handles = $this->getHandles();
197-
$phids = $this->getOtherRecentParticipantPHIDs($viewer);
198-
199-
if (count($phids) == 0) {
200-
$phids[] = $viewer->getPHID();
201-
$more = false;
202-
} else {
203-
$limit = 3;
204-
$more = (count($phids) > $limit);
205-
$phids = array_slice($phids, 0, $limit);
206-
}
207-
208-
$names = array_select_keys($handles, $phids);
209-
$names = mpull($names, 'getName');
210-
$names = implode(', ', $names);
211-
212-
if ($more) {
213-
$names = $names.'...';
214-
}
215-
216-
return $names;
217-
}
218-
219-
220-
/**
221-
* Get PHIDs for recent participants who are not the viewer.
222-
*
223-
* @param PhabricatorUser Viewer.
224-
* @return list<phid> Participants who are not the viewer.
225-
*/
226-
private function getOtherRecentParticipantPHIDs(PhabricatorUser $viewer) {
227-
$phids = $this->getRecentParticipantPHIDs();
228-
$phids = array_fuse($phids);
229-
unset($phids[$viewer->getPHID()]);
230-
return array_values($phids);
231-
}
232-
233-
234164
public function getDisplayData(PhabricatorUser $viewer) {
235165
$handles = $this->getHandles();
236166

@@ -277,7 +207,7 @@ public function getDisplayData(PhabricatorUser $viewer) {
277207
}
278208
$unread_count = $this->getMessageCount() - $user_seen_count;
279209

280-
$title = $this->getDisplayTitle($viewer);
210+
$title = $this->getTitle();
281211
$topic = $this->getTopic();
282212

283213
return array(

src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public function willBuildNavigationItems(array $items) {
4545
$rooms = id(new ConpherenceThreadQuery())
4646
->setViewer($viewer)
4747
->withPHIDs($room_phids)
48-
->needParticipantCache(true)
4948
->needProfileImage(true)
5049
->execute();
5150

0 commit comments

Comments
 (0)