From 01ed526527b36386ae474298c51931c0f8f0d62e Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 7 Mar 2016 15:24:59 -0800 Subject: [PATCH] Modernize Nuance queries and search engines Summary: Ref T10537. Minor updates to simplify and modernize these codepaths. Test Plan: Searched for queues and sources. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10537 Differential Revision: https://secure.phabricator.com/D15429 --- .../query/AlmanacServiceSearchEngine.php | 4 ---- .../nuance/query/NuanceQueueQuery.php | 18 +++++------------- .../nuance/query/NuanceQueueSearchEngine.php | 16 +++++++--------- .../nuance/query/NuanceSourceQuery.php | 18 +++++------------- .../nuance/query/NuanceSourceSearchEngine.php | 16 +++++++--------- 5 files changed, 24 insertions(+), 48 deletions(-) diff --git a/src/applications/almanac/query/AlmanacServiceSearchEngine.php b/src/applications/almanac/query/AlmanacServiceSearchEngine.php index 1a9509a2c2..a2fd9c23b7 100644 --- a/src/applications/almanac/query/AlmanacServiceSearchEngine.php +++ b/src/applications/almanac/query/AlmanacServiceSearchEngine.php @@ -15,10 +15,6 @@ final class AlmanacServiceSearchEngine return new AlmanacServiceQuery(); } - public function newResultObject() { - return new AlmanacService(); - } - protected function buildQueryFromParameters(array $map) { $query = $this->newQuery(); diff --git a/src/applications/nuance/query/NuanceQueueQuery.php b/src/applications/nuance/query/NuanceQueueQuery.php index d50e393667..10f761d189 100644 --- a/src/applications/nuance/query/NuanceQueueQuery.php +++ b/src/applications/nuance/query/NuanceQueueQuery.php @@ -16,20 +16,12 @@ final class NuanceQueueQuery return $this; } + public function newResultObject() { + return new NuanceQueue(); + } + protected function loadPage() { - $table = new NuanceQueue(); - $conn = $table->establishConnection('r'); - - $data = queryfx_all( - $conn, - '%Q FROM %T %Q %Q %Q', - $this->buildSelectClause($conn), - $table->getTableName(), - $this->buildWhereClause($conn), - $this->buildOrderClause($conn), - $this->buildLimitClause($conn)); - - return $table->loadAllFromArray($data); + return $this->loadStandardPage($this->newResultObject()); } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { diff --git a/src/applications/nuance/query/NuanceQueueSearchEngine.php b/src/applications/nuance/query/NuanceQueueSearchEngine.php index 12259982f1..2f794c2a9c 100644 --- a/src/applications/nuance/query/NuanceQueueSearchEngine.php +++ b/src/applications/nuance/query/NuanceQueueSearchEngine.php @@ -11,21 +11,19 @@ final class NuanceQueueSearchEngine return pht('Nuance Queues'); } - public function buildSavedQueryFromRequest(AphrontRequest $request) { - $saved = new PhabricatorSavedQuery(); - - return $saved; + public function newQuery() { + return new NuanceQueueQuery(); } - public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { - $query = id(new NuanceQueueQuery()); + protected function buildQueryFromParameters(array $map) { + $query = $this->newQuery(); return $query; } - public function buildSearchForm( - AphrontFormView $form, - PhabricatorSavedQuery $saved_query) {} + protected function buildCustomSearchFields() { + return array(); + } protected function getURI($path) { return '/nuance/queue/'.$path; diff --git a/src/applications/nuance/query/NuanceSourceQuery.php b/src/applications/nuance/query/NuanceSourceQuery.php index ee4b964ee3..6fbc4d3ddf 100644 --- a/src/applications/nuance/query/NuanceSourceQuery.php +++ b/src/applications/nuance/query/NuanceSourceQuery.php @@ -22,20 +22,12 @@ final class NuanceSourceQuery return $this; } + public function newResultObject() { + return new NuanceSource(); + } + protected function loadPage() { - $table = new NuanceSource(); - $conn = $table->establishConnection('r'); - - $data = queryfx_all( - $conn, - '%Q FROM %T %Q %Q %Q', - $this->buildSelectClause($conn), - $table->getTableName(), - $this->buildWhereClause($conn), - $this->buildOrderClause($conn), - $this->buildLimitClause($conn)); - - return $table->loadAllFromArray($data); + return $this->loadStandardPage($this->newResultObject()); } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { diff --git a/src/applications/nuance/query/NuanceSourceSearchEngine.php b/src/applications/nuance/query/NuanceSourceSearchEngine.php index 02a8b502fb..2991c69c5f 100644 --- a/src/applications/nuance/query/NuanceSourceSearchEngine.php +++ b/src/applications/nuance/query/NuanceSourceSearchEngine.php @@ -11,21 +11,19 @@ final class NuanceSourceSearchEngine return pht('Nuance Sources'); } - public function buildSavedQueryFromRequest(AphrontRequest $request) { - $saved = new PhabricatorSavedQuery(); - - return $saved; + public function newQuery() { + return new NuanceSourceQuery(); } - public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { - $query = id(new NuanceSourceQuery()); + protected function buildQueryFromParameters(array $map) { + $query = $this->newQuery(); return $query; } - public function buildSearchForm( - AphrontFormView $form, - PhabricatorSavedQuery $saved_query) {} + protected function buildCustomSearchFields() { + return array(); + } protected function getURI($path) { return '/nuance/source/'.$path;