1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-29 16:08:22 +01:00

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
This commit is contained in:
Chad Little 2017-04-13 13:30:05 -07:00
parent ce06a051a5
commit 5587abf04c
13 changed files with 7 additions and 153 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_conpherence.conpherence_thread
DROP COLUMN recentParticipantPHIDs;

View file

@ -16,9 +16,6 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase {
$this->assertTrue((bool)$conpherence->getID()); $this->assertTrue((bool)$conpherence->getID());
$this->assertEqual(1, count($conpherence->getParticipants())); $this->assertEqual(1, count($conpherence->getParticipants()));
$this->assertEqual(
$participant_phids,
$conpherence->getRecentParticipantPHIDs());
} }
public function testNUserRoomCreate() { public function testNUserRoomCreate() {
@ -38,9 +35,6 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase {
$this->assertTrue((bool)$conpherence->getID()); $this->assertTrue((bool)$conpherence->getID());
$this->assertEqual(4, count($conpherence->getParticipants())); $this->assertEqual(4, count($conpherence->getParticipants()));
$this->assertEqual(
$participant_phids,
$conpherence->getRecentParticipantPHIDs());
} }
public function testRoomParticipantAddition() { public function testRoomParticipantAddition() {
@ -58,16 +52,11 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase {
$this->assertTrue((bool)$conpherence->getID()); $this->assertTrue((bool)$conpherence->getID());
$this->assertEqual(2, count($conpherence->getParticipants())); $this->assertEqual(2, count($conpherence->getParticipants()));
$this->assertEqual(
$participant_phids,
$conpherence->getRecentParticipantPHIDs());
// test add by creator // test add by creator
$participant_phids[] = $friend_2->getPHID(); $participant_phids[] = $friend_2->getPHID();
$this->addParticipants($creator, $conpherence, array($friend_2->getPHID())); $this->addParticipants($creator, $conpherence, array($friend_2->getPHID()));
$this->assertEqual( $this->assertEqual(3, count($conpherence->getParticipants()));
$participant_phids,
$conpherence->getRecentParticipantPHIDs());
// test add by other participant, so recent participation should // test add by other participant, so recent participation should
// meaningfully change // meaningfully change
@ -81,9 +70,7 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase {
$friend_2, $friend_2,
$conpherence, $conpherence,
array($friend_3->getPHID())); array($friend_3->getPHID()));
$this->assertEqual( $this->assertEqual(4, count($conpherence->getParticipants()));
$participant_phids,
$conpherence->getRecentParticipantPHIDs());
} }
public function testRoomParticipantDeletion() { public function testRoomParticipantDeletion() {

View file

@ -71,7 +71,6 @@ final class ConpherenceQueryThreadConduitAPIMethod
'conpherencePHID' => $conpherence->getPHID(), 'conpherencePHID' => $conpherence->getPHID(),
'conpherenceTitle' => $conpherence->getTitle(), 'conpherenceTitle' => $conpherence->getTitle(),
'messageCount' => $conpherence->getMessageCount(), 'messageCount' => $conpherence->getMessageCount(),
'recentParticipantPHIDs' => $conpherence->getRecentParticipantPHIDs(),
'conpherenceURI' => $this->getConpherenceURI($conpherence), 'conpherenceURI' => $this->getConpherenceURI($conpherence),
); );
} }

View file

@ -17,7 +17,6 @@ final class ConpherenceColumnViewController extends
->setViewer($user) ->setViewer($user)
->withPHIDs($conpherence_phids) ->withPHIDs($conpherence_phids)
->needProfileImage(true) ->needProfileImage(true)
->needParticipantCache(true)
->execute(); ->execute();
$latest_conpherences = mpull($latest_conpherences, null, 'getPHID'); $latest_conpherences = mpull($latest_conpherences, null, 'getPHID');
$latest_conpherences = array_select_keys( $latest_conpherences = array_select_keys(

View file

@ -159,7 +159,6 @@ final class ConpherenceListController extends ConpherenceController {
->setViewer($user) ->setViewer($user)
->withPHIDs($conpherence_phids) ->withPHIDs($conpherence_phids)
->needProfileImage(true) ->needProfileImage(true)
->needParticipantCache(true)
->execute(); ->execute();
// this will re-sort by participation data // this will re-sort by participation data

View file

@ -21,7 +21,6 @@ final class ConpherenceNotificationPanelController
->needProfileImage(true) ->needProfileImage(true)
->needTransactions(true) ->needTransactions(true)
->setTransactionLimit(100) ->setTransactionLimit(100)
->needParticipantCache(true)
->execute(); ->execute();
} }

View file

@ -470,7 +470,6 @@ final class ConpherenceUpdateController
$latest_transaction_id) { $latest_transaction_id) {
$need_transactions = false; $need_transactions = false;
$need_participant_cache = true;
switch ($action) { switch ($action) {
case ConpherenceUpdateActions::METADATA: case ConpherenceUpdateActions::METADATA:
case ConpherenceUpdateActions::LOAD: case ConpherenceUpdateActions::LOAD:
@ -491,7 +490,6 @@ final class ConpherenceUpdateController
->setViewer($user) ->setViewer($user)
->setAfterTransactionID($latest_transaction_id) ->setAfterTransactionID($latest_transaction_id)
->needProfileImage(true) ->needProfileImage(true)
->needParticipantCache($need_participant_cache)
->needParticipants(true) ->needParticipants(true)
->needTransactions($need_transactions) ->needTransactions($need_transactions)
->withIDs(array($conpherence_id)) ->withIDs(array($conpherence_id))

View file

@ -20,7 +20,6 @@ final class ConpherenceViewController extends
->setViewer($user) ->setViewer($user)
->withIDs(array($conpherence_id)) ->withIDs(array($conpherence_id))
->needProfileImage(true) ->needProfileImage(true)
->needParticipantCache(true)
->needTransactions(true) ->needTransactions(true)
->setTransactionLimit($this->getMainQueryLimit()); ->setTransactionLimit($this->getMainQueryLimit());

View file

@ -190,7 +190,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
->setSeenMessageCount($message_count) ->setSeenMessageCount($message_count)
->save(); ->save();
$object->attachParticipants($participants); $object->attachParticipants($participants);
$object->setRecentParticipantPHIDs(array_keys($participants));
} }
break; break;
} }
@ -201,39 +200,12 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
PhabricatorLiskDAO $object, PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) { PhabricatorApplicationTransaction $xaction) {
$make_author_recent_participant = true;
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case ConpherenceTransaction::TYPE_PARTICIPANTS: case ConpherenceTransaction::TYPE_PARTICIPANTS:
if (!$this->getIsNewObject()) { if (!$this->getIsNewObject()) {}
$old_map = array_fuse($xaction->getOldValue());
$new_map = array_fuse($xaction->getNewValue());
// if we added people, add them to the end of "recent" participants
$add = array_keys(array_diff_key($new_map, $old_map));
// if we remove people, then definintely remove them from "recent"
// participants
$del = array_keys(array_diff_key($old_map, $new_map));
if ($add || $del) {
$participants = $object->getRecentParticipantPHIDs();
if ($add) {
$participants = array_merge($participants, $add);
}
if ($del) {
$participants = array_diff($participants, $del);
$actor = $this->requireActor();
if (in_array($actor->getPHID(), $del)) {
$make_author_recent_participant = false;
}
}
$participants = array_slice(array_unique($participants), 0, 10);
$object->setRecentParticipantPHIDs($participants);
}
}
break; break;
} }
if ($make_author_recent_participant) {
$this->makeAuthorMostRecentParticipant($object, $xaction);
}
} }
protected function applyBuiltinInternalTransaction( protected function applyBuiltinInternalTransaction(
@ -249,17 +221,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
return parent::applyBuiltinInternalTransaction($object, $xaction); return parent::applyBuiltinInternalTransaction($object, $xaction);
} }
private function makeAuthorMostRecentParticipant(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
$participants = $object->getRecentParticipantPHIDs();
array_unshift($participants, $xaction->getAuthorPHID());
$participants = array_slice(array_unique($participants), 0, 10);
$object->setRecentParticipantPHIDs($participants);
}
protected function applyCustomExternalTransaction( protected function applyCustomExternalTransaction(
PhabricatorLiskDAO $object, PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) { PhabricatorApplicationTransaction $xaction) {

View file

@ -10,18 +10,12 @@ final class ConpherenceThreadQuery
private $participantPHIDs; private $participantPHIDs;
private $needParticipants; private $needParticipants;
private $needTransactions; private $needTransactions;
private $needParticipantCache;
private $afterTransactionID; private $afterTransactionID;
private $beforeTransactionID; private $beforeTransactionID;
private $transactionLimit; private $transactionLimit;
private $fulltext; private $fulltext;
private $needProfileImage; private $needProfileImage;
public function needParticipantCache($participant_cache) {
$this->needParticipantCache = $participant_cache;
return $this;
}
public function needParticipants($need) { public function needParticipants($need) {
$this->needParticipants = $need; $this->needParticipants = $need;
return $this; return $this;
@ -101,9 +95,6 @@ final class ConpherenceThreadQuery
if ($conpherences) { if ($conpherences) {
$conpherences = mpull($conpherences, null, 'getPHID'); $conpherences = mpull($conpherences, null, 'getPHID');
$this->loadParticipantsAndInitHandles($conpherences); $this->loadParticipantsAndInitHandles($conpherences);
if ($this->needParticipantCache) {
$this->loadCoreHandles($conpherences, 'getRecentParticipantPHIDs');
}
if ($this->needParticipants) { if ($this->needParticipants) {
$this->loadCoreHandles($conpherences, 'getParticipantPHIDs'); $this->loadCoreHandles($conpherences, 'getParticipantPHIDs');
} }

View file

@ -13,7 +13,6 @@ final class ConpherenceThreadSearchEngine
public function newQuery() { public function newQuery() {
return id(new ConpherenceThreadQuery()) return id(new ConpherenceThreadQuery())
->needParticipantCache(true)
->needProfileImage(true); ->needProfileImage(true);
} }
@ -92,14 +91,6 @@ final class ConpherenceThreadSearchEngine
return parent::buildSavedQueryFromBuiltin($query_key); return parent::buildSavedQueryFromBuiltin($query_key);
} }
protected function getRequiredHandlePHIDsForResultList(
array $conpherences,
PhabricatorSavedQuery $query) {
$recent = mpull($conpherences, 'getRecentParticipantPHIDs');
return array_unique(array_mergev($recent));
}
protected function renderResultList( protected function renderResultList(
array $conpherences, array $conpherences,
PhabricatorSavedQuery $query, PhabricatorSavedQuery $query,
@ -153,7 +144,7 @@ final class ConpherenceThreadSearchEngine
$list->setUser($viewer); $list->setUser($viewer);
foreach ($conpherences as $conpherence_phid => $conpherence) { foreach ($conpherences as $conpherence_phid => $conpherence) {
$created = phabricator_date($conpherence->getDateCreated(), $viewer); $created = phabricator_date($conpherence->getDateCreated(), $viewer);
$title = $conpherence->getDisplayTitle($viewer); $title = $conpherence->getTitle();
$monogram = $conpherence->getMonogram(); $monogram = $conpherence->getMonogram();
$icon_name = $conpherence->getPolicyIconName($policy_objects); $icon_name = $conpherence->getPolicyIconName($policy_objects);

View file

@ -12,7 +12,6 @@ final class ConpherenceThread extends ConpherenceDAO
protected $topic; protected $topic;
protected $profileImagePHID; protected $profileImagePHID;
protected $messageCount; protected $messageCount;
protected $recentParticipantPHIDs = array();
protected $mailKey; protected $mailKey;
protected $viewPolicy; protected $viewPolicy;
protected $editPolicy; protected $editPolicy;
@ -39,9 +38,6 @@ final class ConpherenceThread extends ConpherenceDAO
protected function getConfiguration() { protected function getConfiguration() {
return array( return array(
self::CONFIG_AUX_PHID => true, self::CONFIG_AUX_PHID => true,
self::CONFIG_SERIALIZATION => array(
'recentParticipantPHIDs' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array( self::CONFIG_COLUMN_SCHEMA => array(
'title' => 'text255?', 'title' => 'text255?',
'topic' => 'text255', 'topic' => 'text255',
@ -165,72 +161,6 @@ final class ConpherenceThread extends ConpherenceDAO
return pht('Private Room'); return pht('Private Room');
} }
/**
* Get the thread's display title for a user.
*
* If a thread doesn't have a title set, this will return a string describing
* recent participants.
*
* @param PhabricatorUser Viewer.
* @return string Thread title.
*/
public function getDisplayTitle(PhabricatorUser $viewer) {
$title = $this->getTitle();
if (strlen($title)) {
return $title;
}
return $this->getRecentParticipantsString($viewer);
}
/**
* Get recent participants (other than the viewer) as a string.
*
* For example, this method might return "alincoln, htaft, gwashington...".
*
* @param PhabricatorUser Viewer.
* @return string Description of other participants.
*/
private function getRecentParticipantsString(PhabricatorUser $viewer) {
$handles = $this->getHandles();
$phids = $this->getOtherRecentParticipantPHIDs($viewer);
if (count($phids) == 0) {
$phids[] = $viewer->getPHID();
$more = false;
} else {
$limit = 3;
$more = (count($phids) > $limit);
$phids = array_slice($phids, 0, $limit);
}
$names = array_select_keys($handles, $phids);
$names = mpull($names, 'getName');
$names = implode(', ', $names);
if ($more) {
$names = $names.'...';
}
return $names;
}
/**
* Get PHIDs for recent participants who are not the viewer.
*
* @param PhabricatorUser Viewer.
* @return list<phid> Participants who are not the viewer.
*/
private function getOtherRecentParticipantPHIDs(PhabricatorUser $viewer) {
$phids = $this->getRecentParticipantPHIDs();
$phids = array_fuse($phids);
unset($phids[$viewer->getPHID()]);
return array_values($phids);
}
public function getDisplayData(PhabricatorUser $viewer) { public function getDisplayData(PhabricatorUser $viewer) {
$handles = $this->getHandles(); $handles = $this->getHandles();
@ -277,7 +207,7 @@ final class ConpherenceThread extends ConpherenceDAO
} }
$unread_count = $this->getMessageCount() - $user_seen_count; $unread_count = $this->getMessageCount() - $user_seen_count;
$title = $this->getDisplayTitle($viewer); $title = $this->getTitle();
$topic = $this->getTopic(); $topic = $this->getTopic();
return array( return array(

View file

@ -45,7 +45,6 @@ final class PhabricatorConpherenceProfileMenuItem
$rooms = id(new ConpherenceThreadQuery()) $rooms = id(new ConpherenceThreadQuery())
->setViewer($viewer) ->setViewer($viewer)
->withPHIDs($room_phids) ->withPHIDs($room_phids)
->needParticipantCache(true)
->needProfileImage(true) ->needProfileImage(true)
->execute(); ->execute();