Something went wrong. Try again.
@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
Something went wrong. Try again.
phorge src applications diffusion engineextension DiffusionRepositoryMetricsSearchEngineAttachment.php
993 B · 41 lines
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142<?php
final class DiffusionRepositoryMetricsSearchEngineAttachment extends PhabricatorSearchEngineAttachment {
public function getAttachmentName() { return pht('Repository Metrics'); }
public function getAttachmentDescription() { return pht( 'Get metrics (like commit count and most recent commit) for each '. 'repository.'); }
public function willLoadAttachmentData($query, $spec) { $query ->needCommitCounts(true) ->needMostRecentCommits(true); }
public function getAttachmentForObject($object, $data, $spec) { $commit = $object->getMostRecentCommit(); if ($commit !== null) { $recent_commit = $commit->getFieldValuesForConduit(); } else { $recent_commit = null; }
$commit_count = $object->getCommitCount(); if ($commit_count !== null) { $commit_count = (int)$commit_count; }
return array( 'commitCount' => $commit_count, 'recentCommit' => $recent_commit, ); }
}