Methods for reading reviewers from edges in differential
Summary: Add `getReviewerStatus` to get an array of `DifferentialReviewer` objects. The method `needReviewerStatus` in `DifferentialRevisionQuery` loads the edges into the revisions loaded. Test Plan: Added `->needReviewerStatus(true)` to `DifferentialRevisionSearchEngine` and checked through logging that the data was being loaded correctly. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D6450
This commit is contained in:
committed by
epriestley
parent
1b48e922d4
commit
d4c28dcbc2
@@ -56,6 +56,7 @@ final class DifferentialRevisionQuery
|
||||
private $needDiffIDs = false;
|
||||
private $needCommitPHIDs = false;
|
||||
private $needHashes = false;
|
||||
private $needReviewerStatus = false;
|
||||
|
||||
private $buildingGlobalOrder;
|
||||
|
||||
@@ -326,6 +327,19 @@ final class DifferentialRevisionQuery
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set whether or not the query should load associated reviewer status.
|
||||
*
|
||||
* @param bool True to load and attach reviewers.
|
||||
* @return this
|
||||
* @task config
|
||||
*/
|
||||
public function needReviewerStatus($need_reviewer_status) {
|
||||
$this->needReviewerStatus = $need_reviewer_status;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/* -( Query Execution )---------------------------------------------------- */
|
||||
|
||||
|
||||
@@ -376,6 +390,10 @@ final class DifferentialRevisionQuery
|
||||
$this->loadHashes($conn_r, $revisions);
|
||||
}
|
||||
|
||||
if ($this->needReviewerStatus) {
|
||||
$this->loadReviewers($conn_r, $revisions);
|
||||
}
|
||||
|
||||
return $revisions;
|
||||
}
|
||||
|
||||
@@ -903,6 +921,37 @@ final class DifferentialRevisionQuery
|
||||
}
|
||||
}
|
||||
|
||||
private function loadReviewers(
|
||||
AphrontDatabaseConnection $conn_r,
|
||||
array $revisions) {
|
||||
|
||||
assert_instances_of($revisions, 'DifferentialRevision');
|
||||
$edge_type = PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER;
|
||||
|
||||
$edges = id(new PhabricatorEdgeQuery())
|
||||
->withSourcePHIDs(mpull($revisions, 'getPHID'))
|
||||
->withEdgeTypes(array($edge_type))
|
||||
->needEdgeData(true)
|
||||
->execute();
|
||||
|
||||
foreach ($revisions as $revision) {
|
||||
$revision_edges = $edges[$revision->getPHID()][$edge_type];
|
||||
|
||||
$reviewers = array();
|
||||
foreach ($revision_edges as $user_phid => $edge) {
|
||||
$data = $edge['data'];
|
||||
$reviewers[] = new DifferentialReviewer(
|
||||
$user_phid, $data['status'], idx($data, 'diff', null)
|
||||
);
|
||||
}
|
||||
|
||||
$revision->attachReviewerStatus($reviewers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function splitResponsible(array $revisions, array $user_phids) {
|
||||
$blocking = array();
|
||||
$active = array();
|
||||
|
||||
Reference in New Issue
Block a user