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
This commit is contained in:
@@ -12,8 +12,11 @@ final class DiffusionLastModifiedController extends DiffusionController {
|
||||
|
||||
$paths = $request->getStr('paths');
|
||||
$paths = json_decode($paths, true);
|
||||
if (!is_array($paths)) {
|
||||
return new Aphront400Response();
|
||||
}
|
||||
|
||||
$output = array();
|
||||
$commits = array();
|
||||
foreach ($paths as $path) {
|
||||
$prequest = clone $drequest;
|
||||
$prequest->setPath($path);
|
||||
@@ -31,6 +34,8 @@ final class DiffusionLastModifiedController extends DiffusionController {
|
||||
$commit_data = PhabricatorRepositoryCommitData::newFromDictionary(
|
||||
$conduit_result['commitData']);
|
||||
|
||||
$commit->attachCommitData($commit_data);
|
||||
|
||||
$phids = array();
|
||||
if ($commit_data) {
|
||||
if ($commit_data->getCommitDetail('authorPHID')) {
|
||||
@@ -41,18 +46,110 @@ final class DiffusionLastModifiedController extends DiffusionController {
|
||||
}
|
||||
}
|
||||
|
||||
$phids = array_keys($phids);
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
$commits[$path] = $commit;
|
||||
}
|
||||
|
||||
$view = new DiffusionBrowseTableView();
|
||||
$view->setUser($request->getUser());
|
||||
$output[$path] = $view->renderLastModifiedColumns(
|
||||
$phids = array_keys($phids);
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
|
||||
$branch = $drequest->loadBranch();
|
||||
if ($branch) {
|
||||
$lint_query = id(new DiffusionLintCountQuery())
|
||||
->withBranchIDs(array($branch->getID()))
|
||||
->withPaths(array_keys($commits));
|
||||
|
||||
if ($drequest->getLint()) {
|
||||
$lint_query->withCodes(array($drequest->getLint()));
|
||||
}
|
||||
|
||||
$lint = $lint_query->execute();
|
||||
} else {
|
||||
$lint = array();
|
||||
}
|
||||
|
||||
$output = array();
|
||||
foreach ($commits as $path => $commit) {
|
||||
$prequest = clone $drequest;
|
||||
$prequest->setPath($path);
|
||||
|
||||
$output[$path] = $this->renderColumns(
|
||||
$prequest,
|
||||
$handles,
|
||||
$commit,
|
||||
$commit_data);
|
||||
idx($lint, $path));
|
||||
}
|
||||
|
||||
return id(new AphrontAjaxResponse())->setContent($output);
|
||||
}
|
||||
|
||||
private function renderColumns(
|
||||
DiffusionRequest $drequest,
|
||||
array $handles,
|
||||
PhabricatorRepositoryCommit $commit = null,
|
||||
$lint = null) {
|
||||
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
if ($commit) {
|
||||
$epoch = $commit->getEpoch();
|
||||
$modified = DiffusionView::linkCommit(
|
||||
$drequest->getRepository(),
|
||||
$commit->getCommitIdentifier());
|
||||
$date = phabricator_date($epoch, $viewer);
|
||||
$time = phabricator_time($epoch, $viewer);
|
||||
} else {
|
||||
$modified = '';
|
||||
$date = '';
|
||||
$time = '';
|
||||
}
|
||||
|
||||
$data = $commit->getCommitData();
|
||||
if ($data) {
|
||||
$author_phid = $data->getCommitDetail('authorPHID');
|
||||
if ($author_phid && isset($handles[$author_phid])) {
|
||||
$author = $handles[$author_phid]->renderLink();
|
||||
} else {
|
||||
$author = DiffusionView::renderName($data->getAuthorName());
|
||||
}
|
||||
|
||||
$committer = $data->getCommitDetail('committer');
|
||||
if ($committer) {
|
||||
$committer_phid = $data->getCommitDetail('committerPHID');
|
||||
if ($committer_phid && isset($handles[$committer_phid])) {
|
||||
$committer = $handles[$committer_phid]->renderLink();
|
||||
} else {
|
||||
$committer = DiffusionView::renderName($committer);
|
||||
}
|
||||
if ($author != $committer) {
|
||||
$author = hsprintf('%s/%s', $author, $committer);
|
||||
}
|
||||
}
|
||||
|
||||
$details = AphrontTableView::renderSingleDisplayLine($data->getSummary());
|
||||
} else {
|
||||
$author = '';
|
||||
$details = '';
|
||||
}
|
||||
|
||||
$return = array(
|
||||
'commit' => $modified,
|
||||
'date' => $date,
|
||||
'time' => $time,
|
||||
'author' => $author,
|
||||
'details' => $details,
|
||||
);
|
||||
|
||||
if ($lint !== null) {
|
||||
$return['lint'] = phutil_tag(
|
||||
'a',
|
||||
array('href' => $drequest->generateURI(array(
|
||||
'action' => 'lint',
|
||||
'lint' => null,
|
||||
))),
|
||||
number_format($lint));
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user