3 final class ReleephDiffChurnFieldSpecification
4 extends ReleephFieldSpecification
{
6 const REJECTIONS_WEIGHT
= 30;
7 const COMMENTS_WEIGHT
= 7;
8 const UPDATES_WEIGHT
= 10;
9 const MAX_POINTS
= 100;
11 public function getFieldKey() {
15 public function getName() {
19 public function renderPropertyViewValue(array $handles) {
20 $requested_object = $this->getObject()->getRequestedObject();
21 if (!($requested_object instanceof DifferentialRevision
)) {
24 $diff_rev = $requested_object;
26 $xactions = id(new DifferentialTransactionQuery())
27 ->setViewer($this->getViewer())
28 ->withObjectPHIDs(array($diff_rev->getPHID()))
35 foreach ($xactions as $xaction) {
36 switch ($xaction->getTransactionType()) {
37 case PhabricatorTransactions
::TYPE_COMMENT
:
40 case DifferentialRevisionUpdateTransaction
::TRANSACTIONTYPE
:
43 case DifferentialTransaction
::TYPE_ACTION
:
44 switch ($xaction->getNewValue()) {
45 case DifferentialAction
::ACTION_REJECT
:
54 self
::REJECTIONS_WEIGHT
* $rejections +
55 self
::COMMENTS_WEIGHT
* $comments +
56 self
::UPDATES_WEIGHT
* $updates;
59 $points = 0.15 * self
::MAX_POINTS
;
60 $blurb = pht('Silent diff');
64 $parts[] = pht('%s rejection(s)', new PhutilNumber($rejections));
67 $parts[] = pht('%s comment(s)', new PhutilNumber($comments));
70 $parts[] = pht('%s update(s)', new PhutilNumber($updates));
73 if (count($parts) === 0) {
75 } else if (count($parts) === 1) {
76 $blurb = head($parts);
78 $last = array_pop($parts);
79 $blurb = pht('%s and %s', implode(', ', $parts), $last);
83 return id(new AphrontProgressBarView())
85 ->setMax(self
::MAX_POINTS
)