1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 13:00:56 +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:
James Rhodes 2014-05-21 10:09:51 -07:00 committed by epriestley
parent eba11238b9
commit 49c15a6d95

View file

@ -27,6 +27,11 @@ final class PhabricatorDashboardPanelTypeQuery
'name' => pht('ApplicationSearch Key'),
'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);
$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);
return $engine->renderResults($results, $saved);