mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +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:
parent
6b069f26c0
commit
2c184bd4cd
2 changed files with 50 additions and 10 deletions
|
@ -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(
|
public function adjustPanelHeader(
|
||||||
|
|
|
@ -850,19 +850,31 @@ final class PhabricatorApplicationSearchController
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function newOverheatedView(array $results) {
|
public static function newOverheatedError($has_results) {
|
||||||
if ($results) {
|
$overheated_link = phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => 'https://phurl.io/u/overheated',
|
||||||
|
'target' => '_blank',
|
||||||
|
),
|
||||||
|
pht('Learn More'));
|
||||||
|
|
||||||
|
if ($has_results) {
|
||||||
$message = pht(
|
$message = pht(
|
||||||
'Most objects matching your query are not visible to you, so '.
|
'This query took too long, so only some results are shown. %s',
|
||||||
'filtering results is taking a long time. Only some results are '.
|
$overheated_link);
|
||||||
'shown. Refine your query to find results more quickly.');
|
|
||||||
} else {
|
} else {
|
||||||
$message = pht(
|
$message = pht(
|
||||||
'Most objects matching your query are not visible to you, so '.
|
'This query took too long. %s',
|
||||||
'filtering results is taking a long time. Refine your query to '.
|
$overheated_link);
|
||||||
'find results more quickly.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function newOverheatedView(array $results) {
|
||||||
|
$message = self::newOverheatedError((bool)$results);
|
||||||
|
|
||||||
return id(new PHUIInfoView())
|
return id(new PHUIInfoView())
|
||||||
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
|
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
|
||||||
->setFlush(true)
|
->setFlush(true)
|
||||||
|
|
Loading…
Reference in a new issue