Migrate project membership to edges
Summary: - Store project members in edges. - Migrate existing members to edge storage. - Delete PhabricatorProjectAffiliation. - I left the actual underlying data around just in case something goes wrong; we can delete it evenutally. Test Plan: - Ran migration. - Created a new project. - Joined and left a project. - Added and removed project members. - Manually called PhabricatorOwnersOwner::loadAffiliatedUserPHIDs() to verify its behavior. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D3186
This commit is contained in:
@@ -35,12 +35,19 @@ final class PhabricatorProjectCreateController
|
||||
|
||||
try {
|
||||
$xactions = array();
|
||||
|
||||
$xaction = new PhabricatorProjectTransaction();
|
||||
$xaction->setTransactionType(
|
||||
PhabricatorProjectTransactionType::TYPE_NAME);
|
||||
$xaction->setNewValue($request->getStr('name'));
|
||||
$xactions[] = $xaction;
|
||||
|
||||
$xaction = new PhabricatorProjectTransaction();
|
||||
$xaction->setTransactionType(
|
||||
PhabricatorProjectTransactionType::TYPE_MEMBERS);
|
||||
$xaction->setNewValue(array($user->getPHID()));
|
||||
$xactions[] = $xaction;
|
||||
|
||||
$editor = new PhabricatorProjectEditor($project);
|
||||
$editor->setUser($user);
|
||||
$editor->applyTransactions($xactions);
|
||||
@@ -56,13 +63,6 @@ final class PhabricatorProjectCreateController
|
||||
$profile->setProjectPHID($project->getPHID());
|
||||
$profile->save();
|
||||
|
||||
id(new PhabricatorProjectAffiliation())
|
||||
->setUserPHID($user->getPHID())
|
||||
->setProjectPHID($project->getPHID())
|
||||
->setRole('Owner')
|
||||
->setIsOwner(true)
|
||||
->save();
|
||||
|
||||
if ($request->isAjax()) {
|
||||
return id(new AphrontAjaxResponse())
|
||||
->setContent(array(
|
||||
|
||||
@@ -81,10 +81,12 @@ final class PhabricatorProjectListController
|
||||
$profiles = mpull($profiles, null, 'getProjectPHID');
|
||||
}
|
||||
|
||||
$affil_groups = array();
|
||||
$edge_query = new PhabricatorEdgeQuery();
|
||||
if ($projects) {
|
||||
$affil_groups = PhabricatorProjectAffiliation::loadAllForProjectPHIDs(
|
||||
$project_phids);
|
||||
$edge_query
|
||||
->withSourcePHIDs($project_phids)
|
||||
->withEdgeTypes(array(PhabricatorEdgeConfig::TYPE_PROJ_MEMBER))
|
||||
->execute();
|
||||
}
|
||||
|
||||
$tasks = array();
|
||||
@@ -104,18 +106,17 @@ final class PhabricatorProjectListController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows = array();
|
||||
foreach ($projects as $project) {
|
||||
$phid = $project->getPHID();
|
||||
|
||||
$profile = idx($profiles, $phid);
|
||||
$affiliations = $affil_groups[$phid];
|
||||
$members = $edge_query->getDestinationPHIDs(array($phid));
|
||||
|
||||
$group = idx($groups, $phid, array());
|
||||
$task_count = count($group);
|
||||
|
||||
$population = count($affiliations);
|
||||
$population = count($members);
|
||||
|
||||
if ($profile) {
|
||||
$blurb = $profile->getBlurb();
|
||||
|
||||
Reference in New Issue
Block a user