mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Allow a limit to be set on the number of results in a query panel
Summary: This allows a maximum number of items to be set in a query panel. Mostly useful when you have a query panel on the feed search and you don't want 4 billion results cluttering your dashboard. Test Plan: Created a query panel with a maximum and it worked. Left it blank and got the default results. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T4980 Differential Revision: https://secure.phabricator.com/D9235
This commit is contained in:
parent
eba11238b9
commit
49c15a6d95
1 changed files with 13 additions and 0 deletions
|
@ -27,6 +27,11 @@ final class PhabricatorDashboardPanelTypeQuery
|
||||||
'name' => pht('ApplicationSearch Key'),
|
'name' => pht('ApplicationSearch Key'),
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
),
|
),
|
||||||
|
'limit' => array(
|
||||||
|
'name' => pht('Maximum Number of Items'),
|
||||||
|
'caption' => pht('Leave this blank for the default number of items'),
|
||||||
|
'type' => 'text',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +73,14 @@ final class PhabricatorDashboardPanelTypeQuery
|
||||||
|
|
||||||
$query = $engine->buildQueryFromSavedQuery($saved);
|
$query = $engine->buildQueryFromSavedQuery($saved);
|
||||||
$pager = $engine->newPagerForSavedQuery($saved);
|
$pager = $engine->newPagerForSavedQuery($saved);
|
||||||
|
|
||||||
|
if ($panel->getProperty('limit')) {
|
||||||
|
$limit = (int)$panel->getProperty('limit');
|
||||||
|
if ($pager->getPageSize() !== 0xFFFF) {
|
||||||
|
$pager->setPageSize($limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$results = $engine->executeQuery($query, $pager);
|
$results = $engine->executeQuery($query, $pager);
|
||||||
|
|
||||||
return $engine->renderResults($results, $saved);
|
return $engine->renderResults($results, $saved);
|
||||||
|
|
Loading…
Reference in a new issue