diff --git a/src/applications/pholio/query/PholioMockQuery.php b/src/applications/pholio/query/PholioMockQuery.php --- a/src/applications/pholio/query/PholioMockQuery.php +++ b/src/applications/pholio/query/PholioMockQuery.php @@ -59,10 +59,14 @@ $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 @@ 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 @@ return 'PhabricatorPholioApplication'; } + public function getPrimaryTableAlias() { + return 'mock'; + } + } diff --git a/src/applications/pholio/query/PholioMockSearchEngine.php b/src/applications/pholio/query/PholioMockSearchEngine.php --- a/src/applications/pholio/query/PholioMockSearchEngine.php +++ b/src/applications/pholio/query/PholioMockSearchEngine.php @@ -12,9 +12,15 @@ 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 @@ $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 @@ 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 @@ $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'))