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

Make panels decide async rendering nonrandomly

Summary: Ref T4986. The random rule was useful for making sure stuff works, but it works now.

Test Plan: Loaded some dashboards, got consistent async vs non-async.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4986

Differential Revision: https://secure.phabricator.com/D9281
This commit is contained in:
epriestley 2014-06-03 16:51:02 -07:00
parent 99c72a32d0
commit bad7f3d49b
3 changed files with 33 additions and 15 deletions

View file

@ -7,6 +7,29 @@ abstract class PhabricatorDashboardPanelType extends Phobject {
abstract public function getPanelTypeDescription();
abstract public function getFieldSpecifications();
abstract public function renderPanelContent(
PhabricatorUser $viewer,
PhabricatorDashboardPanel $panel,
PhabricatorDashboardPanelRenderingEngine $engine);
/**
* Should this panel pull content in over AJAX?
*
* Normally, panels use AJAX to render their content. This makes the page
* interactable sooner, allows panels to render in parallel, and prevents one
* slow panel from slowing everything down.
*
* However, some panels are very cheap to build (i.e., no expensive service
* calls or complicated rendering). In these cases overall performance can be
* improved by disabling async rendering so the panel rendering happens in the
* same process.
*
* @return bool True to enable asynchronous rendering when appropriate.
*/
public function shouldRenderAsync() {
return true;
}
public static function getAllPanelTypes() {
static $types;
@ -40,19 +63,4 @@ abstract class PhabricatorDashboardPanelType extends Phobject {
return $types;
}
public function renderPanelContent(
PhabricatorUser $viewer,
PhabricatorDashboardPanel $panel,
PhabricatorDashboardPanelRenderingEngine $engine) {
return pht('TODO: Panel content goes here.');
}
public function shouldRenderAsync() {
// TODO: For now, just make these things random so we can catch anything
// that breaks.
return (mt_rand(0, 1) == 1);
}
}

View file

@ -25,6 +25,11 @@ final class PhabricatorDashboardPanelTypeTabs
);
}
public function shouldRenderAsync() {
// The actual tab panel itself is cheap to render.
return false;
}
public function renderPanelContent(
PhabricatorUser $viewer,
PhabricatorDashboardPanel $panel,

View file

@ -26,6 +26,11 @@ final class PhabricatorDashboardPanelTypeText
);
}
public function shouldRenderAsync() {
// Rendering text panels is normally a cheap cache hit.
return false;
}
public function renderPanelContent(
PhabricatorUser $viewer,
PhabricatorDashboardPanel $panel,