From 49c15a6d951c6569e6f94c8c0be3d602b92beda3 Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Wed, 21 May 2014 10:09:51 -0700 Subject: [PATCH] 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 --- .../PhabricatorDashboardPanelTypeQuery.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php index d677e30800..b7eb8b283a 100644 --- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php +++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeQuery.php @@ -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);