Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14069326
D13667.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D13667.diff
View Options
diff --git a/src/applications/ponder/query/PonderAnswerQuery.php b/src/applications/ponder/query/PonderAnswerQuery.php
--- a/src/applications/ponder/query/PonderAnswerQuery.php
+++ b/src/applications/ponder/query/PonderAnswerQuery.php
@@ -36,48 +36,39 @@
return $this;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
- if ($this->ids) {
+ if ($this->ids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'id IN (%Ld)',
$this->ids);
}
- if ($this->phids) {
+ if ($this->phids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'phid IN (%Ls)',
$this->phids);
}
- if ($this->authorPHIDs) {
+ if ($this->authorPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'authorPHID IN (%Ls)',
$this->authorPHIDs);
}
- $where[] = $this->buildPagingClause($conn_r);
+ return $where;
+ }
- return $this->formatWhereClause($where);
+ public function newResultObject() {
+ return new PonderAnswer();
}
protected function loadPage() {
- $answer = new PonderAnswer();
- $conn_r = $answer->establishConnection('r');
-
- $data = queryfx_all(
- $conn_r,
- 'SELECT a.* FROM %T a %Q %Q %Q',
- $answer->getTableName(),
- $this->buildWhereClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- return $answer->loadAllFromArray($data);
+ return $this->loadStandardPage(new PonderAnswer());
}
protected function willFilterPage(array $answers) {
diff --git a/src/applications/ponder/query/PonderQuestionQuery.php b/src/applications/ponder/query/PonderQuestionQuery.php
--- a/src/applications/ponder/query/PonderQuestionQuery.php
+++ b/src/applications/ponder/query/PonderQuestionQuery.php
@@ -9,6 +9,7 @@
private $answererPHIDs;
private $status = 'status-any';
+
const STATUS_ANY = 'status-any';
const STATUS_OPEN = 'status-open';
const STATUS_CLOSED = 'status-closed';
@@ -51,43 +52,43 @@
return $this;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
- if ($this->ids) {
+ if ($this->ids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'q.id IN (%Ld)',
$this->ids);
}
- if ($this->phids) {
+ if ($this->phids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'q.phid IN (%Ls)',
$this->phids);
}
- if ($this->authorPHIDs) {
+ if ($this->authorPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'q.authorPHID IN (%Ls)',
$this->authorPHIDs);
}
- if ($this->status) {
+ if ($this->status !== null) {
switch ($this->status) {
case self::STATUS_ANY:
break;
case self::STATUS_OPEN:
$where[] = qsprintf(
- $conn_r,
+ $conn,
'q.status = %d',
PonderQuestionStatus::STATUS_OPEN);
break;
case self::STATUS_CLOSED:
$where[] = qsprintf(
- $conn_r,
+ $conn,
'q.status = %d',
PonderQuestionStatus::STATUS_CLOSED);
break;
@@ -96,25 +97,15 @@
}
}
- $where[] = $this->buildPagingClause($conn_r);
+ return $where;
+ }
- return $this->formatWhereClause($where);
+ public function newResultObject() {
+ return new PonderQuestion();
}
protected function loadPage() {
- $question = new PonderQuestion();
- $conn_r = $question->establishConnection('r');
-
- $data = queryfx_all(
- $conn_r,
- 'SELECT q.* FROM %T q %Q %Q %Q %Q',
- $question->getTableName(),
- $this->buildJoinsClause($conn_r),
- $this->buildWhereClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- return $question->loadAllFromArray($data);
+ return $this->loadStandardPage(new PonderQuestion());
}
protected function willFilterPage(array $questions) {
@@ -175,6 +166,10 @@
return implode(' ', $joins);
}
+ protected function getPrimaryTableAlias() {
+ return 'q';
+ }
+
public function getQueryApplicationClass() {
return 'PhabricatorPonderApplication';
}
diff --git a/src/applications/ponder/query/PonderQuestionSearchEngine.php b/src/applications/ponder/query/PonderQuestionSearchEngine.php
--- a/src/applications/ponder/query/PonderQuestionSearchEngine.php
+++ b/src/applications/ponder/query/PonderQuestionSearchEngine.php
@@ -11,36 +11,22 @@
return 'PhabricatorPonderApplication';
}
- public function buildSavedQueryFromRequest(AphrontRequest $request) {
- $saved = new PhabricatorSavedQuery();
-
- $saved->setParameter(
- 'authorPHIDs',
- $this->readUsersFromRequest($request, 'authors'));
-
- $saved->setParameter(
- 'answererPHIDs',
- $this->readUsersFromRequest($request, 'answerers'));
-
- $saved->setParameter('status', $request->getStr('status'));
-
- return $saved;
+ public function newQuery() {
+ return new PonderQuestionQuery();
}
- public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
- $query = id(new PonderQuestionQuery());
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
- $author_phids = $saved->getParameter('authorPHIDs');
- if ($author_phids) {
- $query->withAuthorPHIDs($author_phids);
+ if ($map['authorPHIDs']) {
+ $query->withAuthorPHIDs($map['authorPHIDs']);
}
- $answerer_phids = $saved->getParameter('answererPHIDs');
- if ($answerer_phids) {
- $query->withAnswererPHIDs($answerer_phids);
+ if ($map['answerers']) {
+ $query->withAnswererPHIDs($map['answerers']);
}
- $status = $saved->getParameter('status');
+ $status = $map['status'];
if ($status != null) {
switch ($status) {
case 0:
@@ -55,34 +41,21 @@
return $query;
}
- public function buildSearchForm(
- AphrontFormView $form,
- PhabricatorSavedQuery $saved_query) {
-
- $author_phids = $saved_query->getParameter('authorPHIDs', array());
- $answerer_phids = $saved_query->getParameter('answererPHIDs', array());
- $status = $saved_query->getParameter(
- 'status', PonderQuestionStatus::STATUS_OPEN);
-
- $form
- ->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new PhabricatorPeopleDatasource())
- ->setName('authors')
- ->setLabel(pht('Authors'))
- ->setValue($author_phids))
- ->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new PhabricatorPeopleDatasource())
- ->setName('answerers')
- ->setLabel(pht('Answered By'))
- ->setValue($answerer_phids))
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setLabel(pht('Status'))
- ->setName('status')
- ->setValue($status)
- ->setOptions(PonderQuestionStatus::getQuestionStatusMap()));
+ protected function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorUsersSearchField())
+ ->setKey('authorPHIDs')
+ ->setAliases(array('authors'))
+ ->setLabel(pht('Authors')),
+ id(new PhabricatorUsersSearchField())
+ ->setKey('answerers')
+ ->setAliases(array('answerers'))
+ ->setLabel(pht('Answered By')),
+ id(new PhabricatorSearchSelectField())
+ ->setLabel(pht('Status'))
+ ->setKey('status')
+ ->setOptions(PonderQuestionStatus::getQuestionStatusMap()),
+ );
}
protected function getURI($path) {
@@ -104,7 +77,6 @@
}
public function buildSavedQueryFromBuiltin($query_key) {
-
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 5:23 AM (21 h, 47 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6714135
Default Alt Text
D13667.diff (8 KB)
Attached To
Mode
D13667: Modernize Ponder Search
Attached
Detach File
Event Timeline
Log In to Comment