Christopher Johnson (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/180774
Change subject: DataView Performance enhancements
......................................................................
DataView Performance enhancements
removes duplication of calls to getTasks() which is a slow range edge query
adds task setter function in TasksTableView
renames BurndownDataViewController to SprintDataViewController
renames BurndownDataView to SprintDataView
Bug: T78679
Change-Id: I88db37fd8934fd641b9a814a3baca19ec852545a
---
M src/__phutil_library_map__.php
M src/controller/SprintDataViewController.php
M src/query/SprintQuery.php
R src/view/SprintDataView.php
M src/view/SprintTableView.php
M src/view/TasksTableView.php
6 files changed, 73 insertions(+), 56 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/phabricator/extensions/Sprint
refs/changes/74/180774/1
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
index 10c1f52..3addf12 100644
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -13,7 +13,6 @@
'BurndownActionMenuEventListener' =>
'events/BurndownActionMenuEventListener.php',
'BurndownDataDate' => 'util/BurndownDataDate.php',
'BurndownDataDateTest' => 'tests/BurndownDataDateTest.php',
- 'BurndownDataView' => 'view/BurndownDataView.php',
'BurndownException' => 'exception/BurndownException.php',
'CeleritySprintResources' => 'celerity/CeleritySprintResources.php',
'DateIterator' => 'tests/DateIterator.php',
@@ -41,6 +40,7 @@
'SprintController' => 'controller/SprintController.php',
'SprintControllerTest' => 'tests/SprintControllerTest.php',
'SprintDAO' => 'storage/SprintDAO.php',
+ 'SprintDataView' => 'view/SprintDataView.php',
'SprintDataViewController' => 'controller/SprintDataViewController.php',
'SprintDefaultViewCapability' =>
'capability/SprintDefaultViewCapability.php',
'SprintEndDateField' => 'customfield/SprintEndDateField.php',
@@ -55,6 +55,7 @@
'SprintReportController' => 'controller/SprintReportController.php',
'SprintReportOpenTasksView' => 'view/SprintReportOpenTasksView.php',
'SprintTableView' => 'view/SprintTableView.php',
+ 'SprintTask' => 'storage/SprintTask.php',
'SprintTaskStoryPointsField' =>
'customfield/SprintTaskStoryPointsField.php',
'SprintTestCase' => 'tests/SprintTestCase.php',
'SprintTransaction' => 'storage/SprintTransaction.php',
@@ -68,7 +69,6 @@
'xmap' => array(
'BurndownActionMenuEventListener' => 'PhabricatorEventListener',
'BurndownDataDateTest' => 'SprintTestCase',
- 'BurndownDataView' => 'SprintView',
'BurndownException' => 'Exception',
'CeleritySprintResources' => 'CelerityResourcesOnDisk',
'DateIterator' => 'Iterator',
@@ -90,6 +90,7 @@
'SprintController' => 'PhabricatorController',
'SprintControllerTest' => 'SprintTestCase',
'SprintDAO' => 'PhabricatorLiskDAO',
+ 'SprintDataView' => 'SprintView',
'SprintDataViewController' => 'SprintController',
'SprintDefaultViewCapability' => 'PhabricatorPolicyCapability',
'SprintEndDateField' => 'SprintProjectCustomField',
@@ -106,6 +107,19 @@
'SprintReportBurndownView' => 'SprintView',
'SprintReportController' => 'SprintController',
'SprintReportOpenTasksView' => 'SprintView',
+ 'SprintTask' => array(
+ 'SprintDAO',
+ 'PhabricatorMarkupInterface',
+ 'PhabricatorPolicyInterface',
+ 'PhabricatorTokenReceiverInterface',
+ 'PhabricatorFlaggableInterface',
+ 'PhabricatorMentionableInterface',
+ 'PhrequentTrackableInterface',
+ 'PhabricatorCustomFieldInterface',
+ 'PhabricatorDestructibleInterface',
+ 'PhabricatorApplicationTransactionInterface',
+ 'PhabricatorProjectInterface',
+ ),
'SprintTaskStoryPointsField' => array(
'ManiphestCustomField',
'PhabricatorStandardCustomFieldInterface',
diff --git a/src/controller/SprintDataViewController.php
b/src/controller/SprintDataViewController.php
index 107e441..1a16b03 100644
--- a/src/controller/SprintDataViewController.php
+++ b/src/controller/SprintDataViewController.php
@@ -27,7 +27,7 @@
$burndown_view = false;
try {
- $burndown_view = id(new BurndownDataView())
+ $burndown_view = id(new SprintDataView())
->setProject($project)
->setViewer($viewer)
->setRequest($request);
diff --git a/src/query/SprintQuery.php b/src/query/SprintQuery.php
index dd44c89..48038de 100644
--- a/src/query/SprintQuery.php
+++ b/src/query/SprintQuery.php
@@ -73,7 +73,6 @@
public function getXactions($tasks) {
$task_phids = mpull($tasks, 'getPHID');
-
$xactions = id(new ManiphestTransactionQuery())
->setViewer($this->viewer)
->withObjectPHIDs($task_phids)
diff --git a/src/view/BurndownDataView.php b/src/view/SprintDataView.php
similarity index 76%
rename from src/view/BurndownDataView.php
rename to src/view/SprintDataView.php
index e9a9091..77b879a 100644
--- a/src/view/BurndownDataView.php
+++ b/src/view/SprintDataView.php
@@ -4,7 +4,7 @@
* @license GPL version 3
*/
-final class BurndownDataView extends SprintView
+final class SprintDataView extends SprintView
{
private $request;
@@ -35,51 +35,57 @@
}
public function render() {
- $chart = $this->buildC3Chart();
- $tasks_table = id(new TasksTableView())
- ->setProject($this->project)
- ->setViewer($this->viewer)
- ->setRequest($this->request);
- $tasks_table = $tasks_table->buildTasksTable();
- $pie = $this->buildC3Pie();
- $history_table = new HistoryTableView();
- $history_table = $history_table->buildHistoryTable($this->before);
- $sprint_table = new SprintTableView();
- $burndown_table = $sprint_table->buildBurnDownTable($this->sprint_data,
$this->before);
- $event_table = id(new EventTableView())
- ->setProject($this->project)
- ->setViewer($this->viewer)
- ->setRequest($this->request);
- $event_table = $event_table->buildEventTable($this->events,
$this->xactions,
- $this->tasks, $this->start, $this->end);
- return array($chart, $tasks_table, $pie, $history_table, $burndown_table,
$event_table);
- }
-
- private function buildChartDataSet() {
$query = id(new SprintQuery())
->setProject($this->project)
->setViewer($this->viewer);
+ $tasks = $query->getTasks();
+ $this->tasks = mpull($tasks, null, 'getPHID');
+
+ $chart = $this->buildC3Chart($query);
+ $tasks_table_view = id(new TasksTableView())
+ ->setProject($this->project)
+ ->setViewer($this->viewer)
+ ->setRequest($this->request)
+ ->setTasks($this->tasks)
+ ->setQuery($query);
+
+ $tasks_table = $tasks_table_view->buildTasksTable();
+ $pie = $this->buildC3Pie($tasks_table_view);
+ $history_table_view = new HistoryTableView();
+ $history_table = $history_table_view->buildHistoryTable($this->before);
+ $sprint_table_view = new SprintTableView();
+ $sprint_table = $sprint_table_view->buildSprintTable($this->sprint_data,
$this->before);
+ $event_table_view = id(new EventTableView())
+ ->setProject($this->project)
+ ->setViewer($this->viewer)
+ ->setRequest($this->request);
+ $event_table = $event_table_view->buildEventTable($this->events,
$this->xactions,
+ $this->tasks, $this->start, $this->end);
+ return array($chart, $tasks_table, $pie, $history_table, $sprint_table,
$event_table);
+ }
+
+ private function buildChartDataSet($query) {
+
$aux_fields = $query->getAuxFields();
$this->start = $query->getStartDate($aux_fields);
$this->end = $query->getEndDate($aux_fields);
$stats = id(new SprintBuildStats());
- $tasks = $query->getTasks();
- $query->checkNull($this->start, $this->end, $tasks);
+
+ $query->checkNull($this->start, $this->end, $this->tasks);
$timezone = $stats->setTimezone($this->viewer);
$this->before = $stats->buildBefore($this->start, $timezone);
$dates = $stats->buildDateArray($this->start, $this->end, $timezone);
$this->timeseries = $stats->buildTimeSeries($this->start, $this->end);
- $xactions = $query->getXactions($tasks);
- $this->events = $query->getEvents($xactions, $tasks);
+ $xactions = $query->getXactions($this->tasks);
+ $this->events = $query->getEvents($xactions, $this->tasks);
$this->xactions = mpull($xactions, null, 'getPHID');
- $this->tasks = mpull($tasks, null, 'getPHID');
$sprint_xaction = id(new SprintTransaction())
->setViewer($this->viewer);
- $sprint_xaction->buildStatArrays($tasks);
+ $sprint_xaction->buildStatArrays($this->tasks);
$dates = $sprint_xaction->buildDailyData($this->events, $this->before,
$this->start, $this->end, $dates, $this->xactions, $this->project);
$this->sprint_data = $stats->setSprintData($dates, $this->before);
@@ -104,8 +110,8 @@
return $transposed_array;
}
- private function buildC3Chart() {
- $data = $this->buildChartDataSet();
+ private function buildC3Chart($query) {
+ $data = $this->buildChartDataSet($query);
$totalpoints = $data[0];
$remainingpoints = $data[1];
$idealpoints = $data[2];
@@ -137,11 +143,7 @@
return $chart;
}
- private function buildC3Pie() {
- $tasks_table = id(new TasksTableView())
- ->setProject($this->project)
- ->setViewer($this->viewer)
- ->setRequest($this->request);
+ private function buildC3Pie($tasks_table) {
$tasks_table->setStatusPoints();
$task_open_status_sum = $tasks_table->getOpenStatusSum();
$task_closed_status_sum = $tasks_table->getClosedStatusSum();
diff --git a/src/view/SprintTableView.php b/src/view/SprintTableView.php
index edaabe0..4440d6c 100644
--- a/src/view/SprintTableView.php
+++ b/src/view/SprintTableView.php
@@ -8,7 +8,7 @@
*
* @returns PHUIObjectBoxView
*/
- public function buildBurnDownTable($sprint_data, $before)
+ public function buildSprintTable($sprint_data, $before)
{
$tdata = array();
$pdata = array();
diff --git a/src/view/TasksTableView.php b/src/view/TasksTableView.php
index 8b1ce1c..3b3382d 100644
--- a/src/view/TasksTableView.php
+++ b/src/view/TasksTableView.php
@@ -5,8 +5,10 @@
private $project;
private $viewer;
private $request;
+ private $tasks;
private $task_open_status_sum;
private $task_closed_status_sum;
+ private $query;
public function setProject ($project) {
$this->project = $project;
@@ -20,6 +22,16 @@
public function setRequest ($request) {
$this->request = $request;
+ return $this;
+ }
+
+ public function setTasks ($tasks) {
+ $this->tasks = $tasks;
+ return $this;
+ }
+
+ public function setQuery ($query) {
+ $this->query = $query;
return $this;
}
@@ -103,26 +115,21 @@
* @return array
*/
private function buildTasksTree($order, $reverse) {
- $query = id(new SprintQuery())
- ->setProject($this->project)
- ->setViewer($this->viewer);
- $tasks = $query->getTasks();
- $tasks = mpull($tasks, null, 'getPHID');
- $edges = $query->getEdges($tasks);
- $map = $this->buildTaskMap($edges, $tasks);
+ $edges = $this->query->getEdges($this->tasks);
+ $map = $this->buildTaskMap($edges, $this->tasks);
// We also collect the phids we need to fetch owner information
$handle_phids = array();
- foreach ($tasks as $task) {
+ foreach ($this->tasks as $task) {
// Get the owner (assigned to) phid
$handle_phids[$task->getOwnerPHID()] = $task->getOwnerPHID();
}
- $handles = $query->getViewerHandles($this->request, $handle_phids);
+ $handles = $this->query->getViewerHandles($this->request, $handle_phids);
// Now we loop through the tasks, and add them to the output
$output = array();
$rows = array();
- foreach ($tasks as $task) {
+ foreach ($this->tasks as $task) {
if (isset($map[$task->getPHID()]['independent'])) {
$blocked = false;
} elseif (isset($map[$task->getPHID()]['parent'])) {
@@ -302,12 +309,7 @@
}
public function setStatusPoints () {
- $query = id(new SprintQuery())
- ->setProject($this->project)
- ->setViewer($this->viewer);
- $tasks = $query->getTasks();
- $tasks = mpull($tasks, null, 'getPHID');
- foreach ($tasks as $task) {
+ foreach ($this->tasks as $task) {
$this->sumPointsbyStatus($task);
}
return;
--
To view, visit https://gerrit.wikimedia.org/r/180774
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I88db37fd8934fd641b9a814a3baca19ec852545a
Gerrit-PatchSet: 1
Gerrit-Project: phabricator/extensions/Sprint
Gerrit-Branch: master
Gerrit-Owner: Christopher Johnson (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits