Christopher Johnson (WMDE) has submitted this change and it was merged.
Change subject: refactoring and improvement of data providers
......................................................................
refactoring and improvement of data providers
removes unused classes and functions
Change-Id: I20c2165f9789803f447b8f92f6e3c77ade23bac2
---
M src/__phutil_library_map__.php
M src/storage/BoardDataProvider.php
A src/storage/TaskTableDataProvider.php
D src/tests/BurndownDataDateTest.php
M src/util/BurndownDataDate.php
M src/view/burndown/BoardDataPieView.php
R src/view/burndown/BoardDataTableView.php
A src/view/burndown/BurndownChartView.php
D src/view/burndown/C3ChartView.php
D src/view/burndown/C3PieView.php
D src/view/burndown/HistoryTableView.php
M src/view/burndown/SprintDataView.php
D src/view/burndown/SprintTableView.php
M src/view/burndown/TasksTableView.php
14 files changed, 480 insertions(+), 726 deletions(-)
Approvals:
Christopher Johnson (WMDE): Verified; Looks good to me, approved
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
index 1b8ba6e..deb4f9c 100644
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -12,15 +12,13 @@
'AutoLoader' => 'tests/Autoloader.php',
'BoardDataPieView' => 'view/burndown/BoardDataPieView.php',
'BoardDataProvider' => 'storage/BoardDataProvider.php',
- 'BoardDataView' => 'view/burndown/BoardDataView.php',
+ 'BoardDataTableView' => 'view/burndown/BoardDataTableView.php',
'BurndownActionMenuEventListener' =>
'events/BurndownActionMenuEventListener.php',
+ 'BurndownChartView' => 'view/burndown/BurndownChartView.php',
'BurndownDataDate' => 'util/BurndownDataDate.php',
'BurndownDataDateTest' => 'tests/BurndownDataDateTest.php',
'BurndownException' => 'exception/BurndownException.php',
- 'C3ChartView' => 'view/burndown/C3ChartView.php',
- 'C3PieView' => 'view/burndown/C3PieView.php',
'CeleritySprintResources' => 'celerity/CeleritySprintResources.php',
- 'ChartDataProvider' => 'storage/ChartDataProvider.php',
'DateIterator' => 'tests/DateIterator.php',
'EventTableView' => 'view/burndown/EventTableView.php',
'HistoryTableView' => 'view/burndown/HistoryTableView.php',
@@ -41,7 +39,6 @@
'SprintBoardTaskCard' => 'view/SprintBoardTaskCard.php',
'SprintBoardTaskEditController' =>
'controller/board/SprintBoardTaskEditController.php',
'SprintBoardViewController' =>
'controller/board/SprintBoardViewController.php',
- 'SprintBuildStatsTest' => 'tests/SprintStatsTest.php',
'SprintColumnTransaction' => 'storage/SprintColumnTransaction.php',
'SprintConstants' => 'constants/SprintConstants.php',
'SprintController' => 'controller/SprintController.php',
@@ -52,7 +49,6 @@
'SprintDataViewController' => 'controller/SprintDataViewController.php',
'SprintDefaultViewCapability' =>
'capability/SprintDefaultViewCapability.php',
'SprintEndDateField' => 'customfield/SprintEndDateField.php',
- 'SprintErrorView' => 'exception/SprintErrorView.php',
'SprintFactDaemon' => 'fact/SprintFactDaemon.php',
'SprintFactUpdateIterator' => 'fact/SprintFactUpdateIterator.php',
'SprintIsSprintField' => 'customfield/SprintIsSprintField.php',
@@ -67,12 +63,13 @@
'SprintReportController' => 'controller/SprintReportController.php',
'SprintReportOpenTasksView' =>
'view/reports/SprintReportOpenTasksView.php',
'SprintStats' => 'storage/SprintStats.php',
+ 'SprintStatsTest' => 'tests/SprintStatsTest.php',
'SprintTableView' => 'view/burndown/SprintTableView.php',
'SprintTaskStoryPointsField' =>
'customfield/SprintTaskStoryPointsField.php',
'SprintTestCase' => 'tests/SprintTestCase.php',
- 'SprintTransaction' => 'storage/SprintTransaction.php',
'SprintValidator' => 'util/SprintValidator.php',
'SprintView' => 'view/SprintView.php',
+ 'TaskTableDataProvider' => 'storage/TaskTableDataProvider.php',
'TasksTableView' => 'view/burndown/TasksTableView.php',
'UserOpenTasksView' => 'view/reports/UserOpenTasksView.php',
),
@@ -97,7 +94,6 @@
'SprintBoardReorderController' => 'SprintBoardController',
'SprintBoardTaskEditController' => 'ManiphestController',
'SprintBoardViewController' => 'SprintBoardController',
- 'SprintBuildStatsTest' => 'SprintTestCase',
'SprintController' => 'PhabricatorController',
'SprintControllerTest' => 'SprintTestCase',
'SprintCustomFieldTest' => 'SprintTestCase',
@@ -106,7 +102,6 @@
'SprintDataViewController' => 'SprintController',
'SprintDefaultViewCapability' => 'PhabricatorPolicyCapability',
'SprintEndDateField' => 'SprintProjectCustomField',
- 'SprintErrorView' => 'AphrontView',
'SprintFactDaemon' => 'PhabricatorDaemon',
'SprintFactUpdateIterator' => 'PhutilBufferedIterator',
'SprintIsSprintField' => 'SprintProjectCustomField',
@@ -122,6 +117,7 @@
'SprintReportBurndownView' => 'SprintView',
'SprintReportController' => 'SprintController',
'SprintReportOpenTasksView' => 'SprintView',
+ 'SprintStatsTest' => 'SprintTestCase',
'SprintTaskStoryPointsField' => array(
'ManiphestCustomField',
'PhabricatorStandardCustomFieldInterface',
diff --git a/src/storage/BoardDataProvider.php
b/src/storage/BoardDataProvider.php
index d4cbad3..ba14bed 100644
--- a/src/storage/BoardDataProvider.php
+++ b/src/storage/BoardDataProvider.php
@@ -13,6 +13,9 @@
private $query;
private $stats;
private $timezone;
+ private $timeseries;
+ private $chartdata;
+ private $coldata;
public function setStart ($start) {
$this->start = $start;
@@ -27,6 +30,18 @@
public function setProject ($project) {
$this->project = $project;
return $this;
+ }
+
+ public function getProject () {
+ return $this->project;
+ }
+
+ public function getColumnData () {
+ return $this->coldata;
+ }
+
+ public function getChartData () {
+ return $this->chartdata;
}
public function setViewer ($viewer) {
@@ -44,14 +59,31 @@
return $this;
}
+ public function setTimeSeries ($timeseries) {
+ $this->timeseries = $timeseries;
+ return $this;
+ }
+
+ public function getTimeSeries () {
+ return $this->timeseries;
+ }
+
public function setTasks ($tasks) {
$this->tasks = $tasks;
return $this;
}
+ public function getTasks () {
+ return $this->tasks;
+ }
+
public function setTaskPoints ($taskpoints) {
$this->taskpoints = $taskpoints;
return $this;
+ }
+
+ public function getTaskPoints() {
+ return $this->taskpoints;
}
public function setStats ($stats) {
@@ -64,7 +96,13 @@
return $this;
}
- public function buildBoardDataSet() {
+ public function execute() {
+ $this->buildBoardDataSet();
+ $this->buildChartfromBoardData();
+ return $this;
+ }
+
+ private function buildBoardDataSet() {
$board_columns = array();
$columns = $this->query->getProjectColumns();
$positions = $this->query->getProjectColumnPositionforTask($this->tasks,
@@ -85,8 +123,8 @@
$board_columns[$column->getPHID()] = $board_column;
}
- $coldata = $this->buildBoardColumnData($board_columns);
- return $coldata;
+ $this->coldata = $this->buildBoardColumnData($board_columns);
+ return $this;
}
private function buildBoardColumnData($board_columns) {
@@ -108,7 +146,7 @@
return $column_tasks;
}
- public function getColumnName($column_phid) {
+ private function getColumnName($column_phid) {
$name = null;
$column = $this->query->getColumnforPHID($column_phid);
foreach ($column as $obj) {
@@ -117,7 +155,7 @@
return $name;
}
- public function getTaskPointsSum($tasks) {
+ private function getTaskPointsSum($tasks) {
$points_sum = null;
$taskpoints = mpull($this->taskpoints, null, 'getObjectPHID');
$column_points = array_intersect_key($taskpoints, $tasks);
@@ -133,7 +171,7 @@
return $points_sum;
}
- public function getProjectColumnXactions() {
+ private function getProjectColumnXactions() {
$xactions = array();
$scope_phid = $this->project->getPHID();
$query = new PhabricatorFeedQuery();
@@ -159,7 +197,7 @@
return $xactions;
}
- public function buildChartfromBoardData() {
+ private function buildChartfromBoardData() {
$date_array = $this->stats->buildDateArray($this->start, $this->end,
$this->timezone);
@@ -177,7 +215,7 @@
$this->stats->setTaskPoints($this->taskpoints);
$sprint_data = $this->stats->setSprintData($dates);
$data = $this->stats->buildDataSet($sprint_data);
- $data = $this->stats->transposeArray($data);
- return $data;
+ $this->chartdata = $this->stats->transposeArray($data);
+ return $this;
}
}
diff --git a/src/storage/TaskTableDataProvider.php
b/src/storage/TaskTableDataProvider.php
new file mode 100644
index 0000000..5030b63
--- /dev/null
+++ b/src/storage/TaskTableDataProvider.php
@@ -0,0 +1,316 @@
+<?php
+
+final class TaskTableDataProvider {
+
+ private $project;
+ private $viewer;
+ private $request;
+ private $tasks;
+ private $taskpoints;
+ private $query;
+ private $rows;
+ private $order;
+ private $reverse;
+
+
+ public function setProject ($project) {
+ $this->project = $project;
+ return $this;
+ }
+
+ public function setViewer ($viewer) {
+ $this->viewer = $viewer;
+ return $this;
+ }
+
+ public function setRequest ($request) {
+ $this->request = $request;
+ return $this;
+ }
+
+ public function setTasks ($tasks) {
+ $this->tasks = $tasks;
+ return $this;
+ }
+
+ public function setTaskPoints ($taskpoints) {
+ $this->taskpoints = $taskpoints;
+ return $this;
+ }
+
+ public function setQuery ($query) {
+ $this->query = $query;
+ return $this;
+ }
+
+ public function getRows () {
+ return $this->rows;
+ }
+
+ public function getRequest () {
+ return $this->request;
+ }
+
+ public function getOrder () {
+ return $this->order;
+ }
+
+ public function getReverse () {
+ return $this->reverse;
+ }
+
+ public function execute() {
+ return $this->buildTaskTableData();
+ }
+
+ private function buildTaskTableData() {
+ $order = $this->request->getStr('order', 'name');
+ list($this->order, $this->reverse) = AphrontTableView::parseSort($order);
+ $edges = $this->query->getEdges($this->tasks);
+ $map = $this->buildTaskMap($edges, $this->tasks);
+ $sprintpoints = id(new SprintPoints())
+ ->setTaskPoints($this->taskpoints);
+
+ $handles = $this->getHandles();
+
+ $output = array();
+ $rows = array();
+ foreach ($this->tasks as $task) {
+ $blocked = false;
+ if (isset($map[$task->getPHID()]['child'])) {
+ foreach (($map[$task->getPHID()]['child']) as $phid) {
+ $ctask = $this->getTaskforPHID($phid);
+ foreach ($ctask as $child) {
+ if (ManiphestTaskStatus::isOpenStatus($child->getStatus())) {
+ $blocked = true;
+ break;
+ }
+ }
+ }
+ }
+
+ $ptasks = array();
+ $phid = null;
+ $blocker = false;
+ if (isset($map[$task->getPHID()]['parent'])) {
+ $blocker = true;
+ foreach (($map[$task->getPHID()]['parent']) as $phid) {
+ $ptask = $this->getTaskforPHID($phid);
+ $ptasks = array_merge($ptasks, $ptask);
+ }
+ }
+
+ $points = $sprintpoints->getTaskPoints($task->getPHID());
+
+ $row = $this->addTaskToTree($output, $blocked, $ptasks, $blocker,
+ $task, $handles, $points);
+ list ($task, $cdate, , $udate, , $owner_link, $numpriority, , $points,
+ $status) = $row[0];
+ $row['sort'] = $this->setSortOrder($row, $order, $task, $cdate, $udate,
+ $owner_link, $numpriority, $points, $status);
+ $rows[] = $row;
+ }
+ $rows = isort($rows, 'sort');
+
+ foreach ($rows as $k => $row) {
+ unset($rows[$k]['sort']);
+ }
+
+ if ($this->reverse) {
+ $rows = array_reverse($rows);
+ }
+
+ $a = array();
+ $this->rows = array_map(function($a) { return $a['0']; }, $rows);
+ return $this;
+ }
+
+ private function setSortOrder ($row, $order, $task, $cdate, $udate,
+ $owner_link, $numpriority, $points, $status) {
+ switch ($order) {
+ case 'Task':
+ $row['sort'] = $task;
+ break;
+ case 'Date Created':
+ $row['sort'] = $cdate;
+ break;
+ case 'Last Update':
+ $row['sort'] = $udate;
+ break;
+ case 'Assigned to':
+ $row['sort'] = $owner_link;
+ break;
+ case 'Priority':
+ $row['sort'] = $numpriority;
+ break;
+ case 'Points':
+ $row['sort'] = $points;
+ break;
+ case 'Status':
+ $row['sort'] = $status;
+ break;
+ default:
+ $row['sort'] = -$numpriority;
+ break;
+ }
+ return $row['sort'];
+ }
+
+ private function buildTaskMap ($edges, $tasks) {
+ $map = array();
+ foreach ($tasks as $task) {
+ $phid = $task->getPHID();
+ if ($parents =
+ $edges[$phid][ ManiphestTaskDependedOnByTaskEdgeType::EDGECONST]) {
+ foreach ($parents as $parent) {
+ if (isset($tasks[$parent['dst']])) {
+ $map[$phid]['parent'][] = $parent['dst'];
+ }
+ }
+ } else if ($children =
+ $edges[$phid][ManiphestTaskDependsOnTaskEdgeType::EDGECONST]) {
+ foreach ($children as $child) {
+ if (isset($tasks[$child['dst']])) {
+ $map[$phid]['child'][] = $child['dst'];
+ }
+ }
+ }
+ }
+ return $map;
+ }
+
+ private function getHandles() {
+ $handle_phids = array();
+ foreach ($this->tasks as $task) {
+ $phid = $task->getOwnerPHID();
+ $handle_phids[$phid] = $phid;
+ }
+ $handles = $this->query->getViewerHandles($this->request, $handle_phids);
+ return $handles;
+ }
+
+ private function setOwnerLink($handles, $task) {
+ $phid = $task->getOwnerPHID();
+ $owner = $handles[$phid];
+
+ if ($owner instanceof PhabricatorObjectHandle) {
+ $owner_link = $phid ? $owner->renderLink() : 'none assigned';
+ } else {
+ $owner_link = 'none assigned';
+ }
+ return $owner_link;
+ }
+
+ private function getTaskCreatedDate($task) {
+ $date_created = $task->getDateCreated();
+ return $date_created;
+ }
+
+ private function getTaskModifiedDate($task) {
+ $last_updated = $task->getDateModified();
+ return $last_updated;
+ }
+
+ private function getPriorityName($task) {
+ $priority_name = new ManiphestTaskPriority();
+ return $priority_name->getTaskPriorityName($task->getPriority());
+ }
+
+ private function getPriority($task) {
+ return $task->getPriority();
+ }
+
+ private function addTaskToTree($output, $blocked, $ptasks, $blocker,
+ $task, $handles, $points) {
+
+ $cdate = $this->getTaskCreatedDate($task);
+ $date_created = phabricator_datetime($cdate, $this->viewer);
+ $udate = $this->getTaskModifiedDate($task);
+ $last_updated = phabricator_datetime($udate, $this->viewer);
+ $status = $task->getStatus();
+
+ $owner_link = $this->setOwnerLink($handles, $task);
+ $priority = $this->getPriority($task);
+ $priority_name = $this->getPriorityName($task);
+ $is_open = ManiphestTaskStatus::isOpenStatus($task->getStatus());
+
+ if ($blocker === true && $is_open === true) {
+ $blockericon = $this->getIconforBlocker($ptasks);
+ } else {
+ $blockericon = '';
+ }
+
+ if ($blocked === true && $is_open === true) {
+ $blockedicon = $this->getIconforBlocked();
+ } else {
+ $blockedicon = '';
+ }
+
+ $output[] = array(
+ phutil_safe_html(phutil_tag(
+ 'a',
+ array(
+ 'href' => '/'.$task->getMonogram(),
+ 'class' => $status !== 'open'
+ ? 'phui-tag-core-closed'
+ : '',
+ ),
+ array ($this->buildTaskLink($task), $blockericon,
+ $blockedicon,))),
+ $cdate,
+ $date_created,
+ $udate,
+ $last_updated,
+ $owner_link,
+ $priority,
+ $priority_name,
+ $points,
+ $status,
+ );
+
+ return $output;
+ }
+
+ private function getIconforBlocker($ptasks) {
+ $linktasks = array();
+ $links = null;
+ foreach ($ptasks as $task) {
+ $linktasks[] = $this->buildTaskLink($task);
+ $links = implode('| ', $linktasks);
+ }
+
+ $sigil = 'has-tooltip';
+ $meta = array(
+ 'tip' => pht('Blocks: '.$links),
+ 'size' => 500,
+ 'align' => 'E',);
+ $image = id(new PHUIIconView())
+ ->addSigil($sigil)
+ ->setMetadata($meta)
+ ->setSpriteSheet(PHUIIconView::SPRITE_PROJECTS)
+ ->setIconFont('fa-wrench', 'green')
+ ->setText('Blocker');
+ return $image;
+ }
+
+ private function getIconforBlocked() {
+ $image = id(new PHUIIconView())
+ ->setSpriteSheet(PHUIIconView::SPRITE_PROJECTS)
+ ->setIconFont('fa-lock', 'red')
+ ->setText('Blocked');
+ return $image;
+ }
+
+ private function buildTaskLink($task) {
+ $linktext = $task->getMonogram().': '.$task->getTitle().' ';
+ return $linktext;
+ }
+
+ private function getTaskforPHID($phid) {
+ $task = id(new ManiphestTaskQuery())
+ ->setViewer($this->viewer)
+ ->withPHIDs(array($phid))
+ ->execute();
+ return $task;
+ }
+}
diff --git a/src/tests/BurndownDataDateTest.php
b/src/tests/BurndownDataDateTest.php
deleted file mode 100644
index f6aa331..0000000
--- a/src/tests/BurndownDataDateTest.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-final class BurndownDataDateTest extends SprintTestCase {
-
- public function testSumPointsTotal() {
- $date = new BurndownDataDate('test date');
- $previous = id(new BurndownDataDate('monday'));
- $previous->setPointsTotal('14');
- $current = id(new BurndownDataDate('tuesday'));
- $current->setPointsTotal('4');
- $total = $date->sumPointsTotal($current, $previous);
- $this->assertEquals(18, $total);
- }
-
- public function testSumTasksTotal() {
- $date = new BurndownDataDate('test date');
- $previous = id(new BurndownDataDate('monday'));
- $previous->setTasksTotal('5');
- $current = id(new BurndownDataDate('tuesday'));
- $current->setTasksTotal('8');
- $total = $date->sumTasksTotal($current, $previous);
- $this->assertEquals(13, $total);
- }
-
- public function testsumTasksRemaining() {
- $date = new BurndownDataDate('test date');
- $previous = id(new BurndownDataDate('monday'));
- $previous->setTasksRemaining('5');
- $current = id(new BurndownDataDate('tuesday'));
- $current->setTasksClosedToday();
- $total = $date->sumTasksRemaining($current, $previous);
- $this->assertEquals(4, $total);
- }
-
- public function testsumPointsRemaining() {
- $date = new BurndownDataDate('test date');
- $previous = id(new BurndownDataDate('monday'));
- $previous->setPointsRemaining('15');
- $current = id(new BurndownDataDate('tuesday'));
- $current->setPointsClosedToday('10');
- $total = $date->sumPointsRemaining($current, $previous);
- $this->assertEquals(5, $total);
- }
-}
\ No newline at end of file
diff --git a/src/util/BurndownDataDate.php b/src/util/BurndownDataDate.php
index 5d3e8c3..63c6883 100644
--- a/src/util/BurndownDataDate.php
+++ b/src/util/BurndownDataDate.php
@@ -15,12 +15,6 @@
private $points_closed_today;
private $points_reopened_today;
private $yesterday_points_remaining;
- private $tasks_added_before;
- private $tasks_closed_before;
- private $tasks_reopened_before;
- private $points_added_before;
- private $points_closed_before;
- private $points_reopened_before;
// Totals over time
private $tasks_total;
@@ -31,34 +25,6 @@
public function __construct($date) {
$this->date = $date;
- }
-
- public function setTasksAddedBefore () {
- return $this->tasks_added_before = $this->tasks_added_before + 1;
- }
-
- public function getTasksAddedBefore () {
- return $this->tasks_added_before;
- }
-
- public function setTasksClosedBefore () {
- return $this->tasks_closed_before = $this->tasks_closed_before + 1;
- }
-
- public function getTasksClosedBefore () {
- return $this->tasks_closed_before;
- }
-
- public function setTasksReopenedBefore () {
- return $this->tasks_reopened_before = $this->tasks_reopened_before + 1;
- }
-
- public function getTasksReopenedBefore () {
- return $this->tasks_reopened_before;
- }
-
- public function getTasksForwardfromBefore () {
- return $this->tasks_added_before + $this->tasks_reopened_before -
$this->tasks_closed_before;
}
public function setTasksAddedToday () {
@@ -107,34 +73,6 @@
public function getTasksRemaining() {
return $this->tasks_remaining;
- }
-
- public function setPointsAddedBefore ($points) {
- $this->points_added_before = $this->points_added_before + $points;
- }
-
- public function getPointsAddedBefore () {
- return $this->points_added_before;
- }
-
- public function setPointsClosedBefore ($points) {
- $this->points_closed_before = $this->points_closed_before + $points;
- }
-
- public function getPointsClosedBefore () {
- return $this->points_closed_before;
- }
-
- public function setPointsReopenedBefore ($points) {
- $this->points_reopened_before = $this->points_reopened_before + $points;
- }
-
- public function getPointsReopenedBefore () {
- return $this->points_reopened_before;
- }
-
- public function getPointsForwardfromBefore () {
- return $this->points_added_before + $this->points_reopened_before -
$this->points_closed_before;
}
public function setPointsAddedToday ($points) {
@@ -196,25 +134,4 @@
public function setPointsIdealRemaining($points_total) {
return $this->points_ideal_remaining = $points_total;
}
-
- public function sumTasksTotal($current, $previous) {
- $current->tasks_total += $previous->tasks_total;
- return $current->tasks_total;
- }
-
- public function sumPointsTotal($current, $previous) {
- $current->points_total += $previous->points_total;
- return $current->points_total;
- }
-
- public function sumTasksRemaining($current, $previous) {
- $current->tasks_remaining = $previous->tasks_remaining -
$current->tasks_closed_today;
- return $current->tasks_remaining;
- }
-
- public function sumPointsRemaining($current, $previous) {
- $current->points_remaining = $previous->points_remaining -
$current->points_closed_today;
- return $current->points_remaining;
- }
-
}
diff --git a/src/view/burndown/BoardDataPieView.php
b/src/view/burndown/BoardDataPieView.php
index 2fc8d4c..aaf8701 100644
--- a/src/view/burndown/BoardDataPieView.php
+++ b/src/view/burndown/BoardDataPieView.php
@@ -2,7 +2,6 @@
final class BoardDataPieView {
- private $project;
private $board_data;
public function setBoardData ($board_data) {
@@ -10,17 +9,35 @@
return $this;
}
- public function setProject($project) {
- $this->project = $project;
- return $this;
+ public function buildPieBox() {
+ $this->initBoardDataPie();
+ $this->initTaskStatusPie();
+ $project_name = $this->board_data->getProject()->getName();
+ $boardpie = phutil_tag('div',
+ array(
+ 'id' => 'c3-board-data-pie',
+ 'style' => 'width: 400px; height:200px; padding-right: 200px;
+ float: left;',
+ ), pht('Board'));
+ $taskpie = phutil_tag('div',
+ array(
+ 'id' => 'pie',
+ 'style' => 'width: 300px; height:200px; margin-left: 600px;',
+ ), pht('Task Status'));
+ $box = id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Progress Report for '.
+ $project_name))
+ ->appendChild($boardpie)
+ ->appendChild($taskpie);
+ return $box;
}
- public function buildBoardDataPie() {
+ private function initBoardDataPie() {
require_celerity_resource('d3', 'sprint');
require_celerity_resource('c3-css', 'sprint');
require_celerity_resource('c3', 'sprint');
- $coldata = $this->board_data->buildBoardDataSet();
+ $coldata = $this->board_data->getColumnData();
$done_points = '0';
$backlog_points = '0';
$doing_points = '0';
@@ -53,24 +70,25 @@
'Review' => $review_points,
'Done' => $done_points,
), 'sprint');
+ }
+ private function initTaskStatusPie() {
+ $sprintpoints = id(new SprintPoints())
+ ->setTaskPoints($this->board_data->getTaskPoints())
+ ->setTasks($this->board_data->getTasks());
- $boardpie = phutil_tag('div',
- array(
- 'id' => 'c3-board-data-pie',
- 'style' => 'width: 400px; height:200px; padding-right: 200px;
- float: left;',
- ), pht('Board'));
- $taskpie = phutil_tag('div',
- array(
- 'id' => 'pie',
- 'style' => 'width: 300px; height:200px; margin-left: 600px;',
- ), pht('Task Status'));
- $box = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Progress Report for '.
- $this->project->getName()))
- ->appendChild($boardpie)
- ->appendChild($taskpie);
- return $box;
+ list($task_open_status_sum, $task_closed_status_sum) = $sprintpoints
+ ->getStatusSums();
+
+ require_celerity_resource('d3', 'sprint');
+ require_celerity_resource('c3-css', 'sprint');
+ require_celerity_resource('c3', 'sprint');
+
+ $id = 'pie';
+ Javelin::initBehavior('c3-pie', array(
+ 'hardpoint' => $id,
+ 'open' => $task_open_status_sum,
+ 'resolved' => $task_closed_status_sum,
+ ), 'sprint');
}
}
diff --git a/src/view/burndown/BoardDataView.php
b/src/view/burndown/BoardDataTableView.php
similarity index 86%
rename from src/view/burndown/BoardDataView.php
rename to src/view/burndown/BoardDataTableView.php
index 786fed0..9379f64 100644
--- a/src/view/burndown/BoardDataView.php
+++ b/src/view/burndown/BoardDataTableView.php
@@ -1,6 +1,6 @@
<?php
-final class BoardDataView {
+final class BoardDataTableView {
private $board_data;
@@ -10,7 +10,7 @@
}
public function buildBoardDataTable() {
- $coldata = $this->board_data->buildBoardDataSet();
+ $coldata = $this->board_data->getColumnData();
$table = id(new AphrontTableView($coldata))
->setHeaders(
array(
diff --git a/src/view/burndown/BurndownChartView.php
b/src/view/burndown/BurndownChartView.php
new file mode 100644
index 0000000..6ac2049
--- /dev/null
+++ b/src/view/burndown/BurndownChartView.php
@@ -0,0 +1,46 @@
+<?php
+
+final class BurndownChartView {
+ private $data;
+
+ public function setChartData($chart_data) {
+ $this->data = $chart_data;
+ return $this;
+ }
+
+ public function buildBurndownChart() {
+ $chartdata = $this->data->getChartData();
+ $totalpoints = $chartdata[0];
+ $remainingpoints = $chartdata[1];
+ $idealpoints = $chartdata[2];
+ $pointstoday = $chartdata[3];
+ $timeseries = $this->data->getTimeSeries();
+ $project_name = $this->data->getProject()->getName();
+
+ require_celerity_resource('d3', 'sprint');
+ require_celerity_resource('c3-css', 'sprint');
+ require_celerity_resource('c3', 'sprint');
+
+ $id = 'chart';
+ Javelin::initBehavior('c3-chart', array(
+ 'hardpoint' => $id,
+ 'timeseries' => $timeseries,
+ 'totalpoints' => $totalpoints,
+ 'remainingpoints' => $remainingpoints,
+ 'idealpoints' => $idealpoints,
+ 'pointstoday' => $pointstoday,
+ ), 'sprint');
+
+ $chart = id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Burndown for '.$project_name))
+ ->appendChild(phutil_tag('div',
+ array(
+ 'id' => 'chart',
+ 'style' => 'width: 100%; height:400px',
+ ), ''));
+
+ return $chart;
+ }
+
+
+}
diff --git a/src/view/burndown/C3ChartView.php
b/src/view/burndown/C3ChartView.php
deleted file mode 100644
index 69ed5c2..0000000
--- a/src/view/burndown/C3ChartView.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-
-final class C3ChartView {
- private $data;
- private $project;
- private $timeseries;
-
- public function setChartData($chart_data) {
- $this->data = $chart_data;
- return $this;
- }
-
- public function setTimeSeries($timeseries) {
- $this->timeseries = $timeseries;
- return $this;
- }
-
- public function setProject($project) {
- $this->project = $project;
- return $this;
- }
-
- public function buildC3Chart() {
- $totalpoints = $this->data[0];
- $remainingpoints = $this->data[1];
- $idealpoints = $this->data[2];
- $pointstoday = $this->data[3];
- $timeseries = $this->timeseries;
-
- require_celerity_resource('d3', 'sprint');
- require_celerity_resource('c3-css', 'sprint');
- require_celerity_resource('c3', 'sprint');
-
- $id = 'chart';
- Javelin::initBehavior('c3-chart', array(
- 'hardpoint' => $id,
- 'timeseries' => $timeseries,
- 'totalpoints' => $totalpoints,
- 'remainingpoints' => $remainingpoints,
- 'idealpoints' => $idealpoints,
- 'pointstoday' => $pointstoday
- ), 'sprint');
-
- $chart = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Burndown for ' . $this->project->getName()))
- ->appendChild(phutil_tag('div',
- array(
- 'id' => 'chart',
- 'style' => 'width: 100%; height:400px'
- ), ''));
-
- return $chart;
- }
-
-
-}
\ No newline at end of file
diff --git a/src/view/burndown/C3PieView.php b/src/view/burndown/C3PieView.php
deleted file mode 100644
index e31f9e3..0000000
--- a/src/view/burndown/C3PieView.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-final class C3PieView {
-
- private $project;
- private $taskpoints;
- private $tasks;
-
- public function setProject($project) {
- $this->project = $project;
- return $this;
- }
-
- public function setTasks ($tasks) {
- $this->tasks = $tasks;
- return $this;
- }
-
- public function setTaskPoints ($taskpoints) {
- $this->taskpoints = $taskpoints;
- return $this;
- }
-
- public function buildC3Pie() {
- $sprintpoints = id(new SprintPoints())
- ->setTaskPoints($this->taskpoints)
- ->setTasks($this->tasks);
-
- list($task_open_status_sum, $task_closed_status_sum) = $sprintpoints
- ->getStatusSums();
-
- require_celerity_resource('d3', 'sprint');
- require_celerity_resource('c3-css', 'sprint');
- require_celerity_resource('c3', 'sprint');
-
- $id = 'pie';
- Javelin::initBehavior('c3-pie', array(
- 'hardpoint' => $id,
- 'open' => $task_open_status_sum,
- 'resolved' => $task_closed_status_sum,
- ), 'sprint');
-
- $pie = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Task Status Report for '.
- $this->project->getName()))
- ->appendChild(phutil_tag('div',
- array(
- 'id' => 'pie',
- 'style' => 'width: 100%; height:200px',
- ), ''));
-
- return $pie;
- }
-
-}
diff --git a/src/view/burndown/HistoryTableView.php
b/src/view/burndown/HistoryTableView.php
deleted file mode 100644
index 3a46426..0000000
--- a/src/view/burndown/HistoryTableView.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-final class HistoryTableView {
-
- public function buildHistoryTable($before) {
- $bdata = array();
- $bdata[] = array(
- $before->getTasksAddedBefore(),
- $before->getTasksReopenedBefore(),
- $before->getTasksClosedBefore(),
- $before->getPointsAddedBefore(),
- $before->getPointsForwardfromBefore(),
- );
-
- $btable = id(new AphrontTableView($bdata))
- ->setHeaders(
- array(
- pht('Tasks Added '),
- pht('Tasks Reopened'),
- pht('Tasks Closed'),
- pht('Points Added'),
- pht('Points Forwarded'),
- ));
- $box = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Before Sprint'))
- ->appendChild($btable);
- return $box;
- }
-}
diff --git a/src/view/burndown/SprintDataView.php
b/src/view/burndown/SprintDataView.php
index f18d20b..dcdd9d2 100644
--- a/src/view/burndown/SprintDataView.php
+++ b/src/view/burndown/SprintDataView.php
@@ -1,7 +1,6 @@
<?php
-final class SprintDataView extends SprintView
-{
+final class SprintDataView extends SprintView {
private $request;
private $timezone;
@@ -57,37 +56,32 @@
->setTimezone($this->timezone)
->setTaskPoints($this->taskpoints)
->setStats($stats)
- ->setQuery($query);
-
- $pie_chart_view = id(new C3PieView())
- ->setTasks($this->tasks)
- ->setTaskPoints($this->taskpoints)
- ->setProject($this->project);
- $task_pie = $pie_chart_view->buildC3Pie();
+ ->setQuery($query)
+ ->setTimeSeries($this->timeseries)
+ ->execute();
$board_data_pie_view = id(new BoardDataPieView())
- ->setBoardData($board_model)
- ->setProject($this->project);
- $pies = $board_data_pie_view->buildBoardDataPie();
+ ->setBoardData($board_model);
+ $pies = $board_data_pie_view->buildPieBox();
- $board_data_table_view = id(new BoardDataView())
+ $board_data_table_view = id(new BoardDataTableView())
->setBoardData($board_model);
$board_table = $board_data_table_view->buildBoardDataTable();
- $board_chart_data = $board_model->buildChartfromBoardData();
- $board_chart_view = id(new C3ChartView())
- ->setChartData($board_chart_data)
- ->setProject($this->project)
- ->setTimeSeries($this->timeseries);
- $board_chart = $board_chart_view->buildC3Chart();;
+ $board_chart_view = id(new BurndownChartView())
+ ->setChartData($board_model);
+ $board_chart = $board_chart_view->buildBurndownChart();
- $tasks_table_view = id(new TasksTableView())
+ $task_table_model = id(new TaskTableDataProvider())
->setProject($this->project)
->setViewer($this->viewer)
->setRequest($this->request)
->setTasks($this->tasks)
->setTaskPoints($this->taskpoints)
- ->setQuery($query);
+ ->setQuery($query)
+ ->execute();
+ $tasks_table_view = id(new TasksTableView())
+ ->setTableData($task_table_model);
$tasks_table = $tasks_table_view->buildTasksTable();
$event_table_view = id(new EventTableView())
diff --git a/src/view/burndown/SprintTableView.php
b/src/view/burndown/SprintTableView.php
deleted file mode 100644
index d63ab1c..0000000
--- a/src/view/burndown/SprintTableView.php
+++ /dev/null
@@ -1,104 +0,0 @@
-<?php
-
-final class SprintTableView {
-
- /**
- * Format the Burndown data for display on the page.
- *
- * @returns PHUIObjectBoxView
- */
- public function buildSprintTable($sprint_data, $before) {
- $tdata = array();
- $pdata = array();
-
- foreach ($sprint_data as $date) {
- $start_tasks = null;
- $tasks_before = $before->getTasksForwardfromBefore();
- $tasks_yesterday = $date->getYesterdayTasksRemaining();
- $today_tasks = $date->getTasksAddedToday();
- $tasks_remaining = $date->getTasksRemaining();
-
- $timestamp = strtotime($date->getDate());
- $now = time();
-
- if ($timestamp < $now) {
- if (!$tasks_before == 0) {
- $start_tasks = $before->getTasksForwardfromBefore();
- } else if (!$tasks_yesterday == 0) {
- $start_tasks = $date->getYesterdayTasksRemaining();
- } else if (!$today_tasks == 0) {
- $start_tasks = $today_tasks;
- } else {
- $start_tasks = $tasks_remaining;
- }
- }
-
- $tdata[] = array(
- $date->getDate(),
- $start_tasks,
- $tasks_remaining,
- $date->getTasksAddedToday(),
- $date->getTasksReopenedToday(),
- $date->getTasksClosedToday(),
- );
-
- $start_points = null;
- $before_points = $before->getPointsForwardfromBefore();
- $yesterday_points = $date->getYesterdayPointsRemaining();
- $today_points = $date->getPointsAddedToday();
- $points_remaining = $date->getPointsRemaining();
-
- if ($timestamp < $now) {
- if (!$before_points == 0) {
- $start_points = $before_points;
- } else if (!$yesterday_points == 0) {
- $start_points = $yesterday_points;
- } else if (!$today_points == 0) {
- $start_points = $today_points;
- } else {
- $start_points = $points_remaining;
- }
- }
-
- $pdata[] = array(
- $date->getDate(),
- $start_points,
- $date->getPointsRemaining(),
- $date->getPointsAddedToday(),
- $date->getPointsReopenedToday(),
- $date->getPointsClosedToday(),
- );
- }
- $ttable = id(new AphrontTableView($tdata))
- ->setHeaders(
- array(
- pht('Date'),
- pht('Starting Tasks'),
- pht('Remaining Tasks'),
- pht('Tasks Added'),
- pht('Tasks Reopened'),
- pht('Tasks Closed'),
- ));
- $ptable = id(new AphrontTableView($pdata))
- ->setHeaders(
- array(
- pht('Date'),
- pht('Starting Points'),
- pht('Remaining Points'),
- pht('Points Added'),
- pht('Points Reopened'),
- pht('Points Closed'),
- ));
- $taskdata = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Tasks'))
- ->appendChild($ttable);
- $pointsdata = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Points'))
- ->appendChild($ptable);
- $box = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Data'))
- ->appendChild($taskdata)
- ->appendChild($pointsdata);
- return $box;
- }
-}
diff --git a/src/view/burndown/TasksTableView.php
b/src/view/burndown/TasksTableView.php
index c7662f9..511f9dc 100644
--- a/src/view/burndown/TasksTableView.php
+++ b/src/view/burndown/TasksTableView.php
@@ -2,41 +2,11 @@
final class TasksTableView {
- private $project;
- private $viewer;
- private $request;
- private $tasks;
- private $taskpoints;
- private $query;
+ private $table_data;
- public function setProject ($project) {
- $this->project = $project;
- return $this;
- }
-
- public function setViewer ($viewer) {
- $this->viewer = $viewer;
- return $this;
- }
-
- public function setRequest ($request) {
- $this->request = $request;
- return $this;
- }
-
- public function setTasks ($tasks) {
- $this->tasks = $tasks;
- return $this;
- }
-
- public function setTaskPoints ($taskpoints) {
- $this->taskpoints = $taskpoints;
- return $this;
- }
-
- public function setQuery ($query) {
- $this->query = $query;
+ public function setTableData ($table_data) {
+ $this->table_data = $table_data;
return $this;
}
@@ -46,10 +16,8 @@
* @returns PHUIObjectBoxView
*/
public function buildTasksTable() {
- $order = $this->request->getStr('order', 'name');
- list($order, $reverse) = AphrontTableView::parseSort($order);
- $rows = $this->buildTasksTree($order, $reverse);
- $table = id(new AphrontTableView($rows))
+
+ $table = id(new AphrontTableView($this->table_data->getRows()))
->setHeaders(
array(
pht('Task'),
@@ -64,10 +32,10 @@
pht('Status'),
));
$table->makeSortable(
- $this->request->getRequestURI(),
+ $this->table_data->getRequest()->getRequestURI(),
'order',
- $order,
- $reverse,
+ $this->table_data->getOrder(),
+ $this->table_data->getReverse(),
array(
'Task',
'Epoch Created',
@@ -101,257 +69,5 @@
return $box;
}
- /**
- * @param string $order
- * @param integer $reverse
- * @return array
- */
- private function buildTasksTree($order, $reverse) {
- $edges = $this->query->getEdges($this->tasks);
- $map = $this->buildTaskMap($edges, $this->tasks);
- $sprintpoints = id(new SprintPoints())
- ->setTaskPoints($this->taskpoints);
- $handles = $this->getHandles();
-
- $output = array();
- $rows = array();
- foreach ($this->tasks as $task) {
- $blocked = false;
- if (isset($map[$task->getPHID()]['child'])) {
- foreach (($map[$task->getPHID()]['child']) as $phid) {
- $ctask = $this->getTaskforPHID($phid);
- foreach ($ctask as $child) {
- if (ManiphestTaskStatus::isOpenStatus($child->getStatus())) {
- $blocked = true;
- break;
- }
- }
- }
- }
-
- $ptasks = array();
- $phid = null;
- $blocker = false;
- if (isset($map[$task->getPHID()]['parent'])) {
- $blocker = true;
- foreach (($map[$task->getPHID()]['parent']) as $phid) {
- $ptask = $this->getTaskforPHID($phid);
- $ptasks = array_merge($ptasks, $ptask);
- }
- }
-
- $points = $sprintpoints->getTaskPoints($task->getPHID());
-
- $row = $this->addTaskToTree($output, $blocked, $ptasks, $blocker,
- $task, $handles, $points);
- list ($task, $cdate, , $udate, , $owner_link, $numpriority, , $points,
- $status) = $row[0];
- $row['sort'] = $this->setSortOrder($row, $order, $task, $cdate, $udate,
- $owner_link, $numpriority, $points, $status);
- $rows[] = $row;
- }
- $rows = isort($rows, 'sort');
-
- foreach ($rows as $k => $row) {
- unset($rows[$k]['sort']);
- }
-
- if ($reverse) {
- $rows = array_reverse($rows);
- }
-
- $a = array();
- $rows = array_map(function($a) { return $a['0']; }, $rows);
- return $rows;
- }
-
- private function setSortOrder ($row, $order, $task, $cdate, $udate,
- $owner_link, $numpriority, $points, $status) {
- switch ($order) {
- case 'Task':
- $row['sort'] = $task;
- break;
- case 'Date Created':
- $row['sort'] = $cdate;
- break;
- case 'Last Update':
- $row['sort'] = $udate;
- break;
- case 'Assigned to':
- $row['sort'] = $owner_link;
- break;
- case 'Priority':
- $row['sort'] = $numpriority;
- break;
- case 'Points':
- $row['sort'] = $points;
- break;
- case 'Status':
- $row['sort'] = $status;
- break;
- default:
- $row['sort'] = -$numpriority;
- break;
- }
- return $row['sort'];
- }
-
- private function buildTaskMap ($edges, $tasks) {
- $map = array();
- foreach ($tasks as $task) {
- $phid = $task->getPHID();
- if ($parents =
- $edges[$phid][ ManiphestTaskDependedOnByTaskEdgeType::EDGECONST]) {
- foreach ($parents as $parent) {
- if (isset($tasks[$parent['dst']])) {
- $map[$phid]['parent'][] = $parent['dst'];
- }
- }
- } else if ($children =
- $edges[$phid][ManiphestTaskDependsOnTaskEdgeType::EDGECONST]) {
- foreach ($children as $child) {
- if (isset($tasks[$child['dst']])) {
- $map[$phid]['child'][] = $child['dst'];
- }
- }
- }
- }
- return $map;
- }
-
- private function getHandles() {
- $handle_phids = array();
- foreach ($this->tasks as $task) {
- $phid = $task->getOwnerPHID();
- $handle_phids[$phid] = $phid;
- }
- $handles = $this->query->getViewerHandles($this->request, $handle_phids);
- return $handles;
- }
-
- private function setOwnerLink($handles, $task) {
- $phid = $task->getOwnerPHID();
- $owner = $handles[$phid];
-
- if ($owner instanceof PhabricatorObjectHandle) {
- $owner_link = $phid ? $owner->renderLink() : 'none assigned';
- } else {
- $owner_link = 'none assigned';
- }
- return $owner_link;
- }
-
- private function getTaskCreatedDate($task) {
- $date_created = $task->getDateCreated();
- return $date_created;
- }
-
- private function getTaskModifiedDate($task) {
- $last_updated = $task->getDateModified();
- return $last_updated;
- }
-
- private function getPriorityName($task) {
- $priority_name = new ManiphestTaskPriority();
- return $priority_name->getTaskPriorityName($task->getPriority());
- }
-
- private function getPriority($task) {
- return $task->getPriority();
- }
-
- private function addTaskToTree($output, $blocked, $ptasks, $blocker,
- $task, $handles, $points) {
-
- $cdate = $this->getTaskCreatedDate($task);
- $date_created = phabricator_datetime($cdate, $this->viewer);
- $udate = $this->getTaskModifiedDate($task);
- $last_updated = phabricator_datetime($udate, $this->viewer);
- $status = $task->getStatus();
-
- $owner_link = $this->setOwnerLink($handles, $task);
- $priority = $this->getPriority($task);
- $priority_name = $this->getPriorityName($task);
- $is_open = ManiphestTaskStatus::isOpenStatus($task->getStatus());
-
- if ($blocker === true && $is_open === true) {
- $blockericon = $this->getIconforBlocker($ptasks);
- } else {
- $blockericon = '';
- }
-
- if ($blocked === true && $is_open === true) {
- $blockedicon = $this->getIconforBlocked();
- } else {
- $blockedicon = '';
- }
-
- $output[] = array(
- phutil_safe_html(phutil_tag(
- 'a',
- array(
- 'href' => '/'.$task->getMonogram(),
- 'class' => $status !== 'open'
- ? 'phui-tag-core-closed'
- : '',
- ),
- array ($this->buildTaskLink($task), $blockericon,
- $blockedicon,))),
- $cdate,
- $date_created,
- $udate,
- $last_updated,
- $owner_link,
- $priority,
- $priority_name,
- $points,
- $status,
- );
-
- return $output;
- }
-
- private function getIconforBlocker($ptasks) {
- $linktasks = array();
- $links = null;
- foreach ($ptasks as $task) {
- $linktasks[] = $this->buildTaskLink($task);
- $links = implode('| ', $linktasks);
- }
-
- $sigil = 'has-tooltip';
- $meta = array(
- 'tip' => pht('Blocks: '.$links),
- 'size' => 500,
- 'align' => 'E',);
- $image = id(new PHUIIconView())
- ->addSigil($sigil)
- ->setMetadata($meta)
- ->setSpriteSheet(PHUIIconView::SPRITE_PROJECTS)
- ->setIconFont('fa-wrench', 'green')
- ->setText('Blocker');
- return $image;
- }
-
- private function getIconforBlocked() {
- $image = id(new PHUIIconView())
- ->setSpriteSheet(PHUIIconView::SPRITE_PROJECTS)
- ->setIconFont('fa-lock', 'red')
- ->setText('Blocked');
- return $image;
- }
-
- private function buildTaskLink($task) {
- $linktext = $task->getMonogram().': '.$task->getTitle().' ';
- return $linktext;
- }
-
- private function getTaskforPHID($phid) {
- $task = id(new ManiphestTaskQuery())
- ->setViewer($this->viewer)
- ->withPHIDs(array($phid))
- ->execute();
- return $task;
- }
}
--
To view, visit https://gerrit.wikimedia.org/r/189456
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I20c2165f9789803f447b8f92f6e3c77ade23bac2
Gerrit-PatchSet: 1
Gerrit-Project: phabricator/extensions/Sprint
Gerrit-Branch: master
Gerrit-Owner: Christopher Johnson (WMDE) <[email protected]>
Gerrit-Reviewer: Christopher Johnson (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits