@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Always pull extra browse information over Ajax, and batch some of the queries

Summary:
This code is currently quite complicated because we pull history data inline for SVN files, and via ajax for everything else (SVN dirs, everything in Git and Hg).

Always pull over ajax; batch some of the queries.

Test Plan: {F34860}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley, vrana, aran

Maniphest Tasks: T2683

Differential Revision: https://secure.phabricator.com/D5255

+119 -120
+104 -7
src/applications/diffusion/controller/DiffusionLastModifiedController.php
··· 12 12 13 13 $paths = $request->getStr('paths'); 14 14 $paths = json_decode($paths, true); 15 + if (!is_array($paths)) { 16 + return new Aphront400Response(); 17 + } 15 18 16 - $output = array(); 19 + $commits = array(); 17 20 foreach ($paths as $path) { 18 21 $prequest = clone $drequest; 19 22 $prequest->setPath($path); ··· 30 33 31 34 $commit_data = PhabricatorRepositoryCommitData::newFromDictionary( 32 35 $conduit_result['commitData']); 36 + 37 + $commit->attachCommitData($commit_data); 33 38 34 39 $phids = array(); 35 40 if ($commit_data) { ··· 41 46 } 42 47 } 43 48 44 - $phids = array_keys($phids); 45 - $handles = $this->loadViewerHandles($phids); 49 + $commits[$path] = $commit; 50 + } 46 51 47 - $view = new DiffusionBrowseTableView(); 48 - $view->setUser($request->getUser()); 49 - $output[$path] = $view->renderLastModifiedColumns( 52 + $phids = array_keys($phids); 53 + $handles = $this->loadViewerHandles($phids); 54 + 55 + $branch = $drequest->loadBranch(); 56 + if ($branch) { 57 + $lint_query = id(new DiffusionLintCountQuery()) 58 + ->withBranchIDs(array($branch->getID())) 59 + ->withPaths(array_keys($commits)); 60 + 61 + if ($drequest->getLint()) { 62 + $lint_query->withCodes(array($drequest->getLint())); 63 + } 64 + 65 + $lint = $lint_query->execute(); 66 + } else { 67 + $lint = array(); 68 + } 69 + 70 + $output = array(); 71 + foreach ($commits as $path => $commit) { 72 + $prequest = clone $drequest; 73 + $prequest->setPath($path); 74 + 75 + $output[$path] = $this->renderColumns( 50 76 $prequest, 51 77 $handles, 52 78 $commit, 53 - $commit_data); 79 + idx($lint, $path)); 54 80 } 55 81 56 82 return id(new AphrontAjaxResponse())->setContent($output); 57 83 } 84 + 85 + private function renderColumns( 86 + DiffusionRequest $drequest, 87 + array $handles, 88 + PhabricatorRepositoryCommit $commit = null, 89 + $lint = null) { 90 + assert_instances_of($handles, 'PhabricatorObjectHandle'); 91 + $viewer = $this->getRequest()->getUser(); 92 + 93 + if ($commit) { 94 + $epoch = $commit->getEpoch(); 95 + $modified = DiffusionView::linkCommit( 96 + $drequest->getRepository(), 97 + $commit->getCommitIdentifier()); 98 + $date = phabricator_date($epoch, $viewer); 99 + $time = phabricator_time($epoch, $viewer); 100 + } else { 101 + $modified = ''; 102 + $date = ''; 103 + $time = ''; 104 + } 105 + 106 + $data = $commit->getCommitData(); 107 + if ($data) { 108 + $author_phid = $data->getCommitDetail('authorPHID'); 109 + if ($author_phid && isset($handles[$author_phid])) { 110 + $author = $handles[$author_phid]->renderLink(); 111 + } else { 112 + $author = DiffusionView::renderName($data->getAuthorName()); 113 + } 114 + 115 + $committer = $data->getCommitDetail('committer'); 116 + if ($committer) { 117 + $committer_phid = $data->getCommitDetail('committerPHID'); 118 + if ($committer_phid && isset($handles[$committer_phid])) { 119 + $committer = $handles[$committer_phid]->renderLink(); 120 + } else { 121 + $committer = DiffusionView::renderName($committer); 122 + } 123 + if ($author != $committer) { 124 + $author = hsprintf('%s/%s', $author, $committer); 125 + } 126 + } 127 + 128 + $details = AphrontTableView::renderSingleDisplayLine($data->getSummary()); 129 + } else { 130 + $author = ''; 131 + $details = ''; 132 + } 133 + 134 + $return = array( 135 + 'commit' => $modified, 136 + 'date' => $date, 137 + 'time' => $time, 138 + 'author' => $author, 139 + 'details' => $details, 140 + ); 141 + 142 + if ($lint !== null) { 143 + $return['lint'] = phutil_tag( 144 + 'a', 145 + array('href' => $drequest->generateURI(array( 146 + 'action' => 'lint', 147 + 'lint' => null, 148 + ))), 149 + number_format($lint)); 150 + } 151 + 152 + return $return; 153 + } 154 + 58 155 }
+11 -112
src/applications/diffusion/view/DiffusionBrowseTableView.php
··· 17 17 return $this; 18 18 } 19 19 20 - public function renderLastModifiedColumns( 21 - DiffusionRequest $drequest, 22 - array $handles, 23 - PhabricatorRepositoryCommit $commit = null, 24 - PhabricatorRepositoryCommitData $data = null) { 25 - assert_instances_of($handles, 'PhabricatorObjectHandle'); 26 - 27 - if ($commit) { 28 - $epoch = $commit->getEpoch(); 29 - $modified = DiffusionView::linkCommit( 30 - $drequest->getRepository(), 31 - $commit->getCommitIdentifier()); 32 - $date = phabricator_date($epoch, $this->user); 33 - $time = phabricator_time($epoch, $this->user); 34 - } else { 35 - $modified = ''; 36 - $date = ''; 37 - $time = ''; 38 - } 39 - 40 - if ($data) { 41 - $author_phid = $data->getCommitDetail('authorPHID'); 42 - if ($author_phid && isset($handles[$author_phid])) { 43 - $author = $handles[$author_phid]->renderLink(); 44 - } else { 45 - $author = self::renderName($data->getAuthorName()); 46 - } 47 - 48 - $committer = $data->getCommitDetail('committer'); 49 - if ($committer) { 50 - $committer_phid = $data->getCommitDetail('committerPHID'); 51 - if ($committer_phid && isset($handles[$committer_phid])) { 52 - $committer = $handles[$committer_phid]->renderLink(); 53 - } else { 54 - $committer = self::renderName($committer); 55 - } 56 - if ($author != $committer) { 57 - $author = hsprintf('%s/%s', $author, $committer); 58 - } 59 - } 60 - 61 - $details = AphrontTableView::renderSingleDisplayLine($data->getSummary()); 62 - } else { 63 - $author = ''; 64 - $details = ''; 65 - } 66 - 67 - $return = array( 68 - 'commit' => $modified, 69 - 'date' => $date, 70 - 'time' => $time, 71 - 'author' => $author, 72 - 'details' => $details, 73 - ); 74 - 75 - $lint = self::loadLintMessagesCount($drequest); 76 - if ($lint !== null) { 77 - $return['lint'] = phutil_tag( 78 - 'a', 79 - array('href' => $drequest->generateURI(array( 80 - 'action' => 'lint', 81 - 'lint' => null, 82 - ))), 83 - number_format($lint)); 84 - } 85 - 86 - return $return; 87 - } 88 - 89 - private static function loadLintMessagesCount(DiffusionRequest $drequest) { 90 - $path = $drequest->getPath(); 91 - $branch = $drequest->loadBranch(); 92 - if (!$branch) { 93 - return null; 94 - } 95 - 96 - $query = id(new DiffusionLintCountQuery()) 97 - ->withBranchIDs(array($branch->getID())) 98 - ->withPaths(array($path)); 99 - 100 - $code = $drequest->getLint(); 101 - if ($code) { 102 - $query->withCodes(array($code)); 103 - } 104 - 105 - $result = $query->execute(); 106 - 107 - return idx($result, $path); 108 - } 109 - 110 20 public function render() { 111 21 $request = $this->getDiffusionRequest(); 112 22 $repository = $request->getRepository(); ··· 152 62 )); 153 63 } 154 64 155 - $commit = $path->getLastModifiedCommit(); 156 - if ($commit) { 157 - $drequest = clone $request; 158 - $drequest->setPath($request->getPath().$path->getPath().$dir_slash); 159 - $dict = $this->renderLastModifiedColumns( 160 - $drequest, 161 - $this->handles, 162 - $commit, 163 - $path->getLastCommitData()); 164 - } else { 165 - $dict = array( 166 - 'lint' => celerity_generate_unique_node_id(), 167 - 'commit' => celerity_generate_unique_node_id(), 168 - 'date' => celerity_generate_unique_node_id(), 169 - 'time' => celerity_generate_unique_node_id(), 170 - 'author' => celerity_generate_unique_node_id(), 171 - 'details' => celerity_generate_unique_node_id(), 172 - ); 65 + $dict = array( 66 + 'lint' => celerity_generate_unique_node_id(), 67 + 'commit' => celerity_generate_unique_node_id(), 68 + 'date' => celerity_generate_unique_node_id(), 69 + 'time' => celerity_generate_unique_node_id(), 70 + 'author' => celerity_generate_unique_node_id(), 71 + 'details' => celerity_generate_unique_node_id(), 72 + ); 173 73 174 - $need_pull[$base_path.$path->getPath().$dir_slash] = $dict; 175 - foreach ($dict as $k => $uniq) { 176 - $dict[$k] = phutil_tag('span', array('id' => $uniq), ''); 177 - } 74 + $need_pull[$base_path.$path->getPath().$dir_slash] = $dict; 75 + foreach ($dict as $k => $uniq) { 76 + $dict[$k] = phutil_tag('span', array('id' => $uniq), ''); 178 77 } 179 78 180 79 $editor_button = '';
+1 -1
src/applications/diffusion/view/DiffusionView.php
··· 144 144 "D{$id}"); 145 145 } 146 146 147 - final protected static function renderName($name) { 147 + final public static function renderName($name) { 148 148 $email = new PhutilEmailAddress($name); 149 149 if ($email->getDisplayName() && $email->getDomainName()) { 150 150 Javelin::initBehavior('phabricator-tooltips', array());
+3
webroot/rsrc/js/application/diffusion/behavior-pull-lastmodified.js
··· 13 13 .setHandler(function(r) { 14 14 for (var k in r) { 15 15 for (var l in r[k]) { 16 + if (!config.map[k][l]) { 17 + continue; 18 + } 16 19 JX.DOM.setContent(JX.$(config.map[k][l]), JX.$H(r[k][l])); 17 20 } 18 21 }