mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-02 01:48:23 +01:00
Display number of lint messages in Diffusion dir
Test Plan: Went to https://secure.phabricator.com/diffusion/ARC/browse/. Saw number of lint messages per dir, not terribly slow. Went to https://secure.phabricator.com/diffusion/ARC/browse/master/src/difference/. Saw number of lint messages per file. Disabled lint, didn't see it. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3921
This commit is contained in:
parent
47a184e2a5
commit
846a359d9a
4 changed files with 76 additions and 6 deletions
|
@ -70,7 +70,19 @@ final class DiffusionHomeController extends DiffusionController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$branch = new PhabricatorRepositoryBranch();
|
||||||
|
$lint_messages = queryfx_all(
|
||||||
|
$branch->establishConnection('r'),
|
||||||
|
'SELECT b.repositoryID, b.name, COUNT(lm.id) AS n
|
||||||
|
FROM %T b
|
||||||
|
LEFT JOIN %T lm ON b.id = lm.branchID
|
||||||
|
GROUP BY b.id',
|
||||||
|
$branch->getTableName(),
|
||||||
|
PhabricatorRepository::TABLE_LINTMESSAGE);
|
||||||
|
$lint_messages = igroup($lint_messages, 'repositoryID');
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
|
$show_lint = false;
|
||||||
foreach ($repositories as $repository) {
|
foreach ($repositories as $repository) {
|
||||||
$id = $repository->getID();
|
$id = $repository->getID();
|
||||||
$commit = idx($commits, $id);
|
$commit = idx($commits, $id);
|
||||||
|
@ -86,6 +98,13 @@ final class DiffusionHomeController extends DiffusionController {
|
||||||
number_format($size));
|
number_format($size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$lint_branches = ipull(idx($lint_messages, $id, array()), 'n', 'name');
|
||||||
|
$branch = $repository->getDefaultArcanistBranch();
|
||||||
|
|
||||||
|
if (isset($lint_branches[$branch])) {
|
||||||
|
$show_lint = true;
|
||||||
|
}
|
||||||
|
|
||||||
$date = '-';
|
$date = '-';
|
||||||
$time = '-';
|
$time = '-';
|
||||||
if ($commit) {
|
if ($commit) {
|
||||||
|
@ -104,6 +123,9 @@ final class DiffusionHomeController extends DiffusionController {
|
||||||
PhabricatorRepositoryType::getNameForRepositoryType(
|
PhabricatorRepositoryType::getNameForRepositoryType(
|
||||||
$repository->getVersionControlSystem()),
|
$repository->getVersionControlSystem()),
|
||||||
$size,
|
$size,
|
||||||
|
(isset($lint_branches[$branch])
|
||||||
|
? $lint_branches[$branch]
|
||||||
|
: ''),
|
||||||
$commit
|
$commit
|
||||||
? DiffusionView::linkCommit(
|
? DiffusionView::linkCommit(
|
||||||
$repository,
|
$repository,
|
||||||
|
@ -138,6 +160,7 @@ final class DiffusionHomeController extends DiffusionController {
|
||||||
'Description',
|
'Description',
|
||||||
'VCS',
|
'VCS',
|
||||||
'Commits',
|
'Commits',
|
||||||
|
'Lint',
|
||||||
'Last',
|
'Last',
|
||||||
'Date',
|
'Date',
|
||||||
'Time',
|
'Time',
|
||||||
|
@ -149,9 +172,21 @@ final class DiffusionHomeController extends DiffusionController {
|
||||||
'',
|
'',
|
||||||
'n',
|
'n',
|
||||||
'n',
|
'n',
|
||||||
|
'n',
|
||||||
'',
|
'',
|
||||||
'right',
|
'right',
|
||||||
));
|
));
|
||||||
|
$table->setColumnVisibility(
|
||||||
|
array(
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
$show_lint,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
));
|
||||||
|
|
||||||
$panel = new AphrontPanelView();
|
$panel = new AphrontPanelView();
|
||||||
$panel->setHeader('Browse Repositories');
|
$panel->setHeader('Browse Repositories');
|
||||||
|
|
|
@ -24,7 +24,7 @@ final class DiffusionLastModifiedController extends DiffusionController {
|
||||||
$handles = $this->loadViewerHandles($phids);
|
$handles = $this->loadViewerHandles($phids);
|
||||||
|
|
||||||
$output = DiffusionBrowseTableView::renderLastModifiedColumns(
|
$output = DiffusionBrowseTableView::renderLastModifiedColumns(
|
||||||
$drequest->getRepository(),
|
$drequest,
|
||||||
$handles,
|
$handles,
|
||||||
$commit,
|
$commit,
|
||||||
$commit_data);
|
$commit_data);
|
||||||
|
|
|
@ -24,7 +24,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function renderLastModifiedColumns(
|
public static function renderLastModifiedColumns(
|
||||||
PhabricatorRepository $repository,
|
DiffusionRequest $drequest,
|
||||||
array $handles,
|
array $handles,
|
||||||
PhabricatorRepositoryCommit $commit = null,
|
PhabricatorRepositoryCommit $commit = null,
|
||||||
PhabricatorRepositoryCommitData $data = null) {
|
PhabricatorRepositoryCommitData $data = null) {
|
||||||
|
@ -33,7 +33,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
if ($commit) {
|
if ($commit) {
|
||||||
$epoch = $commit->getEpoch();
|
$epoch = $commit->getEpoch();
|
||||||
$modified = DiffusionView::linkCommit(
|
$modified = DiffusionView::linkCommit(
|
||||||
$repository,
|
$drequest->getRepository(),
|
||||||
$commit->getCommitIdentifier());
|
$commit->getCommitIdentifier());
|
||||||
$date = date('M j, Y', $epoch);
|
$date = date('M j, Y', $epoch);
|
||||||
$time = date('g:i A', $epoch);
|
$time = date('g:i A', $epoch);
|
||||||
|
@ -71,13 +71,34 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
$details = '';
|
$details = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
$return = array(
|
||||||
'commit' => $modified,
|
'commit' => $modified,
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
'time' => $time,
|
'time' => $time,
|
||||||
'author' => $author,
|
'author' => $author,
|
||||||
'details' => $details,
|
'details' => $details,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$lint = self::loadLintMessagesCount($drequest);
|
||||||
|
if ($lint !== null) {
|
||||||
|
$return['lint'] = (string)$lint;
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function loadLintMessagesCount(DiffusionRequest $drequest) {
|
||||||
|
$branch = $drequest->loadBranch();
|
||||||
|
if (!$branch) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$like = (substr($drequest->getPath(), -1) == '/' ? 'LIKE %>' : '= %s');
|
||||||
|
return head(queryfx_one(
|
||||||
|
$drequest->getRepository()->establishConnection('r'),
|
||||||
|
'SELECT COUNT(*) FROM %T WHERE branchID = %d AND path '.$like,
|
||||||
|
PhabricatorRepository::TABLE_LINTMESSAGE,
|
||||||
|
$branch->getID(),
|
||||||
|
'/'.$drequest->getPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
|
@ -134,13 +155,16 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
|
|
||||||
$commit = $path->getLastModifiedCommit();
|
$commit = $path->getLastModifiedCommit();
|
||||||
if ($commit) {
|
if ($commit) {
|
||||||
|
$drequest = clone $request;
|
||||||
|
$drequest->setPath($path->getPath().$dir_slash);
|
||||||
$dict = self::renderLastModifiedColumns(
|
$dict = self::renderLastModifiedColumns(
|
||||||
$repository,
|
$drequest,
|
||||||
$this->handles,
|
$this->handles,
|
||||||
$commit,
|
$commit,
|
||||||
$path->getLastCommitData());
|
$path->getLastCommitData());
|
||||||
} else {
|
} else {
|
||||||
$dict = array(
|
$dict = array(
|
||||||
|
'lint' => celerity_generate_unique_node_id(),
|
||||||
'commit' => celerity_generate_unique_node_id(),
|
'commit' => celerity_generate_unique_node_id(),
|
||||||
'date' => celerity_generate_unique_node_id(),
|
'date' => celerity_generate_unique_node_id(),
|
||||||
'time' => celerity_generate_unique_node_id(),
|
'time' => celerity_generate_unique_node_id(),
|
||||||
|
@ -151,7 +175,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
$uri = (string)$request->generateURI(
|
$uri = (string)$request->generateURI(
|
||||||
array(
|
array(
|
||||||
'action' => 'lastmodified',
|
'action' => 'lastmodified',
|
||||||
'path' => $base_path.$path->getPath(),
|
'path' => $base_path.$path->getPath().$dir_slash,
|
||||||
));
|
));
|
||||||
|
|
||||||
$need_pull[$uri] = $dict;
|
$need_pull[$uri] = $dict;
|
||||||
|
@ -181,6 +205,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
$this->linkHistory($base_path.$path->getPath().$dir_slash),
|
$this->linkHistory($base_path.$path->getPath().$dir_slash),
|
||||||
$editor_button,
|
$editor_button,
|
||||||
$browse_link,
|
$browse_link,
|
||||||
|
$dict['lint'],
|
||||||
$dict['commit'],
|
$dict['commit'],
|
||||||
$dict['date'],
|
$dict['date'],
|
||||||
$dict['time'],
|
$dict['time'],
|
||||||
|
@ -193,12 +218,16 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
Javelin::initBehavior('diffusion-pull-lastmodified', $need_pull);
|
Javelin::initBehavior('diffusion-pull-lastmodified', $need_pull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$branch = $this->getDiffusionRequest()->loadBranch();
|
||||||
|
$show_lint = ($branch && $branch->getLintCommit());
|
||||||
|
|
||||||
$view = new AphrontTableView($rows);
|
$view = new AphrontTableView($rows);
|
||||||
$view->setHeaders(
|
$view->setHeaders(
|
||||||
array(
|
array(
|
||||||
'History',
|
'History',
|
||||||
'Edit',
|
'Edit',
|
||||||
'Path',
|
'Path',
|
||||||
|
'Lint',
|
||||||
'Modified',
|
'Modified',
|
||||||
'Date',
|
'Date',
|
||||||
'Time',
|
'Time',
|
||||||
|
@ -210,6 +239,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
|
'n',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'right',
|
'right',
|
||||||
|
@ -221,6 +251,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
true,
|
true,
|
||||||
$show_edit,
|
$show_edit,
|
||||||
true,
|
true,
|
||||||
|
$show_lint,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
|
|
|
@ -287,6 +287,10 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
||||||
return idx($default_branches, $this->getVersionControlSystem());
|
return idx($default_branches, $this->getVersionControlSystem());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDefaultArcanistBranch() {
|
||||||
|
return coalesce($this->getDefaultBranch(), 'svn');
|
||||||
|
}
|
||||||
|
|
||||||
private function isBranchInFilter($branch, $filter_key) {
|
private function isBranchInFilter($branch, $filter_key) {
|
||||||
$vcs = $this->getVersionControlSystem();
|
$vcs = $this->getVersionControlSystem();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue