From ed126cd47ed093beba9e0b8efaee4d01615d11d3 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 16 Sep 2013 16:03:09 -0700 Subject: [PATCH] Provide ApplicationSearch hooks in Maniphest Summary: Ref T418. Adds hooks to support customized ApplicationSearch (you can't currently add indexable fields without writing custom code). Test Plan: Wrote custom code to add an indexable field. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T418 Differential Revision: https://secure.phabricator.com/D7002 --- .../maniphest/query/ManiphestTaskQuery.php | 17 ++++++++++++----- .../query/ManiphestTaskSearchEngine.php | 10 ++++++++++ .../people/query/PhabricatorPeopleQuery.php | 2 ++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php index 7b92e7f7d1..e3aa8075fb 100644 --- a/src/applications/maniphest/query/ManiphestTaskQuery.php +++ b/src/applications/maniphest/query/ManiphestTaskQuery.php @@ -718,22 +718,25 @@ final class ManiphestTaskQuery break; } + $joins[] = $this->buildApplicationSearchJoinClause($conn_r); + return implode(' ', $joins); } private function buildGroupClause(AphrontDatabaseConnection $conn_r) { - $joined_multiple_project_rows = (count($this->projectPHIDs) > 1) || - (count($this->anyProjectPHIDs) > 1); + $joined_multiple_rows = (count($this->projectPHIDs) > 1) || + (count($this->anyProjectPHIDs) > 1) || + ($this->getApplicationSearchMayJoinMultipleRows()); $joined_project_name = ($this->groupBy == self::GROUP_PROJECT); // If we're joining multiple rows, we need to group the results by the // task IDs. - if ($joined_multiple_project_rows) { + if ($joined_multiple_rows) { if ($joined_project_name) { - return 'GROUP BY task.id, projectGroup.projectPHID'; + return 'GROUP BY task.phid, projectGroup.projectPHID'; } else { - return 'GROUP BY task.id'; + return 'GROUP BY task.phid'; } } else { return ''; @@ -950,4 +953,8 @@ final class ManiphestTaskQuery )); } + protected function getApplicationSearchObjectPHIDColumn() { + return 'task.phid'; + } + } diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php index e2a5ed795f..3adfc8d7be 100644 --- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php +++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php @@ -3,6 +3,10 @@ final class ManiphestTaskSearchEngine extends PhabricatorApplicationSearchEngine { + public function getCustomFieldObject() { + return new ManiphestTask(); + } + public function buildSavedQueryFromRequest(AphrontRequest $request) { $saved = new PhabricatorSavedQuery(); @@ -62,6 +66,8 @@ final class ManiphestTaskSearchEngine $saved->setParameter('limit', $limit); } + $this->readCustomFieldsFromRequest($request, $saved); + return $saved; } @@ -155,6 +161,8 @@ final class ManiphestTaskSearchEngine $query->withDateCreatedBefore($end); } + $this->applyCustomFieldsToQuery($query, $saved); + return $query; } @@ -308,6 +316,8 @@ final class ManiphestTaskSearchEngine ->setLabel(pht('Task IDs')) ->setValue(implode(', ', $ids))); + $this->appendCustomFieldsToForm($form, $saved); + $this->buildDateRange( $form, $saved, diff --git a/src/applications/people/query/PhabricatorPeopleQuery.php b/src/applications/people/query/PhabricatorPeopleQuery.php index 0fafe6c484..3bdfdb1a4c 100644 --- a/src/applications/people/query/PhabricatorPeopleQuery.php +++ b/src/applications/people/query/PhabricatorPeopleQuery.php @@ -266,6 +266,8 @@ final class PhabricatorPeopleQuery $this->nameLike); } + $where[] = $this->buildPagingClause($conn_r); + return $this->formatWhereClause($where); }