1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20:55 +01:00

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
This commit is contained in:
epriestley 2014-05-10 15:32:53 -07:00
parent ac020bc420
commit df59f4b047
3 changed files with 58 additions and 52 deletions

View file

@ -9,24 +9,27 @@ final class DiffusionLastModifiedController extends DiffusionController {
public function processRequest() {
$drequest = $this->getDiffusionRequest();
$request = $this->getRequest();
$commit = null;
$commit_data = null;
$paths = $request->getStr('paths');
$paths = json_decode($paths, true);
$output = array();
foreach ($paths as $path) {
$prequest = clone $drequest;
$prequest->setPath($path);
$conduit_result = $this->callConduitWithDiffusionRequest(
'diffusion.lastmodifiedquery',
array(
'commit' => $drequest->getCommit(),
'path' => $drequest->getPath()
'commit' => $prequest->getCommit(),
'path' => $prequest->getPath(),
));
$c_dict = $conduit_result['commit'];
if ($c_dict) {
$commit = PhabricatorRepositoryCommit::newFromDictionary($c_dict);
}
$c_d_dict = $conduit_result['commitData'];
if ($c_d_dict) {
$commit_data =
PhabricatorRepositoryCommitData::newFromDictionary($c_d_dict);
}
$commit = PhabricatorRepositoryCommit::newFromDictionary(
$conduit_result['commit']);
$commit_data = PhabricatorRepositoryCommitData::newFromDictionary(
$conduit_result['commitData']);
$phids = array();
if ($commit_data) {
@ -43,13 +46,13 @@ final class DiffusionLastModifiedController extends DiffusionController {
$view = new DiffusionBrowseTableView();
$view->setUser($request->getUser());
$output = $view->renderLastModifiedColumns(
$drequest,
$output[$path] = $view->renderLastModifiedColumns(
$prequest,
$handles,
$commit,
$commit_data);
}
return id(new AphrontAjaxResponse())
->setContent($output);
return id(new AphrontAjaxResponse())->setContent($output);
}
}

View file

@ -171,13 +171,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
'details' => celerity_generate_unique_node_id(),
);
$uri = (string)$request->generateURI(
array(
'action' => 'lastmodified',
'path' => $base_path.$path->getPath().$dir_slash,
));
$need_pull[$uri] = $dict;
$need_pull[$base_path.$path->getPath().$dir_slash] = $dict;
foreach ($dict as $k => $uniq) {
$dict[$k] = phutil_tag('span', array('id' => $uniq), '');
}
@ -214,7 +208,15 @@ final class DiffusionBrowseTableView extends DiffusionView {
}
if ($need_pull) {
Javelin::initBehavior('diffusion-pull-lastmodified', $need_pull);
Javelin::initBehavior(
'diffusion-pull-lastmodified',
array(
'uri' => (string)$request->generateURI(
array(
'action' => 'lastmodified',
)),
'map' => $need_pull,
));
}
$branch = $this->getDiffusionRequest()->loadBranch();

View file

@ -3,19 +3,20 @@
* @requires javelin-behavior
* javelin-dom
* javelin-util
* javelin-request
* javelin-workflow
* javelin-json
*/
JX.behavior('diffusion-pull-lastmodified', function(config) {
for (var uri in config) {
new JX.Request(uri, JX.bind(config[uri], function(r) {
new JX.Workflow(config.uri, {paths: JX.JSON.stringify(JX.keys(config.map))})
.setHandler(function(r) {
for (var k in r) {
if (this[k]) {
JX.DOM.setContent(JX.$(this[k]), JX.$H(r[k]));
for (var l in r[k]) {
JX.DOM.setContent(JX.$(config.map[k][l]), JX.$H(r[k][l]));
}
}
})).send();
}
})
.start();
});