@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
3final class DiffusionRepositoryMetricsSearchEngineAttachment
4 extends PhabricatorSearchEngineAttachment {
5
6 public function getAttachmentName() {
7 return pht('Repository Metrics');
8 }
9
10 public function getAttachmentDescription() {
11 return pht(
12 'Get metrics (like commit count and most recent commit) for each '.
13 'repository.');
14 }
15
16 public function willLoadAttachmentData($query, $spec) {
17 $query
18 ->needCommitCounts(true)
19 ->needMostRecentCommits(true);
20 }
21
22 public function getAttachmentForObject($object, $data, $spec) {
23 $commit = $object->getMostRecentCommit();
24 if ($commit !== null) {
25 $recent_commit = $commit->getFieldValuesForConduit();
26 } else {
27 $recent_commit = null;
28 }
29
30 $commit_count = $object->getCommitCount();
31 if ($commit_count !== null) {
32 $commit_count = (int)$commit_count;
33 }
34
35 return array(
36 'commitCount' => $commit_count,
37 'recentCommit' => $recent_commit,
38 );
39 }
40
41}