Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13980693
D15923.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D15923.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -533,6 +533,8 @@
'DifferentialRevisionQuery' => 'applications/differential/query/DifferentialRevisionQuery.php',
'DifferentialRevisionRepositoryHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php',
'DifferentialRevisionRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php',
+ 'DifferentialRevisionRequiredActionResultBucket' => 'applications/differential/query/DifferentialRevisionRequiredActionResultBucket.php',
+ 'DifferentialRevisionResultBucket' => 'applications/differential/query/DifferentialRevisionResultBucket.php',
'DifferentialRevisionReviewersHeraldField' => 'applications/differential/herald/DifferentialRevisionReviewersHeraldField.php',
'DifferentialRevisionSearchEngine' => 'applications/differential/query/DifferentialRevisionSearchEngine.php',
'DifferentialRevisionStatus' => 'applications/differential/constants/DifferentialRevisionStatus.php',
@@ -3317,6 +3319,7 @@
'PhabricatorSearchOrderField' => 'applications/search/field/PhabricatorSearchOrderField.php',
'PhabricatorSearchPreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorSearchPreferencesSettingsPanel.php',
'PhabricatorSearchRelationship' => 'applications/search/constants/PhabricatorSearchRelationship.php',
+ 'PhabricatorSearchResultBucket' => 'applications/search/buckets/PhabricatorSearchResultBucket.php',
'PhabricatorSearchResultView' => 'applications/search/view/PhabricatorSearchResultView.php',
'PhabricatorSearchSchemaSpec' => 'applications/search/storage/PhabricatorSearchSchemaSpec.php',
'PhabricatorSearchSelectController' => 'applications/search/controller/PhabricatorSearchSelectController.php',
@@ -4758,6 +4761,8 @@
'DifferentialRevisionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DifferentialRevisionRepositoryHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionRepositoryProjectsHeraldField' => 'DifferentialRevisionHeraldField',
+ 'DifferentialRevisionRequiredActionResultBucket' => 'DifferentialRevisionResultBucket',
+ 'DifferentialRevisionResultBucket' => 'PhabricatorSearchResultBucket',
'DifferentialRevisionReviewersHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DifferentialRevisionStatus' => 'Phobject',
@@ -8009,6 +8014,7 @@
'PhabricatorSearchOrderField' => 'PhabricatorSearchField',
'PhabricatorSearchPreferencesSettingsPanel' => 'PhabricatorSettingsPanel',
'PhabricatorSearchRelationship' => 'Phobject',
+ 'PhabricatorSearchResultBucket' => 'Phobject',
'PhabricatorSearchResultView' => 'AphrontView',
'PhabricatorSearchSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PhabricatorSearchSelectController' => 'PhabricatorSearchBaseController',
diff --git a/src/applications/differential/query/DifferentialRevisionRequiredActionResultBucket.php b/src/applications/differential/query/DifferentialRevisionRequiredActionResultBucket.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/query/DifferentialRevisionRequiredActionResultBucket.php
@@ -0,0 +1,12 @@
+<?php
+
+final class DifferentialRevisionRequiredActionResultBucket
+ extends DifferentialRevisionResultBucket {
+
+ const BUCKETKEY = 'action';
+
+ public function getResultBucketName() {
+ return pht('Bucket by Required Action');
+ }
+
+}
diff --git a/src/applications/differential/query/DifferentialRevisionResultBucket.php b/src/applications/differential/query/DifferentialRevisionResultBucket.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/query/DifferentialRevisionResultBucket.php
@@ -0,0 +1,13 @@
+<?php
+
+abstract class DifferentialRevisionResultBucket
+ extends PhabricatorSearchResultBucket {
+
+ public static function getAllResultBuckets() {
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getResultBucketKey')
+ ->execute();
+ }
+
+}
diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php
--- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php
+++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php
@@ -11,6 +11,10 @@
return 'PhabricatorDifferentialApplication';
}
+ protected function newResultBuckets() {
+ return DifferentialRevisionResultBucket::getAllResultBuckets();
+ }
+
public function newQuery() {
return id(new DifferentialRevisionQuery())
->needFlags(true)
@@ -18,14 +22,6 @@
->needRelationships(true);
}
- public function getPageSize(PhabricatorSavedQuery $saved) {
- if ($saved->getQueryKey() == 'active') {
- return 0xFFFF;
- }
- return parent::getPageSize($saved);
- }
-
-
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
@@ -114,9 +110,12 @@
switch ($query_key) {
case 'active':
+ $bucket_key = DifferentialRevisionRequiredActionResultBucket::BUCKETKEY;
+
return $query
->setParameter('responsiblePHIDs', array($viewer->getPHID()))
- ->setParameter('status', DifferentialRevisionQuery::STATUS_OPEN);
+ ->setParameter('status', DifferentialRevisionQuery::STATUS_OPEN)
+ ->setParameter('bucket', $bucket_key);
case 'authored':
return $query
->setParameter('authorPHIDs', array($viewer->getPHID()));
@@ -139,13 +138,6 @@
);
}
- private function getOrderOptions() {
- return array(
- DifferentialRevisionQuery::ORDER_CREATED => pht('Created'),
- DifferentialRevisionQuery::ORDER_MODIFIED => pht('Updated'),
- );
- }
-
protected function renderResultList(
array $revisions,
PhabricatorSavedQuery $query,
@@ -157,8 +149,10 @@
->setUser($viewer)
->setNoBox($this->isPanelContext());
+ $bucket = $this->getResultBucket($query);
+
$views = array();
- if ($query->getQueryKey() == 'active') {
+ if ($bucket) {
$split = DifferentialRevisionQuery::splitResponsible(
$revisions,
$query->getParameter('responsiblePHIDs'));
diff --git a/src/applications/search/buckets/PhabricatorSearchResultBucket.php b/src/applications/search/buckets/PhabricatorSearchResultBucket.php
new file mode 100644
--- /dev/null
+++ b/src/applications/search/buckets/PhabricatorSearchResultBucket.php
@@ -0,0 +1,31 @@
+<?php
+
+abstract class PhabricatorSearchResultBucket
+ extends Phobject {
+
+ private $pageSize;
+
+ final public function setPageSize($page_size) {
+ $this->pageSize = $page_size;
+ return $this;
+ }
+
+ final public function getPageSize() {
+ if ($this->pageSize === null) {
+ return $this->getDefaultPageSize();
+ }
+
+ return $this->pageSize;
+ }
+
+ protected function getDefaultPageSize() {
+ return 1000;
+ }
+
+ abstract public function getResultBucketName();
+
+ final public function getResultBucketKey() {
+ return $this->getPhobjectClassConstant('BUCKETKEY');
+ }
+
+}
diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
--- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
+++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
@@ -28,6 +28,8 @@
const CONTEXT_LIST = 'list';
const CONTEXT_PANEL = 'panel';
+ const BUCKET_NONE = 'none';
+
public function setController(PhabricatorController $controller) {
$this->controller = $controller;
return $this;
@@ -266,6 +268,18 @@
->setOptions($orders);
}
+ $buckets = $this->newResultBuckets();
+ if ($query && $buckets) {
+ $bucket_options = array(
+ self::BUCKET_NONE => pht('No Bucketing'),
+ ) + mpull($buckets, 'getResultBucketName');
+
+ $fields[] = id(new PhabricatorSearchSelectField())
+ ->setLabel(pht('Bucket'))
+ ->setKey('bucket')
+ ->setOptions($bucket_options);
+ }
+
$field_map = array();
foreach ($fields as $field) {
$key = $field->getKey();
@@ -944,13 +958,37 @@
/* -( Paging and Executing Queries )--------------------------------------- */
+ protected function newResultBuckets() {
+ return array();
+ }
+
+ protected function getResultBucket(PhabricatorSavedQuery $saved) {
+ $key = $saved->getParameter('bucket');
+ if ($key == self::BUCKET_NONE) {
+ return null;
+ }
+
+ $buckets = $this->newResultBuckets();
+ return idx($buckets, $key);
+ }
+
+
public function getPageSize(PhabricatorSavedQuery $saved) {
+ $bucket = $this->getResultBucket($saved);
+
$limit = (int)$saved->getParameter('limit');
if ($limit > 0) {
+ if ($bucket) {
+ $bucket->setPageSize($limit);
+ }
return $limit;
}
+ if ($bucket) {
+ return $bucket->getPageSize();
+ }
+
return 100;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 20 2024, 12:05 PM (4 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6713570
Default Alt Text
D15923.diff (9 KB)
Attached To
Mode
D15923: Introduce search result buckets
Attached
Detach File
Event Timeline
Log In to Comment