mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Audit - add ability to query by repositories
Summary: Fixes T5862. The Diffusion table uses `id` but all the other infrastructure uses `phid` so just do a quick load of the repositories to get the ids. Long term, we should re-key the table by phid I think. Test Plan: made a query with a repository and got a proper result set Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T5862 Differential Revision: https://secure.phabricator.com/D10245
This commit is contained in:
parent
ea3aeb4962
commit
644e950ea3
2 changed files with 38 additions and 2 deletions
|
@ -59,6 +59,14 @@ final class PhabricatorCommitSearchEngine
|
|||
$query->withAuditAwaitingUser($this->requireViewer());
|
||||
}
|
||||
|
||||
$repository_phids = $saved->getParameter('repositoryPHIDs', array());
|
||||
if ($repository_phids) {
|
||||
// $repository_phids need to be mapped to $repository_ids via a subquery
|
||||
// so make sure $viewer is set...!
|
||||
$query->setViewer($this->requireViewer());
|
||||
$query->withRepositoryPHIDs($repository_phids);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@ -71,11 +79,13 @@ final class PhabricatorCommitSearchEngine
|
|||
'commitAuthorPHIDs',
|
||||
array());
|
||||
$audit_status = $saved->getParameter('auditStatus', null);
|
||||
$repository_phids = $saved->getParameter('repositoryPHIDs', array());
|
||||
|
||||
$phids = array_mergev(
|
||||
array(
|
||||
$auditor_phids,
|
||||
$commit_author_phids));
|
||||
$commit_author_phids,
|
||||
$repository_phids));
|
||||
|
||||
$handles = id(new PhabricatorHandleQuery())
|
||||
->setViewer($this->requireViewer())
|
||||
|
@ -100,7 +110,14 @@ final class PhabricatorCommitSearchEngine
|
|||
->setName('auditStatus')
|
||||
->setLabel(pht('Audit Status'))
|
||||
->setOptions($this->getAuditStatusOptions())
|
||||
->setValue($audit_status));
|
||||
->setValue($audit_status))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel(pht('Repositories'))
|
||||
->setName('repositoryPHIDs')
|
||||
->setDatasource(new DiffusionRepositoryDatasource())
|
||||
->setValue(array_select_keys($handles, $repository_phids)));
|
||||
|
||||
}
|
||||
|
||||
protected function getURI($path) {
|
||||
|
|
|
@ -59,6 +59,25 @@ final class DiffusionCommitQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up commits in a specific repository. Prefer
|
||||
* @{method:withRepositoryIDs}; the underyling table is keyed by ID such
|
||||
* that this method requires a separate initial query to map PHID to ID.
|
||||
* Furthermore, this method requires calling @{method:setViewer} in
|
||||
* advance due to the separate query.
|
||||
*/
|
||||
public function withRepositoryPHIDs(array $phids) {
|
||||
$repositories = id (new PhabricatorRepositoryQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withPHIDs($phids)
|
||||
->execute();
|
||||
|
||||
if (!$repositories) {
|
||||
throw new PhabricatorEmptyQueryException();
|
||||
}
|
||||
$this->withRepositoryIDs(mpull($repositories, 'getID'));
|
||||
}
|
||||
|
||||
/**
|
||||
* If a default repository is provided, ambiguous commit identifiers will
|
||||
* be assumed to belong to the default repository.
|
||||
|
|
Loading…
Reference in a new issue