@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3abstract class DifferentialRevisionResultBucket
4 extends PhabricatorSearchResultBucket {
5
6 public static function getAllResultBuckets() {
7 return id(new PhutilClassMapQuery())
8 ->setAncestorClass(self::class)
9 ->setUniqueMethod('getResultBucketKey')
10 ->execute();
11 }
12
13 protected function getRevisionsUnderReview(array $objects, array $phids) {
14 $results = array();
15
16 $objects = $this->getRevisionsNotAuthored($objects, $phids);
17
18 foreach ($objects as $key => $object) {
19 if (!$object->isNeedsReview()) {
20 continue;
21 }
22
23 $results[$key] = $object;
24 }
25
26 return $results;
27 }
28
29 protected function getRevisionsAuthored(array $objects, array $phids) {
30 $results = array();
31
32 foreach ($objects as $key => $object) {
33 if (isset($phids[$object->getAuthorPHID()])) {
34 $results[$key] = $object;
35 }
36 }
37
38 return $results;
39 }
40
41 protected function getRevisionsNotAuthored(array $objects, array $phids) {
42 $results = array();
43
44 foreach ($objects as $key => $object) {
45 if (empty($phids[$object->getAuthorPHID()])) {
46 $results[$key] = $object;
47 }
48 }
49
50 return $results;
51 }
52
53 protected function hasReviewersWithStatus(
54 DifferentialRevision $revision,
55 array $phids,
56 array $statuses,
57 $include_voided = null) {
58
59 foreach ($revision->getReviewers() as $reviewer) {
60 $reviewer_phid = $reviewer->getReviewerPHID();
61 if (empty($phids[$reviewer_phid])) {
62 continue;
63 }
64
65 $status = $reviewer->getReviewerStatus();
66 if (empty($statuses[$status])) {
67 continue;
68 }
69
70 if ($include_voided !== null) {
71 if ($status == DifferentialReviewerStatus::STATUS_ACCEPTED) {
72 $is_voided = (bool)$reviewer->getVoidedPHID();
73 if ($is_voided !== $include_voided) {
74 continue;
75 }
76 }
77 }
78
79 return true;
80 }
81
82 return false;
83 }
84
85
86}