mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Parameterize search in Pholio
Summary: Ref T4100. Ref T5595. - Add project query + edgelogic support. - Support user selector functions. Test Plan: - Used search to find stuff. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5595, T4100 Differential Revision: https://secure.phabricator.com/D12531
This commit is contained in:
parent
f64ca87bfe
commit
e094af4618
2 changed files with 49 additions and 14 deletions
|
@ -59,10 +59,14 @@ final class PholioMockQuery
|
|||
|
||||
$data = queryfx_all(
|
||||
$conn_r,
|
||||
'SELECT * FROM %T %Q %Q %Q',
|
||||
'%Q FROM %T mock %Q %Q %Q %Q %Q %Q',
|
||||
$this->buildSelectClause($conn_r),
|
||||
$table->getTableName(),
|
||||
$this->buildJoinClause($conn_r),
|
||||
$this->buildWhereClause($conn_r),
|
||||
$this->buildGroupClause($conn_r),
|
||||
$this->buildOrderClause($conn_r),
|
||||
$this->buildHavingClause($conn_r),
|
||||
$this->buildLimitClause($conn_r));
|
||||
|
||||
$mocks = $table->loadAllFromArray($data);
|
||||
|
@ -85,33 +89,33 @@ final class PholioMockQuery
|
|||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
|
||||
$where = array();
|
||||
|
||||
$where[] = $this->buildPagingClause($conn_r);
|
||||
$where[] = $this->buildWhereClauseParts($conn_r);
|
||||
|
||||
if ($this->ids) {
|
||||
if ($this->ids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'id IN (%Ld)',
|
||||
'mock.id IN (%Ld)',
|
||||
$this->ids);
|
||||
}
|
||||
|
||||
if ($this->phids) {
|
||||
if ($this->phids !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'phid IN (%Ls)',
|
||||
'mock.phid IN (%Ls)',
|
||||
$this->phids);
|
||||
}
|
||||
|
||||
if ($this->authorPHIDs) {
|
||||
if ($this->authorPHIDs !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'authorPHID in (%Ls)',
|
||||
'mock.authorPHID in (%Ls)',
|
||||
$this->authorPHIDs);
|
||||
}
|
||||
|
||||
if ($this->statuses) {
|
||||
if ($this->statuses !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'status IN (%Ls)',
|
||||
'mock.status IN (%Ls)',
|
||||
$this->statuses);
|
||||
}
|
||||
|
||||
|
@ -178,4 +182,8 @@ final class PholioMockQuery
|
|||
return 'PhabricatorPholioApplication';
|
||||
}
|
||||
|
||||
public function getPrimaryTableAlias() {
|
||||
return 'mock';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,9 +12,15 @@ final class PholioMockSearchEngine extends PhabricatorApplicationSearchEngine {
|
|||
|
||||
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
||||
$saved = new PhabricatorSavedQuery();
|
||||
|
||||
$saved->setParameter(
|
||||
'authorPHIDs',
|
||||
$this->readUsersFromRequest($request, 'authors'));
|
||||
|
||||
$saved->setParameter(
|
||||
'projects',
|
||||
$this->readProjectsFromRequest($request, 'projects'));
|
||||
|
||||
$saved->setParameter(
|
||||
'statuses',
|
||||
$request->getStrList('status'));
|
||||
|
@ -26,9 +32,23 @@ final class PholioMockSearchEngine extends PhabricatorApplicationSearchEngine {
|
|||
$query = id(new PholioMockQuery())
|
||||
->needCoverFiles(true)
|
||||
->needImages(true)
|
||||
->needTokenCounts(true)
|
||||
->withAuthorPHIDs($saved->getParameter('authorPHIDs', array()))
|
||||
->withStatuses($saved->getParameter('statuses', array()));
|
||||
->needTokenCounts(true);
|
||||
|
||||
$datasource = id(new PhabricatorTypeaheadUserParameterizedDatasource())
|
||||
->setViewer($this->requireViewer());
|
||||
|
||||
$author_phids = $saved->getParameter('authorPHIDs', array());
|
||||
$author_phids = $datasource->evaluateTokens($author_phids);
|
||||
if ($author_phids) {
|
||||
$query->withAuthorPHIDs($author_phids);
|
||||
}
|
||||
|
||||
$statuses = $saved->getParameter('statuses', array());
|
||||
if ($statuses) {
|
||||
$query->withStatuses($statuses);
|
||||
}
|
||||
|
||||
$this->setQueryProjects($query, $saved);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
@ -38,6 +58,7 @@ final class PholioMockSearchEngine extends PhabricatorApplicationSearchEngine {
|
|||
PhabricatorSavedQuery $saved_query) {
|
||||
|
||||
$author_phids = $saved_query->getParameter('authorPHIDs', array());
|
||||
$projects = $saved_query->getParameter('projects', array());
|
||||
|
||||
$statuses = array(
|
||||
'' => pht('Any Status'),
|
||||
|
@ -51,10 +72,16 @@ final class PholioMockSearchEngine extends PhabricatorApplicationSearchEngine {
|
|||
$form
|
||||
->appendControl(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource(new PhabricatorPeopleDatasource())
|
||||
->setDatasource(new PhabricatorTypeaheadUserParameterizedDatasource())
|
||||
->setName('authors')
|
||||
->setLabel(pht('Authors'))
|
||||
->setValue($author_phids))
|
||||
->appendControl(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource(new PhabricatorProjectLogicalDatasource())
|
||||
->setName('projects')
|
||||
->setLabel(pht('Projects'))
|
||||
->setValue($projects))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Status'))
|
||||
|
|
Loading…
Reference in a new issue