mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 23:01:04 +01:00
Filter all lint messages by owner
Summary: Also add link to this page. Test Plan: /diffusion/lint/ /diffusion/lint/?owner[0]=a (zero lint messages) /diffusion/lint/?owner[0]=b (nonzero lint messages) Clicked the link. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4069
This commit is contained in:
parent
8584b87df4
commit
3645dc2dd9
2 changed files with 83 additions and 7 deletions
|
@ -4,18 +4,31 @@
|
||||||
final class DiffusionLintController extends DiffusionController {
|
final class DiffusionLintController extends DiffusionController {
|
||||||
|
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$user = $this->getRequest()->getUser();
|
||||||
$drequest = $this->diffusionRequest;
|
$drequest = $this->diffusionRequest;
|
||||||
|
|
||||||
if ($this->getRequest()->getStr('lint') !== null) {
|
if ($request->getStr('lint') !== null) {
|
||||||
$controller = new DiffusionLintDetailsController($this->getRequest());
|
$controller = new DiffusionLintDetailsController($request);
|
||||||
$controller->setDiffusionRequest($drequest);
|
$controller->setDiffusionRequest($drequest);
|
||||||
return $this->delegateToController($controller);
|
return $this->delegateToController($controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
$codes = $this->loadLintCodes();
|
$owners = array();
|
||||||
$codes = array_reverse(isort($codes, 'n'));
|
|
||||||
|
|
||||||
if (!$drequest) {
|
if (!$drequest) {
|
||||||
|
if (!$request->getArr('owner')) {
|
||||||
|
$owners[$user->getPHID()] = $user->getFullName();
|
||||||
|
} else {
|
||||||
|
$phids = $request->getArr('owner');
|
||||||
|
$phid = reset($phids);
|
||||||
|
$handles = $this->loadViewerHandles(array($phid));
|
||||||
|
$owners[$phid] = $handles[$phid]->getFullName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$codes = $this->loadLintCodes(array_keys($owners));
|
||||||
|
|
||||||
|
if ($codes && !$drequest) {
|
||||||
$branches = id(new PhabricatorRepositoryBranch())->loadAllWhere(
|
$branches = id(new PhabricatorRepositoryBranch())->loadAllWhere(
|
||||||
'id IN (%Ld)',
|
'id IN (%Ld)',
|
||||||
array_unique(ipull($codes, 'branchID')));
|
array_unique(ipull($codes, 'branchID')));
|
||||||
|
@ -88,6 +101,7 @@ final class DiffusionLintController extends DiffusionController {
|
||||||
'view' => 'lint',
|
'view' => 'lint',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
$link = null;
|
$link = null;
|
||||||
if ($this->diffusionRequest) {
|
if ($this->diffusionRequest) {
|
||||||
$link = hsprintf(
|
$link = hsprintf(
|
||||||
|
@ -97,6 +111,22 @@ final class DiffusionLintController extends DiffusionController {
|
||||||
'lint' => '',
|
'lint' => '',
|
||||||
)),
|
)),
|
||||||
pht('Switch to List View'));
|
pht('Switch to List View'));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$form = id(new AphrontFormView())
|
||||||
|
->setUser($user)
|
||||||
|
->setMethod('GET')
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTokenizerControl())
|
||||||
|
->setDatasource('/typeahead/common/users/')
|
||||||
|
->setLimit(1)
|
||||||
|
->setName('owner')
|
||||||
|
->setLabel('Owner')
|
||||||
|
->setValue($owners))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormSubmitControl())
|
||||||
|
->setValue('Filter'));
|
||||||
|
$content[] = id(new AphrontListFilterView())->appendChild($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content[] = id(new AphrontPanelView())
|
$content[] = id(new AphrontPanelView())
|
||||||
|
@ -115,7 +145,7 @@ final class DiffusionLintController extends DiffusionController {
|
||||||
array('title' => $title));
|
array('title' => $title));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadLintCodes() {
|
private function loadLintCodes(array $owner_phids) {
|
||||||
$drequest = $this->diffusionRequest;
|
$drequest = $this->diffusionRequest;
|
||||||
$conn = id(new PhabricatorRepository())->establishConnection('r');
|
$conn = id(new PhabricatorRepository())->establishConnection('r');
|
||||||
$where = array('1 = 1');
|
$where = array('1 = 1');
|
||||||
|
@ -137,6 +167,46 @@ final class DiffusionLintController extends DiffusionController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($owner_phids) {
|
||||||
|
$packages = id(new PhabricatorOwnersOwner())
|
||||||
|
->loadAllWhere('userPHID IN (%Ls)', $owner_phids);
|
||||||
|
if (!$packages) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$paths = id(new PhabricatorOwnersPath())
|
||||||
|
->loadAllWhere('packageID IN (%Ld)', array_keys($packages));
|
||||||
|
if (!$paths) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$repositories = id(new PhabricatorRepository())->loadAllWhere(
|
||||||
|
'phid IN (%Ls)',
|
||||||
|
array_unique(mpull($paths, 'getRepositoryPHID')));
|
||||||
|
$repositories = mpull($repositories, 'getID', 'getPHID');
|
||||||
|
|
||||||
|
$branches = id(new PhabricatorRepositoryBranch())->loadAllWhere(
|
||||||
|
'repositoryID IN (%Ld)',
|
||||||
|
$repositories);
|
||||||
|
$branches = mgroup($branches, 'getRepositoryID');
|
||||||
|
|
||||||
|
$or = array();
|
||||||
|
foreach ($paths as $path) {
|
||||||
|
$branch = idx($branches, $repositories[$path->getRepositoryPHID()]);
|
||||||
|
if ($branch) {
|
||||||
|
$or[] = qsprintf(
|
||||||
|
$conn,
|
||||||
|
'(branchID IN (%Ld) AND path LIKE %>)',
|
||||||
|
array_keys($branch),
|
||||||
|
$path->getPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$or) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
$where[] = '('.implode(' OR ', $or).')';
|
||||||
|
}
|
||||||
|
|
||||||
return queryfx_all(
|
return queryfx_all(
|
||||||
$conn,
|
$conn,
|
||||||
'SELECT
|
'SELECT
|
||||||
|
@ -149,7 +219,8 @@ final class DiffusionLintController extends DiffusionController {
|
||||||
COUNT(*) AS n
|
COUNT(*) AS n
|
||||||
FROM %T
|
FROM %T
|
||||||
WHERE %Q
|
WHERE %Q
|
||||||
GROUP BY branchID, code',
|
GROUP BY branchID, code
|
||||||
|
ORDER BY n DESC',
|
||||||
PhabricatorRepository::TABLE_LINTMESSAGE,
|
PhabricatorRepository::TABLE_LINTMESSAGE,
|
||||||
implode(' AND ', $where));
|
implode(' AND ', $where));
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,11 @@ final class PhabricatorPeopleProfileController
|
||||||
"Commits {$external_arrow}",
|
"Commits {$external_arrow}",
|
||||||
'/audit/view/author/'.$username.'/');
|
'/audit/view/author/'.$username.'/');
|
||||||
|
|
||||||
|
$nav->addFilter(
|
||||||
|
null,
|
||||||
|
"Lint Messages {$external_arrow}",
|
||||||
|
'/diffusion/lint/?owner[0]='.$user->getPHID());
|
||||||
|
|
||||||
$oauths = id(new PhabricatorUserOAuthInfo())->loadAllWhere(
|
$oauths = id(new PhabricatorUserOAuthInfo())->loadAllWhere(
|
||||||
'userID = %d',
|
'userID = %d',
|
||||||
$user->getID());
|
$user->getID());
|
||||||
|
|
Loading…
Reference in a new issue