mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 00:32:42 +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:
parent
2f4ff6a850
commit
cefbdbcffe
3 changed files with 47 additions and 1 deletions
|
@ -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',
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -907,7 +907,10 @@ final class DifferentialRevision extends DifferentialDAO
|
|||
}
|
||||
|
||||
public function getConduitSearchAttachments() {
|
||||
return array();
|
||||
return array(
|
||||
id(new DifferentialReviewersSearchEngineAttachment())
|
||||
->setAttachmentKey('reviewers'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue