1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 19:32:40 +01:00
phorge-phorge/src/applications/search/buckets/PhabricatorSearchResultBucket.php

55 lines
1.1 KiB
PHP
Raw Normal View History

Introduce search result buckets Summary: Ref T10939. Currently, Differential hard-codes some behaviors for the "active" filter. This introduces "buckets" to make this grouping behavior more general/flexible. The buckets don't actually do any grouping yet, this just gets rid of the `$query === 'active'` stuff so far. These buckets change the page size to a large value, becuase pagination won't currently work with bucketing. The problem is that we normally paginate by selecting one more result than we need: so if we're building a page of size 10, we'll select 11 results. This is fast, and if we get 11 back, we know there's a next page with at least one result on it. With buckets, we can't do this, since our 11 results might come back in these buckets: - A, B, C, A, C, C, A, A, B, B, (B) So we know there are more results, and we know that bucket B has more results, but we have no clue if bucket A and bucket C have more results or not (or if there's anything in bucket D, etc). We might need to select a thousand more results to get the first (D) or the next (A). So we could render something like "Some buckets have more results, click here to go to the next page", but users would normally expect to be able to see "This specific bucket, A, has more results.", and we can't do that without a lot more work. It doesn't really matter for revisions, because almost no one has 1K of them, but this may need to be resolved eventually. (I have some OK-ish ideas for resolving it but nothing I'm particularly happy with.) Test Plan: {F1376542} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10939 Differential Revision: https://secure.phabricator.com/D15923
2016-05-15 18:46:38 +02:00
<?php
abstract class PhabricatorSearchResultBucket
extends Phobject {
private $viewer;
Introduce search result buckets Summary: Ref T10939. Currently, Differential hard-codes some behaviors for the "active" filter. This introduces "buckets" to make this grouping behavior more general/flexible. The buckets don't actually do any grouping yet, this just gets rid of the `$query === 'active'` stuff so far. These buckets change the page size to a large value, becuase pagination won't currently work with bucketing. The problem is that we normally paginate by selecting one more result than we need: so if we're building a page of size 10, we'll select 11 results. This is fast, and if we get 11 back, we know there's a next page with at least one result on it. With buckets, we can't do this, since our 11 results might come back in these buckets: - A, B, C, A, C, C, A, A, B, B, (B) So we know there are more results, and we know that bucket B has more results, but we have no clue if bucket A and bucket C have more results or not (or if there's anything in bucket D, etc). We might need to select a thousand more results to get the first (D) or the next (A). So we could render something like "Some buckets have more results, click here to go to the next page", but users would normally expect to be able to see "This specific bucket, A, has more results.", and we can't do that without a lot more work. It doesn't really matter for revisions, because almost no one has 1K of them, but this may need to be resolved eventually. (I have some OK-ish ideas for resolving it but nothing I'm particularly happy with.) Test Plan: {F1376542} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10939 Differential Revision: https://secure.phabricator.com/D15923
2016-05-15 18:46:38 +02:00
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;
}
public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
public function getViewer() {
return $this->viewer;
}
Introduce search result buckets Summary: Ref T10939. Currently, Differential hard-codes some behaviors for the "active" filter. This introduces "buckets" to make this grouping behavior more general/flexible. The buckets don't actually do any grouping yet, this just gets rid of the `$query === 'active'` stuff so far. These buckets change the page size to a large value, becuase pagination won't currently work with bucketing. The problem is that we normally paginate by selecting one more result than we need: so if we're building a page of size 10, we'll select 11 results. This is fast, and if we get 11 back, we know there's a next page with at least one result on it. With buckets, we can't do this, since our 11 results might come back in these buckets: - A, B, C, A, C, C, A, A, B, B, (B) So we know there are more results, and we know that bucket B has more results, but we have no clue if bucket A and bucket C have more results or not (or if there's anything in bucket D, etc). We might need to select a thousand more results to get the first (D) or the next (A). So we could render something like "Some buckets have more results, click here to go to the next page", but users would normally expect to be able to see "This specific bucket, A, has more results.", and we can't do that without a lot more work. It doesn't really matter for revisions, because almost no one has 1K of them, but this may need to be resolved eventually. (I have some OK-ish ideas for resolving it but nothing I'm particularly happy with.) Test Plan: {F1376542} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10939 Differential Revision: https://secure.phabricator.com/D15923
2016-05-15 18:46:38 +02:00
protected function getDefaultPageSize() {
return 1000;
}
abstract public function getResultBucketName();
abstract protected function buildResultGroups(
PhabricatorSavedQuery $query,
array $objects);
final public function newResultGroups(
PhabricatorSavedQuery $query,
array $objects) {
return $this->buildResultGroups($query, $objects);
}
Introduce search result buckets Summary: Ref T10939. Currently, Differential hard-codes some behaviors for the "active" filter. This introduces "buckets" to make this grouping behavior more general/flexible. The buckets don't actually do any grouping yet, this just gets rid of the `$query === 'active'` stuff so far. These buckets change the page size to a large value, becuase pagination won't currently work with bucketing. The problem is that we normally paginate by selecting one more result than we need: so if we're building a page of size 10, we'll select 11 results. This is fast, and if we get 11 back, we know there's a next page with at least one result on it. With buckets, we can't do this, since our 11 results might come back in these buckets: - A, B, C, A, C, C, A, A, B, B, (B) So we know there are more results, and we know that bucket B has more results, but we have no clue if bucket A and bucket C have more results or not (or if there's anything in bucket D, etc). We might need to select a thousand more results to get the first (D) or the next (A). So we could render something like "Some buckets have more results, click here to go to the next page", but users would normally expect to be able to see "This specific bucket, A, has more results.", and we can't do that without a lot more work. It doesn't really matter for revisions, because almost no one has 1K of them, but this may need to be resolved eventually. (I have some OK-ish ideas for resolving it but nothing I'm particularly happy with.) Test Plan: {F1376542} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10939 Differential Revision: https://secure.phabricator.com/D15923
2016-05-15 18:46:38 +02:00
final public function getResultBucketKey() {
return $this->getPhobjectClassConstant('BUCKETKEY');
}
final protected function newGroup() {
return new PhabricatorSearchResultBucketGroup();
}
Introduce search result buckets Summary: Ref T10939. Currently, Differential hard-codes some behaviors for the "active" filter. This introduces "buckets" to make this grouping behavior more general/flexible. The buckets don't actually do any grouping yet, this just gets rid of the `$query === 'active'` stuff so far. These buckets change the page size to a large value, becuase pagination won't currently work with bucketing. The problem is that we normally paginate by selecting one more result than we need: so if we're building a page of size 10, we'll select 11 results. This is fast, and if we get 11 back, we know there's a next page with at least one result on it. With buckets, we can't do this, since our 11 results might come back in these buckets: - A, B, C, A, C, C, A, A, B, B, (B) So we know there are more results, and we know that bucket B has more results, but we have no clue if bucket A and bucket C have more results or not (or if there's anything in bucket D, etc). We might need to select a thousand more results to get the first (D) or the next (A). So we could render something like "Some buckets have more results, click here to go to the next page", but users would normally expect to be able to see "This specific bucket, A, has more results.", and we can't do that without a lot more work. It doesn't really matter for revisions, because almost no one has 1K of them, but this may need to be resolved eventually. (I have some OK-ish ideas for resolving it but nothing I'm particularly happy with.) Test Plan: {F1376542} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10939 Differential Revision: https://secure.phabricator.com/D15923
2016-05-15 18:46:38 +02:00
}