1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

When query panels overheat, degrade them and show a warning

Summary:
Depends on D20334. Ref T13272. After recent changes to make overheating queries throw by default, dashboard panels now fail into an error state when they overheat.

This is a big step up from the hard-coded homepage panels removed by D20333, but can be improved. Let these panels render partial results when they overheat and show a human-readable warning.

Test Plan: {F6314114}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13272

Differential Revision: https://secure.phabricator.com/D20335
This commit is contained in:
epriestley 2019-03-27 08:43:18 -07:00
parent 6b069f26c0
commit 2c184bd4cd
2 changed files with 50 additions and 10 deletions

View file

@ -106,9 +106,37 @@ final class PhabricatorDashboardQueryPanelType
}
}
$results = $engine->executeQuery($query, $pager);
$query->setReturnPartialResultsOnOverheat(true);
return $engine->renderResults($results, $saved);
$results = $engine->executeQuery($query, $pager);
$results_view = $engine->renderResults($results, $saved);
$is_overheated = $query->getIsOverheated();
$overheated_view = null;
if ($is_overheated) {
$content = $results_view->getContent();
$overheated_message =
PhabricatorApplicationSearchController::newOverheatedError(
(bool)$results);
$overheated_warning = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
->setTitle(pht('Query Overheated'))
->setErrors(
array(
$overheated_message,
));
$overheated_box = id(new PHUIBoxView())
->addClass('mmt mmb')
->appendChild($overheated_warning);
$content = array($content, $overheated_box);
$results_view->setContent($content);
}
return $results_view;
}
public function adjustPanelHeader(

View file

@ -850,19 +850,31 @@ final class PhabricatorApplicationSearchController
));
}
private function newOverheatedView(array $results) {
if ($results) {
public static function newOverheatedError($has_results) {
$overheated_link = phutil_tag(
'a',
array(
'href' => 'https://phurl.io/u/overheated',
'target' => '_blank',
),
pht('Learn More'));
if ($has_results) {
$message = pht(
'Most objects matching your query are not visible to you, so '.
'filtering results is taking a long time. Only some results are '.
'shown. Refine your query to find results more quickly.');
'This query took too long, so only some results are shown. %s',
$overheated_link);
} else {
$message = pht(
'Most objects matching your query are not visible to you, so '.
'filtering results is taking a long time. Refine your query to '.
'find results more quickly.');
'This query took too long. %s',
$overheated_link);
}
return $message;
}
private function newOverheatedView(array $results) {
$message = self::newOverheatedError((bool)$results);
return id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
->setFlush(true)