mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-18 02:31:10 +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:
parent
ce06a051a5
commit
5587abf04c
13 changed files with 7 additions and 153 deletions
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_conpherence.conpherence_thread
|
||||
DROP COLUMN recentParticipantPHIDs;
|
|
@ -16,9 +16,6 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase {
|
|||
|
||||
$this->assertTrue((bool)$conpherence->getID());
|
||||
$this->assertEqual(1, count($conpherence->getParticipants()));
|
||||
$this->assertEqual(
|
||||
$participant_phids,
|
||||
$conpherence->getRecentParticipantPHIDs());
|
||||
}
|
||||
|
||||
public function testNUserRoomCreate() {
|
||||
|
@ -38,9 +35,6 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase {
|
|||
|
||||
$this->assertTrue((bool)$conpherence->getID());
|
||||
$this->assertEqual(4, count($conpherence->getParticipants()));
|
||||
$this->assertEqual(
|
||||
$participant_phids,
|
||||
$conpherence->getRecentParticipantPHIDs());
|
||||
}
|
||||
|
||||
public function testRoomParticipantAddition() {
|
||||
|
@ -58,16 +52,11 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase {
|
|||
|
||||
$this->assertTrue((bool)$conpherence->getID());
|
||||
$this->assertEqual(2, count($conpherence->getParticipants()));
|
||||
$this->assertEqual(
|
||||
$participant_phids,
|
||||
$conpherence->getRecentParticipantPHIDs());
|
||||
|
||||
// test add by creator
|
||||
$participant_phids[] = $friend_2->getPHID();
|
||||
$this->addParticipants($creator, $conpherence, array($friend_2->getPHID()));
|
||||
$this->assertEqual(
|
||||
$participant_phids,
|
||||
$conpherence->getRecentParticipantPHIDs());
|
||||
$this->assertEqual(3, count($conpherence->getParticipants()));
|
||||
|
||||
// test add by other participant, so recent participation should
|
||||
// meaningfully change
|
||||
|
@ -81,9 +70,7 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase {
|
|||
$friend_2,
|
||||
$conpherence,
|
||||
array($friend_3->getPHID()));
|
||||
$this->assertEqual(
|
||||
$participant_phids,
|
||||
$conpherence->getRecentParticipantPHIDs());
|
||||
$this->assertEqual(4, count($conpherence->getParticipants()));
|
||||
}
|
||||
|
||||
public function testRoomParticipantDeletion() {
|
||||
|
|
|
@ -71,7 +71,6 @@ final class ConpherenceQueryThreadConduitAPIMethod
|
|||
'conpherencePHID' => $conpherence->getPHID(),
|
||||
'conpherenceTitle' => $conpherence->getTitle(),
|
||||
'messageCount' => $conpherence->getMessageCount(),
|
||||
'recentParticipantPHIDs' => $conpherence->getRecentParticipantPHIDs(),
|
||||
'conpherenceURI' => $this->getConpherenceURI($conpherence),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ final class ConpherenceColumnViewController extends
|
|||
->setViewer($user)
|
||||
->withPHIDs($conpherence_phids)
|
||||
->needProfileImage(true)
|
||||
->needParticipantCache(true)
|
||||
->execute();
|
||||
$latest_conpherences = mpull($latest_conpherences, null, 'getPHID');
|
||||
$latest_conpherences = array_select_keys(
|
||||
|
|
|
@ -159,7 +159,6 @@ final class ConpherenceListController extends ConpherenceController {
|
|||
->setViewer($user)
|
||||
->withPHIDs($conpherence_phids)
|
||||
->needProfileImage(true)
|
||||
->needParticipantCache(true)
|
||||
->execute();
|
||||
|
||||
// this will re-sort by participation data
|
||||
|
|
|
@ -21,7 +21,6 @@ final class ConpherenceNotificationPanelController
|
|||
->needProfileImage(true)
|
||||
->needTransactions(true)
|
||||
->setTransactionLimit(100)
|
||||
->needParticipantCache(true)
|
||||
->execute();
|
||||
}
|
||||
|
||||
|
|
|
@ -470,7 +470,6 @@ final class ConpherenceUpdateController
|
|||
$latest_transaction_id) {
|
||||
|
||||
$need_transactions = false;
|
||||
$need_participant_cache = true;
|
||||
switch ($action) {
|
||||
case ConpherenceUpdateActions::METADATA:
|
||||
case ConpherenceUpdateActions::LOAD:
|
||||
|
@ -491,7 +490,6 @@ final class ConpherenceUpdateController
|
|||
->setViewer($user)
|
||||
->setAfterTransactionID($latest_transaction_id)
|
||||
->needProfileImage(true)
|
||||
->needParticipantCache($need_participant_cache)
|
||||
->needParticipants(true)
|
||||
->needTransactions($need_transactions)
|
||||
->withIDs(array($conpherence_id))
|
||||
|
|
|
@ -20,7 +20,6 @@ final class ConpherenceViewController extends
|
|||
->setViewer($user)
|
||||
->withIDs(array($conpherence_id))
|
||||
->needProfileImage(true)
|
||||
->needParticipantCache(true)
|
||||
->needTransactions(true)
|
||||
->setTransactionLimit($this->getMainQueryLimit());
|
||||
|
||||
|
|
|
@ -190,7 +190,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
|
|||
->setSeenMessageCount($message_count)
|
||||
->save();
|
||||
$object->attachParticipants($participants);
|
||||
$object->setRecentParticipantPHIDs(array_keys($participants));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -201,39 +200,12 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
|
|||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
$make_author_recent_participant = true;
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case ConpherenceTransaction::TYPE_PARTICIPANTS:
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (!$this->getIsNewObject()) {}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($make_author_recent_participant) {
|
||||
$this->makeAuthorMostRecentParticipant($object, $xaction);
|
||||
}
|
||||
}
|
||||
|
||||
protected function applyBuiltinInternalTransaction(
|
||||
|
@ -249,17 +221,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
|
|||
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(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
|
|
@ -10,18 +10,12 @@ final class ConpherenceThreadQuery
|
|||
private $participantPHIDs;
|
||||
private $needParticipants;
|
||||
private $needTransactions;
|
||||
private $needParticipantCache;
|
||||
private $afterTransactionID;
|
||||
private $beforeTransactionID;
|
||||
private $transactionLimit;
|
||||
private $fulltext;
|
||||
private $needProfileImage;
|
||||
|
||||
public function needParticipantCache($participant_cache) {
|
||||
$this->needParticipantCache = $participant_cache;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function needParticipants($need) {
|
||||
$this->needParticipants = $need;
|
||||
return $this;
|
||||
|
@ -101,9 +95,6 @@ final class ConpherenceThreadQuery
|
|||
if ($conpherences) {
|
||||
$conpherences = mpull($conpherences, null, 'getPHID');
|
||||
$this->loadParticipantsAndInitHandles($conpherences);
|
||||
if ($this->needParticipantCache) {
|
||||
$this->loadCoreHandles($conpherences, 'getRecentParticipantPHIDs');
|
||||
}
|
||||
if ($this->needParticipants) {
|
||||
$this->loadCoreHandles($conpherences, 'getParticipantPHIDs');
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ final class ConpherenceThreadSearchEngine
|
|||
|
||||
public function newQuery() {
|
||||
return id(new ConpherenceThreadQuery())
|
||||
->needParticipantCache(true)
|
||||
->needProfileImage(true);
|
||||
}
|
||||
|
||||
|
@ -92,14 +91,6 @@ final class ConpherenceThreadSearchEngine
|
|||
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(
|
||||
array $conpherences,
|
||||
PhabricatorSavedQuery $query,
|
||||
|
@ -153,7 +144,7 @@ final class ConpherenceThreadSearchEngine
|
|||
$list->setUser($viewer);
|
||||
foreach ($conpherences as $conpherence_phid => $conpherence) {
|
||||
$created = phabricator_date($conpherence->getDateCreated(), $viewer);
|
||||
$title = $conpherence->getDisplayTitle($viewer);
|
||||
$title = $conpherence->getTitle();
|
||||
$monogram = $conpherence->getMonogram();
|
||||
|
||||
$icon_name = $conpherence->getPolicyIconName($policy_objects);
|
||||
|
|
|
@ -12,7 +12,6 @@ final class ConpherenceThread extends ConpherenceDAO
|
|||
protected $topic;
|
||||
protected $profileImagePHID;
|
||||
protected $messageCount;
|
||||
protected $recentParticipantPHIDs = array();
|
||||
protected $mailKey;
|
||||
protected $viewPolicy;
|
||||
protected $editPolicy;
|
||||
|
@ -39,9 +38,6 @@ final class ConpherenceThread extends ConpherenceDAO
|
|||
protected function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_AUX_PHID => true,
|
||||
self::CONFIG_SERIALIZATION => array(
|
||||
'recentParticipantPHIDs' => self::SERIALIZATION_JSON,
|
||||
),
|
||||
self::CONFIG_COLUMN_SCHEMA => array(
|
||||
'title' => 'text255?',
|
||||
'topic' => 'text255',
|
||||
|
@ -165,72 +161,6 @@ final class ConpherenceThread extends ConpherenceDAO
|
|||
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) {
|
||||
$handles = $this->getHandles();
|
||||
|
||||
|
@ -277,7 +207,7 @@ final class ConpherenceThread extends ConpherenceDAO
|
|||
}
|
||||
$unread_count = $this->getMessageCount() - $user_seen_count;
|
||||
|
||||
$title = $this->getDisplayTitle($viewer);
|
||||
$title = $this->getTitle();
|
||||
$topic = $this->getTopic();
|
||||
|
||||
return array(
|
||||
|
|
|
@ -45,7 +45,6 @@ final class PhabricatorConpherenceProfileMenuItem
|
|||
$rooms = id(new ConpherenceThreadQuery())
|
||||
->setViewer($viewer)
|
||||
->withPHIDs($room_phids)
|
||||
->needParticipantCache(true)
|
||||
->needProfileImage(true)
|
||||
->execute();
|
||||
|
||||
|
|
Loading…
Reference in a new issue