Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13993242
D13666.id33084.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D13666.id33084.diff
View Options
diff --git a/src/applications/slowvote/query/PhabricatorSlowvoteQuery.php b/src/applications/slowvote/query/PhabricatorSlowvoteQuery.php
--- a/src/applications/slowvote/query/PhabricatorSlowvoteQuery.php
+++ b/src/applications/slowvote/query/PhabricatorSlowvoteQuery.php
@@ -53,20 +53,12 @@
return $this;
}
+ public function newResultObject() {
+ return new PhabricatorSlowvotePoll();
+ }
+
protected function loadPage() {
- $table = new PhabricatorSlowvotePoll();
- $conn_r = $table->establishConnection('r');
-
- $data = queryfx_all(
- $conn_r,
- 'SELECT p.* FROM %T p %Q %Q %Q %Q',
- $table->getTableName(),
- $this->buildJoinsClause($conn_r),
- $this->buildWhereClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- return $table->loadAllFromArray($data);
+ return $this->loadStandardPage($this->newResultObject());
}
protected function willFilterPage(array $polls) {
@@ -125,53 +117,50 @@
return $polls;
}
- 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,
'p.id IN (%Ld)',
$this->ids);
}
- if ($this->phids) {
+ if ($this->phids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'p.phid IN (%Ls)',
$this->phids);
}
- if ($this->authorPHIDs) {
+ if ($this->authorPHIDs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'p.authorPHID IN (%Ls)',
$this->authorPHIDs);
}
if ($this->isClosed !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'p.isClosed = %d',
(int)$this->isClosed);
}
-
- $where[] = $this->buildPagingClause($conn_r);
- return $this->formatWhereClause($where);
+ return $where;
}
- private function buildJoinsClause(AphrontDatabaseConnection $conn_r) {
- $joins = array();
+ protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {
+ $joins = parent::buildJoinClauseParts($conn);
- if ($this->withVotesByViewer) {
+ if ($this->withVotesByViewer !== null) {
$joins[] = qsprintf(
- $conn_r,
+ $conn,
'JOIN %T vv ON vv.pollID = p.id AND vv.authorPHID = %s',
id(new PhabricatorSlowvoteChoice())->getTableName(),
$this->getViewer()->getPHID());
}
-
- return implode(' ', $joins);
+ return $joins;
}
protected function getPrimaryTableAlias() {
diff --git a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php
--- a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php
+++ b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php
@@ -11,27 +11,22 @@
return 'PhabricatorSlowvoteApplication';
}
- public function buildSavedQueryFromRequest(AphrontRequest $request) {
- $saved = new PhabricatorSavedQuery();
- $saved->setParameter(
- 'authorPHIDs',
- $this->readUsersFromRequest($request, 'authors'));
-
- $saved->setParameter('voted', $request->getBool('voted'));
- $saved->setParameter('statuses', $request->getArr('statuses'));
-
- return $saved;
+ public function newQuery() {
+ return new PhabricatorSlowvoteQuery();
}
- public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
- $query = id(new PhabricatorSlowvoteQuery())
- ->withAuthorPHIDs($saved->getParameter('authorPHIDs', array()));
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
- if ($saved->getParameter('voted')) {
+ if ($map['voted']) {
$query->withVotesByViewer(true);
}
- $statuses = $saved->getParameter('statuses', array());
+ if ($map['authorPHIDs']) {
+ $query->withAuthorPHIDs($map['authorPHIDs']);
+ }
+
+ $statuses = $map['statuses'];
if (count($statuses) == 1) {
$status = head($statuses);
if ($status == 'open') {
@@ -44,41 +39,27 @@
return $query;
}
- public function buildSearchForm(
- AphrontFormView $form,
- PhabricatorSavedQuery $saved_query) {
- $author_phids = $saved_query->getParameter('authorPHIDs', array());
-
- $voted = $saved_query->getParameter('voted', false);
- $statuses = $saved_query->getParameter('statuses', array());
-
- $form
- ->appendControl(
- id(new AphrontFormTokenizerControl())
- ->setDatasource(new PhabricatorPeopleDatasource())
- ->setName('authors')
- ->setLabel(pht('Authors'))
- ->setValue($author_phids))
- ->appendChild(
- id(new AphrontFormCheckboxControl())
- ->addCheckbox(
- 'voted',
- 1,
- pht("Show only polls I've voted in."),
- $voted))
- ->appendChild(
- id(new AphrontFormCheckboxControl())
- ->setLabel(pht('Status'))
- ->addCheckbox(
- 'statuses[]',
- 'open',
- pht('Open'),
- in_array('open', $statuses))
- ->addCheckbox(
- 'statuses[]',
- 'closed',
- pht('Closed'),
- in_array('closed', $statuses)));
+ protected function buildCustomSearchFields() {
+
+ return array(
+ id(new PhabricatorUsersSearchField())
+ ->setKey('authorPHIDs')
+ ->setAliases(array('authors'))
+ ->setLabel(pht('Authors')),
+
+ id(new PhabricatorSearchCheckboxesField())
+ ->setKey('voted')
+ ->setOptions(array(
+ 'voted' => pht("Show only polls I've voted in."),
+ )),
+
+ id(new PhabricatorSearchCheckboxesField())
+ ->setKey('statuses')
+ ->setOptions(array(
+ 'open' => pht('Open'),
+ 'closed' => pht('Closed'),
+ )),
+ );
}
protected function getURI($path) {
@@ -113,7 +94,7 @@
'authorPHIDs',
array($this->requireViewer()->getPHID()));
case 'voted':
- return $query->setParameter('voted', true);
+ return $query->setParameter('voted', array('voted'));
}
return parent::buildSavedQueryFromBuiltin($query_key);
@@ -152,9 +133,15 @@
->setObjectName('V'.$poll->getID())
->setHeader($poll->getQuestion())
->setHref('/V'.$poll->getID())
- ->setDisabled($poll->getIsClosed())
->addIcon('none', $date_created);
+ if ($poll->getIsClosed()) {
+ $item->setStatusIcon('fa-ban grey');
+ $item->setDisabled(true);
+ } else {
+ $item->setStatusIcon('fa-bar-chart');
+ }
+
$description = $poll->getDescription();
if (strlen($description)) {
$item->addAttribute(id(new PhutilUTF8StringTruncator())
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 23, 9:39 PM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6719011
Default Alt Text
D13666.id33084.diff (6 KB)
Attached To
Mode
D13666: Modernize Slowvote Search
Attached
Detach File
Event Timeline
Log In to Comment