Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/controller/ManiphestReportController.php
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
->setNavigation($nav); | ->setNavigation($nav); | ||||
} | } | ||||
/** | /** | ||||
* Render the "Burnup Rate" on /maniphest/report/burn/. | |||||
* | |||||
* Ironically this is not called for the "Burndown" on /project/reports/$id/ | |||||
* as that's handled by PhabricatorProjectReportsController instead. | |||||
* | |||||
* @return array<AphrontListFilterView, PHUIObjectBoxView> | * @return array<AphrontListFilterView, PHUIObjectBoxView> | ||||
*/ | */ | ||||
public function renderBurn() { | public function renderBurn() { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
$handle = null; | $handle = null; | ||||
▲ Show 20 Lines • Show All 396 Lines • ▼ Show 20 Lines | foreach ($data as $row) { | ||||
++$counter; | ++$counter; | ||||
$out[$t] = $counter; | $out[$t] = $counter; | ||||
} | } | ||||
} | } | ||||
return array(array_keys($out), array_values($out)); | return array(array_keys($out), array_values($out)); | ||||
} | } | ||||
/** | |||||
* @param $label string Time representation for the row, e.g. "Feb 29 2024", | |||||
* "All Time", "Week of May 10 2024", "Month To Date", etc. | |||||
* @param $info array<string,int> open|close; number of tasks in timespan | |||||
* @return array<string,string,string,PhutilSafeHTML> Row text label; number | |||||
* of open tasks as string; number of closed tasks as string; | |||||
* PhutilSafeHTML such as "<span class="red">+144</span>" | |||||
*/ | |||||
private function formatBurnRow($label, $info) { | private function formatBurnRow($label, $info) { | ||||
$delta = $info['open'] - $info['close']; | $delta = $info['open'] - $info['close']; | ||||
$fmt = number_format($delta); | $fmt = number_format($delta); | ||||
if ($delta > 0) { | if ($delta > 0) { | ||||
$fmt = '+'.$fmt; | $fmt = '+'.$fmt; | ||||
$fmt = phutil_tag('span', array('class' => 'red'), $fmt); | $fmt = phutil_tag('span', array('class' => 'red'), $fmt); | ||||
} else { | } else { | ||||
$fmt = phutil_tag('span', array('class' => 'green'), $fmt); | $fmt = phutil_tag('span', array('class' => 'green'), $fmt); | ||||
} | } | ||||
return array( | return array( | ||||
$label, | $label, | ||||
number_format($info['open']), | number_format($info['open']), | ||||
number_format($info['close']), | number_format($info['close']), | ||||
$fmt, | $fmt, | ||||
); | ); | ||||
} | } | ||||
/** | |||||
* @return int 50 | |||||
valerio.bozzolan: I don't like hardcoding it also in PHPDoc lol
Maybe better to say that "greater means big… | |||||
Done Inline ActionsThe docs cover the current behavior. ;) I'll leave understanding Priority integers as an exercise to admins and developers if anyone ever wants to dig into that. aklapper: The docs cover the current behavior. ;) I'll leave understanding Priority integers as an… | |||||
Not Done Inline ActionsThis is a nightmare for my dreams but I have already approved so... asd But better to explain what it is than to explain its current value valerio.bozzolan: This is a nightmare for my dreams but I have already approved so... asd
But better to explain… | |||||
*/ | |||||
private function getAveragePriority() { | private function getAveragePriority() { | ||||
// TODO: This is sort of a hard-code for the default "normal" status. | // TODO: This is sort of a hard-code for the default "normal" status. | ||||
// When reports are more powerful, this should be made more general. | // When reports are more powerful, this should be made more general. | ||||
return 50; | return 50; | ||||
} | } | ||||
/** | |||||
* Render all table cells in the "Open Tasks" table on /maniphest/report/*. | |||||
* | |||||
* @return array<AphrontListFilterView,PHUIObjectBoxView> | |||||
*/ | |||||
public function renderOpenTasks() { | public function renderOpenTasks() { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
$query = id(new ManiphestTaskQuery()) | $query = id(new ManiphestTaskQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()); | ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()); | ||||
▲ Show 20 Lines • Show All 268 Lines • ▼ Show 20 Lines | public function renderOpenTasks() { | ||||
} | } | ||||
$filter = $this->renderReportFilters($tokens, $has_window = true); | $filter = $this->renderReportFilters($tokens, $has_window = true); | ||||
return array($filter, $panel); | return array($filter, $panel); | ||||
} | } | ||||
/** | /** | ||||
* Load all the tasks that have been recently closed. | * Load all tasks that have been recently closed. | ||||
* This is used for the "Recently Closed" column on /maniphest/report/*. | |||||
* | |||||
* @return array<ManiphestTask|null> | |||||
*/ | */ | ||||
private function loadRecentlyClosedTasks() { | private function loadRecentlyClosedTasks() { | ||||
list($ignored, $window_epoch) = $this->getWindow(); | list($ignored, $window_epoch) = $this->getWindow(); | ||||
$table = new ManiphestTask(); | $table = new ManiphestTask(); | ||||
$xtable = new ManiphestTransaction(); | $xtable = new ManiphestTransaction(); | ||||
$conn_r = $table->establishConnection('r'); | $conn_r = $table->establishConnection('r'); | ||||
Show All 36 Lines | switch ($this->view) { | ||||
$query->needProjectPHIDs(true); | $query->needProjectPHIDs(true); | ||||
break; | break; | ||||
} | } | ||||
return $query->execute(); | return $query->execute(); | ||||
} | } | ||||
/** | /** | ||||
* Parse the "Recently Means" filter into: | * Parse the "Recently Means" filter on /maniphest/report/* into: | ||||
* | |||||
* - A string representation, like "12 AM 7 days ago" (default); | * - A string representation, like "12 AM 7 days ago" (default); | ||||
* - a locale-aware epoch representation; and | * - a locale-aware epoch representation; and | ||||
* - a possible error. | * - a possible error. | ||||
* This is used for the "Recently Closed" column on /maniphest/report/*. | |||||
* | |||||
* @return array<string,integer,string|null> "Recently Means" user input; | |||||
* Resulting epoch timeframe used to get "Recently Closed" numbers | |||||
* (when user input is invalid, it defaults to a week ago); "Invalid" | |||||
* if first parameter could not be parsed as an epoch, else null. | |||||
*/ | */ | ||||
private function getWindow() { | private function getWindow() { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
$window_str = $this->getRequest()->getStr('window', '12 AM 7 days ago'); | $window_str = $this->getRequest()->getStr('window', '12 AM 7 days ago'); | ||||
$error = null; | $error = null; | ||||
Show All 18 Lines | private function getWindow() { | ||||
if ($window_epoch > time()) { | if ($window_epoch > time()) { | ||||
$window_epoch = time() - ($window_epoch - time()); | $window_epoch = time() - ($window_epoch - time()); | ||||
} | } | ||||
return array($window_str, $window_epoch, $error); | return array($window_str, $window_epoch, $error); | ||||
} | } | ||||
/** | |||||
* Render date of oldest open task per user or per project with a link. | |||||
* Used on /maniphest/report/user/ and /maniphest/report/project/ URIs. | |||||
* | |||||
* @return array<PhutilSafeHTML,int> HTML link markup and the timespan | |||||
* (as epoch) since task creation | |||||
*/ | |||||
private function renderOldest(array $tasks) { | private function renderOldest(array $tasks) { | ||||
assert_instances_of($tasks, 'ManiphestTask'); | assert_instances_of($tasks, 'ManiphestTask'); | ||||
$oldest = null; | $oldest = null; | ||||
foreach ($tasks as $id => $task) { | foreach ($tasks as $id => $task) { | ||||
if (($oldest === null) || | if (($oldest === null) || | ||||
($task->getDateCreated() < $tasks[$oldest]->getDateCreated())) { | ($task->getDateCreated() < $tasks[$oldest]->getDateCreated())) { | ||||
$oldest = $id; | $oldest = $id; | ||||
} | } | ||||
Show All 27 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
I don't like hardcoding it also in PHPDoc lol
Maybe better to say that "greater means big priority" (or vice-versa - I don't know lol)