From 1ad9053e40bcfd2fbab15f56c52d69ca4f87a26f Mon Sep 17 00:00:00 2001 From: Daniel Stone <daniels@collabora.com> Date: Mon, 18 Apr 2016 13:27:52 +0100 Subject: [PATCH] Remove unnecessary story-points field For some reason, despite using Maniphest's built-in story-points field, the extension continued to provide its own, which resulted in duplicate fields showing in the UI. Remove it, and all remenants of code using it, to avoid confusion. Signed-off-by: Daniel Stone <daniels@collabora.com> Differential Revision: https://phabricator.collabora.co.uk/D483 --- src/__phutil_library_map__.php | 5 - src/constants/SprintConstants.php | 1 - .../SprintTaskStoryPointsField.php | 129 ------------------ src/query/SprintQuery.php | 29 ---- src/tests/SprintCustomFieldTest.php | 18 --- src/view/burndown/SprintDataView.php | 2 - 6 files changed, 184 deletions(-) delete mode 100644 src/customfield/SprintTaskStoryPointsField.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 6436dba..ec9e620 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -69,7 +69,6 @@ phutil_register_library_map(array( 'SprintStats' => 'storage/SprintStats.php', 'SprintStatsTest' => 'tests/SprintStatsTest.php', 'SprintTableView' => 'view/SprintTableView.php', - 'SprintTaskStoryPointsField' => 'customfield/SprintTaskStoryPointsField.php', 'SprintTestCase' => 'tests/SprintTestCase.php', 'SprintUIObjectBoxView' => 'view/SprintUIObjectBoxView.php', 'SprintValidator' => 'util/SprintValidator.php', @@ -135,10 +134,6 @@ phutil_register_library_map(array( 'SprintSetStartEndDatesConduitAPIMethod' => 'SprintConduitAPIMethod', 'SprintStatsTest' => 'SprintTestCase', 'SprintTableView' => 'AphrontView', - 'SprintTaskStoryPointsField' => array( - 'ManiphestCustomField', - 'PhabricatorStandardCustomFieldInterface', - ), 'SprintTestCase' => 'PHPUnit_Framework_TestCase', 'SprintUIObjectBoxView' => 'AphrontView', 'SprintValidator' => 'Phobject', diff --git a/src/constants/SprintConstants.php b/src/constants/SprintConstants.php index bea56a3..0e93e6f 100644 --- a/src/constants/SprintConstants.php +++ b/src/constants/SprintConstants.php @@ -2,7 +2,6 @@ final class SprintConstants { - const POINTFIELD_INDEX = 'yERhvoZPNPtM'; const SPRINTFIELD_INDEX = 'scsOmkpB9Tqi'; const PANEL_BURNDOWN = 'project.sprint'; const PANEL_PHRAGILE = 'project.phragile'; diff --git a/src/customfield/SprintTaskStoryPointsField.php b/src/customfield/SprintTaskStoryPointsField.php deleted file mode 100644 index 42a8ac0..0000000 --- a/src/customfield/SprintTaskStoryPointsField.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php - -/** - * @author Michael Peters - * @author Christopher Johnson - * @license GPL version 3 - */ - -final class SprintTaskStoryPointsField extends ManiphestCustomField - implements - PhabricatorStandardCustomFieldInterface { - - private $obj; - private $textproxy; - - public function __construct() { - $this->obj = clone $this; - $this->textproxy = id(new PhabricatorStandardCustomFieldInt()) - ->setFieldKey($this->getFieldKey()) - ->setApplicationField($this->obj) - ->setFieldConfig(array( - 'name' => $this->getFieldName(), - 'description' => $this->getFieldDescription(), - )); - $this->setProxy($this->textproxy); - } - - public function canSetProxy() { - return true; - } - - public function getFieldKey() { - return 'isdc:sprint:storypoints'; - } - - public function getModernFieldKey() { - return 'storypoints'; - } - - public function getFieldName() { - return 'Story Points'; - } - - public function getFieldDescription() { - return 'Estimated story points for this task'; - } - - public function getStandardCustomFieldNamespace() { - return 'maniphest'; - } - - public function showField() { - static $show = null; - - $viewer = $this->getViewer(); - - if ($show == null) { - - if ($this->getObject() instanceof ManiphestTask) { - $id = $this->getObject()->getID(); - if ($id) { - $task = id(new ManiphestTaskQuery()) - ->setViewer($viewer) - ->withIds(array($id)) - ->needProjectPHIDs(true) - ->executeOne(); - $projectphids = $task->getProjectPHIDs(); - } - } - - if (empty($projectphids)) { - return $show = false; - } - - $show = false; - foreach ($projectphids as $projectphid) { - if ($this->isSprint($projectphid)) { - $show = true; - break; - } - } - } - return $show; - } - - public function renderPropertyViewLabel() { - if ($this->showField() === true) { - if ($this->textproxy) { - return $this->textproxy->renderPropertyViewLabel(); - } - return $this->getFieldName(); - } - } - - public function renderPropertyViewValue(array $handles) { - if ($this->showField() === true) { - if ($this->textproxy) { - return $this->textproxy->renderPropertyViewValue($handles); - } - throw new PhabricatorCustomFieldImplementationIncompleteException($this); - } - } - - public function shouldAppearInEditView() { - return true; - } - - public function renderEditControl(array $handles) { - if ($this->showField() === true) { - if ($this->textproxy) { - return $this->textproxy->renderEditControl($handles); - } - throw new PhabricatorCustomFieldImplementationIncompleteException($this); - } - } - - // == Search - public function shouldAppearInApplicationSearch() { - return true; - } - - protected function isSprint($projectphid) { - $validator = new SprintValidator(); - $issprint = call_user_func(array($validator, 'checkForSprint'), - array($validator, 'isSprint'), $projectphid); - return $issprint; - } - -} diff --git a/src/query/SprintQuery.php b/src/query/SprintQuery.php index b1463f0..6964ed1 100644 --- a/src/query/SprintQuery.php +++ b/src/query/SprintQuery.php @@ -103,21 +103,6 @@ final class SprintQuery extends SprintDAO { return $tasks; } - public function getStoryPointsForTask($task_phid) { - $points = null; - $object = new ManiphestCustomFieldStorage(); - $corecustomfield = $object->loadRawDataWhere('objectPHID= %s AND - fieldIndex=%s', $task_phid, SprintConstants::POINTFIELD_INDEX); - if (!empty($corecustomfield)) { - foreach ($corecustomfield as $array) { - $points = idx($array, 'fieldValue'); - } - } else { - $points = 0; - } - return $points; - } - public function getIsSprint() { $issprint = null; $object = new PhabricatorProjectCustomFieldStorage(); @@ -242,20 +227,6 @@ final class SprintQuery extends SprintDAO { return $data; } - public function getTaskData() { - $task_dao = new ManiphestCustomFieldStorage(); - $data = queryfx_all( - $this->getCustomFieldConn(), - 'SELECT f.* FROM %T f %Q - WHERE fieldIndex = %s', - $this->getCustomFieldObj()->getTableName(), - $this->getCustomFieldJoins(), - SprintConstants::POINTFIELD_INDEX); - - $task_data = $task_dao->loadAllFromArray($data); - return $task_data; - } - public function getEdges($tasks) { // Load all edges of depends and depended on tasks $edges = id(new PhabricatorEdgeQuery()) diff --git a/src/tests/SprintCustomFieldTest.php b/src/tests/SprintCustomFieldTest.php index ebe91c8..12fbb7f 100644 --- a/src/tests/SprintCustomFieldTest.php +++ b/src/tests/SprintCustomFieldTest.php @@ -20,24 +20,6 @@ final class SprintCustomFieldTest extends SprintTestCase { $this->assertEquals($fieldname, 'When a sprint starts'); } - public function testgetStoryPointsFieldName() { - $subclassname = new SprintTaskStoryPointsField(); - $fieldname = $subclassname->getFieldName(); - $this->assertEquals($fieldname, 'Story Points'); - } - - public function testgetStoryPointsFieldKey() { - $subclassname = new SprintTaskStoryPointsField(); - $fieldname = $subclassname->getFieldKey(); - $this->assertEquals($fieldname, 'isdc:sprint:storypoints'); - } - - public function testgetStoryPointsFieldDescription() { - $subclassname = new SprintTaskStoryPointsField(); - $fieldname = $subclassname->getFieldDescription(); - $this->assertEquals($fieldname, 'Estimated story points for this task'); - } - public function testgetEndFieldName() { $subclassname = new SprintEndDateField(); $fieldname = $subclassname->getFieldName(); diff --git a/src/view/burndown/SprintDataView.php b/src/view/burndown/SprintDataView.php index 67b1d37..c34e8ac 100644 --- a/src/view/burndown/SprintDataView.php +++ b/src/view/burndown/SprintDataView.php @@ -8,7 +8,6 @@ final class SprintDataView extends SprintView { private $project; private $viewer; private $tasks; - private $taskpoints; private $events; private $start; private $end; @@ -36,7 +35,6 @@ final class SprintDataView extends SprintView { ->setPHID($this->project->getPHID()); $tasks = $query->getTasks(); - $this->taskpoints = $query->getTaskData(); $this->tasks = mpull($tasks, null, 'getPHID'); $stats = id(new SprintStats()); -- GitLab