Christopher Johnson (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/189214
Change subject: SprintReport refactoring
......................................................................
SprintReport refactoring
Change-Id: Ic137364ee78a92ea6266efe8c637887ffed11789
---
M src/query/SprintQuery.php
M src/view/SprintView.php
M src/view/reports/SprintReportBurndownView.php
M src/view/reports/SprintReportOpenTasksView.php
4 files changed, 37 insertions(+), 39 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/phabricator/extensions/Sprint
refs/changes/14/189214/1
diff --git a/src/query/SprintQuery.php b/src/query/SprintQuery.php
index 06574e6..52890a4 100644
--- a/src/query/SprintQuery.php
+++ b/src/query/SprintQuery.php
@@ -260,14 +260,11 @@
return $positions;
}
- public function extractEvents($xactions, $scope_phid) {
+ public function extractEvents($xactions) {
assert_instances_of($xactions, 'ManiphestTransaction');
$events = array();
foreach ($xactions as $xaction) {
- $old = $xaction->getOldValue();
- $new = $xaction->getNewValue();
-
$events[] = array(
'transactionPHID' => $xaction->getPHID(),
'objectPHID' => $xaction->getObjectPHID(),
diff --git a/src/view/SprintView.php b/src/view/SprintView.php
index 69da9bd..99aa476 100644
--- a/src/view/SprintView.php
+++ b/src/view/SprintView.php
@@ -2,7 +2,8 @@
abstract class SprintView extends AphrontView {
- public function renderReportFilters(array $tokens, $has_window, $user) {
+ public function renderReportFilters(array $tokens, $has_window, $request,
+ $user) {
$form = id(new AphrontFormView())
->setUser($user)
@@ -15,7 +16,7 @@
->setValue($tokens));
if ($has_window) {
- list($window_str, , $window_error) = $this->getWindow();
+ list($window_str, , $window_error) = $this->getWindow($request);
$form
->appendChild(
id(new AphrontFormTextControl())
@@ -37,4 +38,33 @@
return $filter;
}
+
+ public function getWindow($request) {
+ $window_str = $request->getStr('window', '12 AM 7 days ago');
+
+ $error = null;
+
+ // Do locale-aware parsing so that the user's timezone is assumed for
+ // time windows like "3 PM", rather than assuming the server timezone.
+
+ $window_epoch = PhabricatorTime::parseLocalTime($window_str, $this->user);
+ if (!$window_epoch) {
+ $error = 'Invalid';
+ $window_epoch = time() - (60 * 60 * 24 * 7);
+ }
+
+ // If the time ends up in the future, convert it to the corresponding time
+ // and equal distance in the past. This is so users can type "6 days"
(which
+ // means "6 days from now") and get the behavior of "6 days ago", rather
+ // than no results (because the window epoch is in the future). This might
+ // be a little confusing because it casues "tomorrow" to mean "yesterday"
+ // and "2022" (or whatever) to mean "ten years ago", but these inputs are
+ // nonsense anyway.
+
+ if ($window_epoch > time()) {
+ $window_epoch = time() - ($window_epoch - time());
+ }
+
+ return array($window_str, $window_epoch, $error);
+ }
}
diff --git a/src/view/reports/SprintReportBurndownView.php
b/src/view/reports/SprintReportBurndownView.php
index 2675d63..24e929b 100644
--- a/src/view/reports/SprintReportBurndownView.php
+++ b/src/view/reports/SprintReportBurndownView.php
@@ -40,7 +40,7 @@
$tokens = $this->getTokens($handle);
}
$filter = parent::renderReportFilters($tokens, $has_window = false,
- $this->user);
+ $this->request, $this->user);
return $filter;
}
diff --git a/src/view/reports/SprintReportOpenTasksView.php
b/src/view/reports/SprintReportOpenTasksView.php
index ae17606..7df607f 100644
--- a/src/view/reports/SprintReportOpenTasksView.php
+++ b/src/view/reports/SprintReportOpenTasksView.php
@@ -96,7 +96,7 @@
$tokens = array($project_handle);
}
$filter = parent::renderReportFilters($tokens, $has_window = false,
- $this->user);
+ $this->request, $this->user);
return array($filter, $panel);
}
@@ -286,7 +286,7 @@
pht('Oldest (Pri)'));
$cclass[] = 'center narrow';
- list($window_epoch) = $this->getWindow();
+ list($window_epoch) = $this->getWindow($this->request);
$edate = phabricator_datetime($window_epoch, $this->user);
$cname[] = javelin_tag(
'span',
@@ -337,7 +337,7 @@
* Load all the tasks that have been recently closed.
*/
private function loadRecentlyClosedTasks() {
- list(, , $window_epoch) = $this->getWindow();
+ list(, , $window_epoch) = $this->getWindow($this->request);
$table = new ManiphestTask();
$xtable = new ManiphestTransaction();
@@ -403,35 +403,6 @@
->needProjectPHIDs(true)
->withStatuses(ManiphestTaskStatus::getOpenStatusConstants());
return $query;
- }
-
- private function getWindow() {
- $window_str = $this->request->getStr('window', '12 AM 7 days ago');
-
- $error = null;
-
- // Do locale-aware parsing so that the user's timezone is assumed for
- // time windows like "3 PM", rather than assuming the server timezone.
-
- $window_epoch = PhabricatorTime::parseLocalTime($window_str, $this->user);
- if (!$window_epoch) {
- $error = 'Invalid';
- $window_epoch = time() - (60 * 60 * 24 * 7);
- }
-
- // If the time ends up in the future, convert it to the corresponding time
- // and equal distance in the past. This is so users can type "6 days"
(which
- // means "6 days from now") and get the behavior of "6 days ago", rather
- // than no results (because the window epoch is in the future). This might
- // be a little confusing because it casues "tomorrow" to mean "yesterday"
- // and "2022" (or whatever) to mean "ten years ago", but these inputs are
- // nonsense anyway.
-
- if ($window_epoch > time()) {
- $window_epoch = time() - ($window_epoch - time());
- }
-
- return array($window_str, $window_epoch, $error);
}
private function getProjectHandle($phids, $project_phid) {
--
To view, visit https://gerrit.wikimedia.org/r/189214
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic137364ee78a92ea6266efe8c637887ffed11789
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