3 final class DiffusionLastModifiedController
extends DiffusionController
{
5 public function shouldAllowPublic() {
9 public function handleRequest(AphrontRequest
$request) {
10 $response = $this->loadDiffusionContext();
15 $viewer = $this->getViewer();
16 $drequest = $this->getDiffusionRequest();
18 $paths = $request->getStr('paths');
21 $paths = phutil_json_decode($paths);
22 } catch (PhutilJSONParserException
$ex) {
23 return new Aphront400Response();
26 $modified_map = $this->callConduitWithDiffusionRequest(
27 'diffusion.lastmodifiedquery',
29 'paths' => array_fill_keys($paths, $drequest->getCommit()),
33 $commit_map = id(new DiffusionCommitQuery())
35 ->withRepository($drequest->getRepository())
36 ->withIdentifiers(array_values($modified_map))
37 ->needCommitData(true)
38 ->needIdentities(true)
40 $commit_map = mpull($commit_map, null, 'getCommitIdentifier');
42 $commit_map = array();
46 foreach ($paths as $path) {
47 $modified_at = idx($modified_map, $path);
49 $commit = idx($commit_map, $modified_at);
51 $commits[$path] = $commit;
56 $branch = $drequest->loadBranch();
57 if ($branch && $commits) {
58 $lint_query = id(new DiffusionLintCountQuery())
59 ->withBranchIDs(array($branch->getID()))
60 ->withPaths(array_keys($commits));
62 if ($drequest->getLint()) {
63 $lint_query->withCodes(array($drequest->getLint()));
66 $lint = $lint_query->execute();
72 foreach ($commits as $path => $commit) {
73 $prequest = clone $drequest;
74 $prequest->setPath($path);
76 $output[$path] = $this->renderColumns(
82 return id(new AphrontAjaxResponse())->setContent($output);
85 private function renderColumns(
86 DiffusionRequest
$drequest,
87 PhabricatorRepositoryCommit
$commit = null,
89 $viewer = $this->getViewer();
92 $epoch = $commit->getEpoch();
93 $modified = DiffusionView
::linkCommit(
94 $drequest->getRepository(),
95 $commit->getCommitIdentifier());
96 $date = $viewer->formatShortDateTime($epoch);
102 $data = $commit->getCommitData();
103 $details = DiffusionView
::linkDetail(
104 $drequest->getRepository(),
105 $commit->getCommitIdentifier(),
106 $data->getSummary());
107 $details = AphrontTableView
::renderSingleDisplayLine($details);
110 'commit' => $modified,
112 'details' => $details,
115 if ($lint !== null) {
116 $return['lint'] = phutil_tag(
119 'href' => $drequest->generateURI(array(
124 number_format($lint));
127 // The client treats these results as markup, so make sure they have been
128 // escaped correctly.
129 foreach ($return as $key => $value) {
130 $return[$key] = hsprintf('%s', $value);