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

For now, hard limit task graph at 100 nodes

Summary:
Ref T4788. One install has some particularly impressive task graphs which are thousands of nodes large.

The current graph is pretty broken in these cases. For now, just render a "too big to show" message. In the future, I'd plan to finesse this (e.g., show parents/children, show links to parents/children, etc).

Test Plan:
  - Viewed a normal task.
  - Set limit to 3, viewed a task with graph size 6, saw an error message.
  - Viewed a revision stack graph (unaffected).

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4788

Differential Revision: https://secure.phabricator.com/D16295
This commit is contained in:
epriestley 2016-07-13 21:07:34 -07:00
parent 6eaa9faec7
commit 2a1b8ce85b
2 changed files with 38 additions and 1 deletions

View file

@ -87,12 +87,25 @@ final class ManiphestTaskDetailController extends ManiphestController {
->addPropertySection(pht('Description'), $description) ->addPropertySection(pht('Description'), $description)
->addPropertySection(pht('Details'), $details); ->addPropertySection(pht('Details'), $details);
$graph_limit = 100;
$task_graph = id(new ManiphestTaskGraph()) $task_graph = id(new ManiphestTaskGraph())
->setViewer($viewer) ->setViewer($viewer)
->setSeedPHID($task->getPHID()) ->setSeedPHID($task->getPHID())
->setLimit($graph_limit)
->loadGraph(); ->loadGraph();
if (!$task_graph->isEmpty()) { if (!$task_graph->isEmpty()) {
$graph_table = $task_graph->newGraphTable(); if ($task_graph->isOverLimit()) {
$message = pht(
'Task graph too large to display (this task is connected to '.
'more than %s other tasks).',
$graph_limit);
$message = phutil_tag('em', array(), $message);
$graph_table = id(new PHUIPropertyListView())
->addTextContent($message);
} else {
$graph_table = $task_graph->newGraphTable();
}
$view->addPropertySection(pht('Task Graph'), $graph_table); $view->addPropertySection(pht('Task Graph'), $graph_table);
} }

View file

@ -9,6 +9,7 @@ abstract class PhabricatorObjectGraph
private $seedPHID; private $seedPHID;
private $objects; private $objects;
private $loadEntireGraph = false; private $loadEntireGraph = false;
private $limit;
public function setViewer(PhabricatorUser $viewer) { public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer; $this->viewer = $viewer;
@ -23,6 +24,15 @@ abstract class PhabricatorObjectGraph
return $this->viewer; return $this->viewer;
} }
public function setLimit($limit) {
$this->limit = $limit;
return $this;
}
public function getLimit() {
return $this->limit;
}
abstract protected function getEdgeTypes(); abstract protected function getEdgeTypes();
abstract protected function getParentEdgeType(); abstract protected function getParentEdgeType();
abstract protected function newQuery(); abstract protected function newQuery();
@ -44,6 +54,16 @@ abstract class PhabricatorObjectGraph
return (count($this->getNodes()) <= 2); return (count($this->getNodes()) <= 2);
} }
final public function isOverLimit() {
$limit = $this->getLimit();
if (!$limit) {
return false;
}
return (count($this->edgeReach) > $limit);
}
final public function getEdges($type) { final public function getEdges($type) {
$edges = idx($this->edges, $type, array()); $edges = idx($this->edges, $type, array());
@ -72,6 +92,10 @@ abstract class PhabricatorObjectGraph
} }
final protected function loadEdges(array $nodes) { final protected function loadEdges(array $nodes) {
if ($this->isOverLimit()) {
return array_fill_keys($nodes, array());
}
$edge_types = $this->getEdgeTypes(); $edge_types = $this->getEdgeTypes();
$query = id(new PhabricatorEdgeQuery()) $query = id(new PhabricatorEdgeQuery())