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

Batch all supplementary information in Diffusion browse views

Summary: Ref T2683. Instead of sending one request for each path's history, send one request for all of it. This permits optimizations which are not currently available to us. It degrades the user experience a tiny bit in theory, but on my machine it's actually way faster already.

Test Plan: Loaded a browse page.

Reviewers: vrana, btrahan

Reviewed By: btrahan

Subscribers: epriestley, aran

Maniphest Tasks: T2683

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

+57 -51
+39 -36
src/applications/diffusion/controller/DiffusionLastModifiedController.php
··· 9 9 public function processRequest() { 10 10 $drequest = $this->getDiffusionRequest(); 11 11 $request = $this->getRequest(); 12 - $commit = null; 13 - $commit_data = null; 14 12 15 - $conduit_result = $this->callConduitWithDiffusionRequest( 16 - 'diffusion.lastmodifiedquery', 17 - array( 18 - 'commit' => $drequest->getCommit(), 19 - 'path' => $drequest->getPath() 20 - )); 21 - $c_dict = $conduit_result['commit']; 22 - if ($c_dict) { 23 - $commit = PhabricatorRepositoryCommit::newFromDictionary($c_dict); 24 - } 25 - $c_d_dict = $conduit_result['commitData']; 26 - if ($c_d_dict) { 27 - $commit_data = 28 - PhabricatorRepositoryCommitData::newFromDictionary($c_d_dict); 29 - } 13 + $paths = $request->getStr('paths'); 14 + $paths = json_decode($paths, true); 30 15 31 - $phids = array(); 32 - if ($commit_data) { 33 - if ($commit_data->getCommitDetail('authorPHID')) { 34 - $phids[$commit_data->getCommitDetail('authorPHID')] = true; 16 + $output = array(); 17 + foreach ($paths as $path) { 18 + $prequest = clone $drequest; 19 + $prequest->setPath($path); 20 + 21 + $conduit_result = $this->callConduitWithDiffusionRequest( 22 + 'diffusion.lastmodifiedquery', 23 + array( 24 + 'commit' => $prequest->getCommit(), 25 + 'path' => $prequest->getPath(), 26 + )); 27 + 28 + $commit = PhabricatorRepositoryCommit::newFromDictionary( 29 + $conduit_result['commit']); 30 + 31 + $commit_data = PhabricatorRepositoryCommitData::newFromDictionary( 32 + $conduit_result['commitData']); 33 + 34 + $phids = array(); 35 + if ($commit_data) { 36 + if ($commit_data->getCommitDetail('authorPHID')) { 37 + $phids[$commit_data->getCommitDetail('authorPHID')] = true; 38 + } 39 + if ($commit_data->getCommitDetail('committerPHID')) { 40 + $phids[$commit_data->getCommitDetail('committerPHID')] = true; 41 + } 35 42 } 36 - if ($commit_data->getCommitDetail('committerPHID')) { 37 - $phids[$commit_data->getCommitDetail('committerPHID')] = true; 38 - } 39 - } 40 43 41 - $phids = array_keys($phids); 42 - $handles = $this->loadViewerHandles($phids); 44 + $phids = array_keys($phids); 45 + $handles = $this->loadViewerHandles($phids); 43 46 44 - $view = new DiffusionBrowseTableView(); 45 - $view->setUser($request->getUser()); 46 - $output = $view->renderLastModifiedColumns( 47 - $drequest, 48 - $handles, 49 - $commit, 50 - $commit_data); 47 + $view = new DiffusionBrowseTableView(); 48 + $view->setUser($request->getUser()); 49 + $output[$path] = $view->renderLastModifiedColumns( 50 + $prequest, 51 + $handles, 52 + $commit, 53 + $commit_data); 54 + } 51 55 52 - return id(new AphrontAjaxResponse()) 53 - ->setContent($output); 56 + return id(new AphrontAjaxResponse())->setContent($output); 54 57 } 55 58 }
+10 -8
src/applications/diffusion/view/DiffusionBrowseTableView.php
··· 171 171 'details' => celerity_generate_unique_node_id(), 172 172 ); 173 173 174 - $uri = (string)$request->generateURI( 175 - array( 176 - 'action' => 'lastmodified', 177 - 'path' => $base_path.$path->getPath().$dir_slash, 178 - )); 179 - 180 - $need_pull[$uri] = $dict; 174 + $need_pull[$base_path.$path->getPath().$dir_slash] = $dict; 181 175 foreach ($dict as $k => $uniq) { 182 176 $dict[$k] = phutil_tag('span', array('id' => $uniq), ''); 183 177 } ··· 214 208 } 215 209 216 210 if ($need_pull) { 217 - Javelin::initBehavior('diffusion-pull-lastmodified', $need_pull); 211 + Javelin::initBehavior( 212 + 'diffusion-pull-lastmodified', 213 + array( 214 + 'uri' => (string)$request->generateURI( 215 + array( 216 + 'action' => 'lastmodified', 217 + )), 218 + 'map' => $need_pull, 219 + )); 218 220 } 219 221 220 222 $branch = $this->getDiffusionRequest()->loadBranch();
+8 -7
webroot/rsrc/js/application/diffusion/behavior-pull-lastmodified.js
··· 3 3 * @requires javelin-behavior 4 4 * javelin-dom 5 5 * javelin-util 6 - * javelin-request 6 + * javelin-workflow 7 + * javelin-json 7 8 */ 8 9 9 10 JX.behavior('diffusion-pull-lastmodified', function(config) { 10 11 11 - for (var uri in config) { 12 - new JX.Request(uri, JX.bind(config[uri], function(r) { 12 + new JX.Workflow(config.uri, {paths: JX.JSON.stringify(JX.keys(config.map))}) 13 + .setHandler(function(r) { 13 14 for (var k in r) { 14 - if (this[k]) { 15 - JX.DOM.setContent(JX.$(this[k]), JX.$H(r[k])); 15 + for (var l in r[k]) { 16 + JX.DOM.setContent(JX.$(config.map[k][l]), JX.$H(r[k][l])); 16 17 } 17 18 } 18 - })).send(); 19 - } 19 + }) 20 + .start(); 20 21 21 22 });