Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/engineextension/DiffusionRepositoryMetricsSearchEngineAttachment.php
12242 views
1
<?php
2
3
final 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
}
42
43