mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-12 00:26:13 +01:00
0ceab7d36f
Summary: Ref T10967. Improves some method names: - `Revision->getReviewerStatus()` -> `Revision->getReviewers()` - `Revision->attachReviewerStatus()` -> `Revision->attachReviewers()` - `Reviewer->getStatus()` -> `Reviewer->getReviewerStatus()` (this is mostly to make this more greppable) Test Plan: - bunch o' `grep` - Browsed around. - If I missed anything, it should fatal in an obvious way. We have a lot of other `getStatus()` calls and it's hard to be sure I got them all. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10967 Differential Revision: https://secure.phabricator.com/D17522
77 lines
1.7 KiB
PHP
77 lines
1.7 KiB
PHP
<?php
|
|
|
|
abstract class DifferentialRevisionResultBucket
|
|
extends PhabricatorSearchResultBucket {
|
|
|
|
public static function getAllResultBuckets() {
|
|
return id(new PhutilClassMapQuery())
|
|
->setAncestorClass(__CLASS__)
|
|
->setUniqueMethod('getResultBucketKey')
|
|
->execute();
|
|
}
|
|
|
|
protected function getRevisionsUnderReview(array $objects, array $phids) {
|
|
$results = array();
|
|
|
|
$objects = $this->getRevisionsNotAuthored($objects, $phids);
|
|
|
|
$status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
|
|
foreach ($objects as $key => $object) {
|
|
if ($object->getStatus() != $status_review) {
|
|
continue;
|
|
}
|
|
|
|
$results[$key] = $object;
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
|
|
protected function getRevisionsAuthored(array $objects, array $phids) {
|
|
$results = array();
|
|
|
|
foreach ($objects as $key => $object) {
|
|
if (isset($phids[$object->getAuthorPHID()])) {
|
|
$results[$key] = $object;
|
|
}
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
|
|
protected function getRevisionsNotAuthored(array $objects, array $phids) {
|
|
$results = array();
|
|
|
|
foreach ($objects as $key => $object) {
|
|
if (empty($phids[$object->getAuthorPHID()])) {
|
|
$results[$key] = $object;
|
|
}
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
|
|
protected function hasReviewersWithStatus(
|
|
DifferentialRevision $revision,
|
|
array $phids,
|
|
array $statuses) {
|
|
|
|
foreach ($revision->getReviewers() as $reviewer) {
|
|
$reviewer_phid = $reviewer->getReviewerPHID();
|
|
if (empty($phids[$reviewer_phid])) {
|
|
continue;
|
|
}
|
|
|
|
$status = $reviewer->getReviewerStatus();
|
|
if (empty($statuses[$status])) {
|
|
continue;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|