1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-26 15:30:58 +01:00

Provide a "Reviewers" attachment to "differential.revision.search"

Summary: Allow API callers to retrieve reviewer information via a new "reviewers" attachment.

Test Plan: {F4675784}

Reviewers: chad, lvital

Reviewed By: lvital

Subscribers: lvital

Differential Revision: https://secure.phabricator.com/D17633
This commit is contained in:
epriestley 2017-04-06 14:07:09 -07:00
parent 2f4ff6a850
commit cefbdbcffe
3 changed files with 47 additions and 1 deletions

View file

@ -502,6 +502,7 @@ phutil_register_library_map(array(
'DifferentialReviewersCommitMessageField' => 'applications/differential/field/DifferentialReviewersCommitMessageField.php',
'DifferentialReviewersField' => 'applications/differential/customfield/DifferentialReviewersField.php',
'DifferentialReviewersHeraldAction' => 'applications/differential/herald/DifferentialReviewersHeraldAction.php',
'DifferentialReviewersSearchEngineAttachment' => 'applications/differential/engineextension/DifferentialReviewersSearchEngineAttachment.php',
'DifferentialReviewersView' => 'applications/differential/view/DifferentialReviewersView.php',
'DifferentialRevision' => 'applications/differential/storage/DifferentialRevision.php',
'DifferentialRevisionAbandonTransaction' => 'applications/differential/xaction/DifferentialRevisionAbandonTransaction.php',
@ -5275,6 +5276,7 @@ phutil_register_library_map(array(
'DifferentialReviewersCommitMessageField' => 'DifferentialCommitMessageField',
'DifferentialReviewersField' => 'DifferentialCoreCustomField',
'DifferentialReviewersHeraldAction' => 'HeraldAction',
'DifferentialReviewersSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
'DifferentialReviewersView' => 'AphrontView',
'DifferentialRevision' => array(
'DifferentialDAO',

View file

@ -0,0 +1,41 @@
<?php
final class DifferentialReviewersSearchEngineAttachment
extends PhabricatorSearchEngineAttachment {
public function getAttachmentName() {
return pht('Differential Reviewers');
}
public function getAttachmentDescription() {
return pht('Get the reviewers for each revision.');
}
public function willLoadAttachmentData($query, $spec) {
$query->needReviewers(true);
}
public function getAttachmentForObject($object, $data, $spec) {
$reviewers = $object->getReviewers();
$status_blocking = DifferentialReviewerStatus::STATUS_BLOCKING;
$list = array();
foreach ($reviewers as $reviewer) {
$status = $reviewer->getReviewerStatus();
$is_blocking = ($status == $status_blocking);
$list[] = array(
'reviewerPHID' => $reviewer->getReviewerPHID(),
'status' => $status,
'isBlocking' => $is_blocking,
'actorPHID' => $reviewer->getLastActorPHID(),
);
}
return array(
'reviewers' => $list,
);
}
}

View file

@ -907,7 +907,10 @@ final class DifferentialRevision extends DifferentialDAO
}
public function getConduitSearchAttachments() {
return array();
return array(
id(new DifferentialReviewersSearchEngineAttachment())
->setAttachmentKey('reviewers'),
);
}