Christopher Johnson (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/180564
Change subject: adds SprintDAO
......................................................................
adds SprintDAO
this is a major overhaul of data access. The objective is to improve
performance. Wasteful range queries have been eliminated in favor of
direct lookups for points.
Also added is a new DefaultViewCapability
Change-Id: I6c27dcf23668bdb01726d1550bc64d2e25e99e9e
---
M src/__phutil_library_map__.php
M src/application/SprintApplication.php
A src/capability/SprintDefaultViewCapability.php
M src/controller/board/SprintBoardController.php
M src/controller/board/SprintBoardViewController.php
M src/customfield/SprintTaskStoryPointsField.php
M src/query/SprintQuery.php
A src/storage/SprintDAO.php
M src/storage/SprintTransaction.php
M src/view/SprintBoardTaskCard.php
M src/view/TasksTableView.php
11 files changed, 69 insertions(+), 51 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/phabricator/extensions/Sprint
refs/changes/64/180564/1
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
index a6457b5..10c1f52 100644
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -42,6 +42,7 @@
'SprintControllerTest' => 'tests/SprintControllerTest.php',
'SprintDAO' => 'storage/SprintDAO.php',
'SprintDataViewController' => 'controller/SprintDataViewController.php',
+ 'SprintDefaultViewCapability' =>
'capability/SprintDefaultViewCapability.php',
'SprintEndDateField' => 'customfield/SprintEndDateField.php',
'SprintFactDaemon' => 'fact/SprintFactDaemon.php',
'SprintFactUpdateIterator' => 'fact/SprintFactUpdateIterator.php',
@@ -54,7 +55,6 @@
'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',
@@ -91,6 +91,7 @@
'SprintControllerTest' => 'SprintTestCase',
'SprintDAO' => 'PhabricatorLiskDAO',
'SprintDataViewController' => 'SprintController',
+ 'SprintDefaultViewCapability' => 'PhabricatorPolicyCapability',
'SprintEndDateField' => 'SprintProjectCustomField',
'SprintFactDaemon' => 'PhabricatorDaemon',
'SprintFactUpdateIterator' => 'PhutilBufferedIterator',
@@ -100,23 +101,11 @@
'PhabricatorStandardCustomFieldInterface',
),
'SprintProjectProfileController' => 'SprintController',
+ 'SprintQuery' => 'SprintDAO',
'SprintQueryTest' => 'SprintTestCase',
'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/application/SprintApplication.php
b/src/application/SprintApplication.php
index bb55617..cba8c8f 100644
--- a/src/application/SprintApplication.php
+++ b/src/application/SprintApplication.php
@@ -94,6 +94,18 @@
ProjectCanLockProjectsCapability::CAPABILITY => array(
'default' => PhabricatorPolicies::POLICY_ADMIN,
),
+ SprintDefaultViewCapability::CAPABILITY => array(
+ 'caption' => pht(
+ 'Default view policy for newly created sprints.'),
+ ),
+ ProjectDefaultViewCapability::CAPABILITY => array(
+ 'caption' => pht(
+ 'Default view policy for newly created projects.'),
+ ),
+ ProjectDefaultEditCapability::CAPABILITY => array(
+ 'caption' => pht(
+ 'Default edit policy for newly created projects.'),
+ ),
ManiphestDefaultViewCapability::CAPABILITY => array(
'caption' => pht('Default view policy for newly created tasks.'),
),
@@ -105,7 +117,6 @@
ManiphestEditPoliciesCapability::CAPABILITY => array(),
ManiphestEditPriorityCapability::CAPABILITY => array(),
ManiphestEditProjectsCapability::CAPABILITY => array(),
- ManiphestBulkEditCapability::CAPABILITY => array(),
);
}
}
diff --git a/src/capability/SprintDefaultViewCapability.php
b/src/capability/SprintDefaultViewCapability.php
new file mode 100644
index 0000000..d59d8d4
--- /dev/null
+++ b/src/capability/SprintDefaultViewCapability.php
@@ -0,0 +1,15 @@
+<?php
+
+final class SprintDefaultViewCapability
+ extends PhabricatorPolicyCapability {
+
+ const CAPABILITY = 'sprint.default.view';
+
+ public function getCapabilityName() {
+ return pht('Default View Policy');
+ }
+
+ public function shouldAllowPublicPolicySetting() {
+ return true;
+ }
+}
diff --git a/src/controller/board/SprintBoardController.php
b/src/controller/board/SprintBoardController.php
index c236d21..322cc9f 100644
--- a/src/controller/board/SprintBoardController.php
+++ b/src/controller/board/SprintBoardController.php
@@ -5,6 +5,10 @@
private $project;
+ public function shouldAllowPublic() {
+ return true;
+ }
+
protected function setProject(PhabricatorProject $project) {
$this->project = $project;
return $this;
diff --git a/src/controller/board/SprintBoardViewController.php
b/src/controller/board/SprintBoardViewController.php
index 7b9c007..4725f05 100644
--- a/src/controller/board/SprintBoardViewController.php
+++ b/src/controller/board/SprintBoardViewController.php
@@ -11,10 +11,6 @@
private $sortKey;
private $showHidden;
- public function shouldAllowPublic() {
- return true;
- }
-
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
$this->slug = idx($data, 'slug');
diff --git a/src/customfield/SprintTaskStoryPointsField.php
b/src/customfield/SprintTaskStoryPointsField.php
index ad31166..18d49ed 100644
--- a/src/customfield/SprintTaskStoryPointsField.php
+++ b/src/customfield/SprintTaskStoryPointsField.php
@@ -9,6 +9,7 @@
private $obj;
private $text_proxy;
+ private $fieldValue;
public function __construct() {
$this->obj = clone $this;
diff --git a/src/query/SprintQuery.php b/src/query/SprintQuery.php
index 1c2fd9f..eb0db36 100644
--- a/src/query/SprintQuery.php
+++ b/src/query/SprintQuery.php
@@ -1,6 +1,6 @@
<?php
-final class SprintQuery {
+final class SprintQuery extends SprintDAO {
private $viewer;
private $project;
@@ -57,26 +57,17 @@
return $tasks;
}
- public function getPointsfromArray($task_phid, $data) {
- $storypoints = null;
- foreach ($data as $k=>$subarray) {
- if (isset ($subarray['objectPHID']) && $subarray['objectPHID'] ==
$task_phid) {
- $data[$k] = $subarray;
- $storypoints = $subarray['newValue'];
- }
+ public function getStoryPointsForTask($task_phid) {
+ $object = new ManiphestCustomFieldStorage();
+ $corecustomfield = $object->loadRawDataWhere('objectPHID= %s', $task_phid);
+ if (!empty($corecustomfield)) {
+ $points = idx($corecustomfield['0'], 'fieldValue');
+ } else {
+ $points = null;
}
- $points = trim($storypoints, '"');
- return $points;
+ return $points;
}
- public function getPointsTransactions() {
- return $this->getXactionData(SprintConstants::CUSTOMFIELD_TYPE_STATUS);
- }
-
- public function getStoryPoints($task_phid, $data) {
- $points = $this->getPointsfromArray($task_phid, $data);
- return $points;
- }
public function getXactions($tasks) {
$task_phids = mpull($tasks, 'getPHID');
diff --git a/src/storage/SprintDAO.php b/src/storage/SprintDAO.php
new file mode 100644
index 0000000..5ea91af
--- /dev/null
+++ b/src/storage/SprintDAO.php
@@ -0,0 +1,9 @@
+<?php
+
+abstract class SprintDAO extends PhabricatorLiskDAO {
+
+ public function getApplicationName() {
+ return 'sprint';
+ }
+
+}
\ No newline at end of file
diff --git a/src/storage/SprintTransaction.php
b/src/storage/SprintTransaction.php
index bbcfe56..d3a0cbd 100644
--- a/src/storage/SprintTransaction.php
+++ b/src/storage/SprintTransaction.php
@@ -15,7 +15,6 @@
public function buildDailyData($events, $before, $start, $end, $dates,
$xactions, $project) {
$query = id(new SprintQuery());
- $points_data = $query->getPointsTransactions();
foreach ($events as $event) {
$date = null;
@@ -26,7 +25,7 @@
$project_phids = $xaction->getObject()->getProjectPHIDs();
if (in_array($project_phid, $project_phids)) {
- $points = $query->getStoryPoints($task_phid, $points_data);
+ $points = $query->getStoryPointsForTask($task_phid);
$old_point_value = $xaction->getOldValue();
$new_point_value = $xaction->getNewValue();
$date = phabricator_format_local_time($xaction_date, $this->viewer, 'D
M j');
diff --git a/src/view/SprintBoardTaskCard.php b/src/view/SprintBoardTaskCard.php
index 8c86df6..9583d54 100644
--- a/src/view/SprintBoardTaskCard.php
+++ b/src/view/SprintBoardTaskCard.php
@@ -62,9 +62,8 @@
$task = $this->getTask();
$task_phid = $task->getPHID();
$owner = $this->getOwner();
- $data = $query->getPointsTransactions();
- $points = $query->getStoryPoints($task_phid, $data);
- $can_edit = $this->getCanEdit();
+ $points = $query->getStoryPointsForTask($task_phid);
+ $can_edit = $this->getCanEdit();
$color_map = ManiphestTaskPriority::getColorMap();
$bar_color = idx($color_map, $task->getPriority(), 'grey');
@@ -88,6 +87,12 @@
->setIcon('fa-pencil')
->addSigil('edit-project-card')
->setHref('/sprint/board/task/edit/'.$task->getID().'/'))
+ ->addAction(
+ id(new PHUIListItemView())
+ ->setName(pht('View Checklist'))
+ ->setIcon('fa-camera-retro')
+ ->addSigil('edit-project-card')
+ ->setHref("/search/attach/{$task_phid}/MOCK/edge/"))
->setBarColor($bar_color);
if ($owner) {
diff --git a/src/view/TasksTableView.php b/src/view/TasksTableView.php
index 9949bed..8b1ce1c 100644
--- a/src/view/TasksTableView.php
+++ b/src/view/TasksTableView.php
@@ -111,8 +111,7 @@
$edges = $query->getEdges($tasks);
$map = $this->buildTaskMap($edges, $tasks);
- $points_data = $query->getPointsTransactions();
- // We also collect the phids we need to fetch owner information
+ // We also collect the phids we need to fetch owner information
$handle_phids = array();
foreach ($tasks as $task) {
// Get the owner (assigned to) phid
@@ -132,7 +131,7 @@
$blocked = true;
}
- $points = $this->getTaskPoints($task, $points_data);
+ $points = $this->getTaskPoints($task);
$row = $this->addTaskToTree($output, $blocked, $task, $handles, $points);
list ($task, $cdate, $date_created, $udate, $last_update, $owner_link,
$numpriority, $priority, $points, $status) = $row[0];
$row['sort'] = $this->setSortOrder($row, $order, $task, $cdate, $udate,
$owner_link, $numpriority, $points, $status);
@@ -220,11 +219,11 @@
return $owner_link;
}
- private function getTaskPoints($task, $points_data) {
+ private function getTaskPoints($task) {
$query = id(new SprintQuery())
->setProject($this->project)
->setViewer($this->viewer);
- $points = $query->getPointsfromArray($task->getPHID(),$points_data);
+ $points = $query->getStoryPointsForTask($task->getPHID());
return $points;
}
@@ -290,10 +289,10 @@
return $status;
}
- private function sumPointsbyStatus ($task, $points_data) {
+ private function sumPointsbyStatus ($task) {
$stats = id(new SprintBuildStats());
$status = $this->setTaskStatus($task);
- $points = $this->getTaskPoints($task, $points_data);
+ $points = $this->getTaskPoints($task);
if ($status == 'open') {
$this->task_open_status_sum =
$stats->setTaskOpenStatusSum($this->task_open_status_sum, $points);
} elseif ($status == 'resolved') {
@@ -307,10 +306,9 @@
->setProject($this->project)
->setViewer($this->viewer);
$tasks = $query->getTasks();
- $points_data =
$query->getXactionData(SprintConstants::CUSTOMFIELD_TYPE_STATUS);
$tasks = mpull($tasks, null, 'getPHID');
foreach ($tasks as $task) {
- $this->sumPointsbyStatus($task, $points_data);
+ $this->sumPointsbyStatus($task);
}
return;
}
--
To view, visit https://gerrit.wikimedia.org/r/180564
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c27dcf23668bdb01726d1550bc64d2e25e99e9e
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