mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 13:00:56 +01:00
Allow ApplicationSearch to be offset-paged
Summary: Ref T4365. It's not practical to cursor-page all engines; allow main search engines to be offset-paged. Basically, this comes down to setting a flag and then doing a couple of tiny things differently. Test Plan: Used this two diffs from now. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4365 Differential Revision: https://secure.phabricator.com/D8121
This commit is contained in:
parent
e7d671c8d3
commit
a82f573102
4 changed files with 38 additions and 13 deletions
|
@ -7,6 +7,16 @@ final class PhabricatorApplicationSearchController
|
|||
private $navigation;
|
||||
private $queryKey;
|
||||
private $preface;
|
||||
private $useOffsetPaging;
|
||||
|
||||
public function setUseOffsetPaging($use_offset_paging) {
|
||||
$this->useOffsetPaging = $use_offset_paging;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUseOffsetPaging() {
|
||||
return $this->useOffsetPaging;
|
||||
}
|
||||
|
||||
public function setPreface($preface) {
|
||||
$this->preface = $preface;
|
||||
|
@ -213,7 +223,12 @@ final class PhabricatorApplicationSearchController
|
|||
|
||||
$query = $engine->buildQueryFromSavedQuery($saved_query);
|
||||
|
||||
$pager = new AphrontCursorPagerView();
|
||||
$use_offset_paging = $this->getUseOffsetPaging();
|
||||
if ($use_offset_paging) {
|
||||
$pager = new AphrontPagerView();
|
||||
} else {
|
||||
$pager = new AphrontCursorPagerView();
|
||||
}
|
||||
$pager->readFromRequest($request);
|
||||
$page_size = $engine->getPageSize($saved_query);
|
||||
if (is_finite($page_size)) {
|
||||
|
@ -225,8 +240,14 @@ final class PhabricatorApplicationSearchController
|
|||
// with INF seems to vary across PHP versions, systems, and runtimes.
|
||||
$pager->setPageSize(0xFFFF);
|
||||
}
|
||||
$objects = $query->setViewer($request->getUser())
|
||||
->executeWithCursorPager($pager);
|
||||
|
||||
$query->setViewer($request->getUser());
|
||||
|
||||
if ($use_offset_paging) {
|
||||
$objects = $query->executeWithOffsetPager($pager);
|
||||
} else {
|
||||
$objects = $query->executeWithCursorPager($pager);
|
||||
}
|
||||
|
||||
$list = $parent->renderResultsList($objects, $saved_query);
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ abstract class PhabricatorApplicationSearchEngine {
|
|||
* This provides flexibility when constructing URIs, especially from external
|
||||
* sources.
|
||||
*
|
||||
* @param AphrontRequest Request to read PHIDs from.
|
||||
* @param AphrontRequest Request to read strings from.
|
||||
* @param string Key to read in the request.
|
||||
* @return list<string> List of values.
|
||||
*/
|
||||
|
|
|
@ -11,16 +11,9 @@ final class PhabricatorSearchIndexer {
|
|||
}
|
||||
|
||||
public function indexDocumentByPHID($phid) {
|
||||
$doc_indexer_symbols = id(new PhutilSymbolLoader())
|
||||
$indexers = id(new PhutilSymbolLoader())
|
||||
->setAncestorClass('PhabricatorSearchDocumentIndexer')
|
||||
->setConcreteOnly(true)
|
||||
->setType('class')
|
||||
->selectAndLoadSymbols();
|
||||
|
||||
$indexers = array();
|
||||
foreach ($doc_indexer_symbols as $symbol) {
|
||||
$indexers[] = newv($symbol['name'], array());
|
||||
}
|
||||
->loadObjects();
|
||||
|
||||
foreach ($indexers as $indexer) {
|
||||
if ($indexer->shouldIndexDocumentByPHID($phid)) {
|
||||
|
|
|
@ -47,6 +47,17 @@ final class AphrontPagerView extends AphrontView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
final public function readFromRequest(AphrontRequest $request) {
|
||||
$this->uri = $request->getRequestURI();
|
||||
$this->pagingParameter = 'offset';
|
||||
$this->offset = $request->getInt($this->pagingParameter);
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function willShowPagingControls() {
|
||||
return $this->hasMorePages;
|
||||
}
|
||||
|
||||
final public function setSurroundingPages($pages) {
|
||||
$this->surroundingPages = max(0, $pages);
|
||||
return $this;
|
||||
|
|
Loading…
Reference in a new issue