mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Add very very basic reporting to Maniphest
Summary: Rough cut for Quora, we want this too eventually but it's super basic right now so I'm not linking it anywhere. Once we get a couple more iterations I'll put it in the UI. Test Plan: Looked at stats for test data. Reviewers: btrahan Reviewed By: btrahan CC: anjali, aran, epriestley Differential Revision: https://secure.phabricator.com/D1594
This commit is contained in:
parent
7a5ec015d9
commit
a1c20638fa
5 changed files with 174 additions and 1 deletions
|
@ -398,6 +398,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestDAO' => 'applications/maniphest/storage/base',
|
||||
'ManiphestDefaultTaskExtensions' => 'applications/maniphest/extensions/task',
|
||||
'ManiphestReplyHandler' => 'applications/maniphest/replyhandler',
|
||||
'ManiphestReportController' => 'applications/maniphest/controller/report',
|
||||
'ManiphestTask' => 'applications/maniphest/storage/task',
|
||||
'ManiphestTaskAuxiliaryStorage' => 'applications/maniphest/storage/auxiliary',
|
||||
'ManiphestTaskDescriptionChangeController' => 'applications/maniphest/controller/descriptionchange',
|
||||
|
@ -1139,6 +1140,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestDAO' => 'PhabricatorLiskDAO',
|
||||
'ManiphestDefaultTaskExtensions' => 'ManiphestTaskExtensions',
|
||||
'ManiphestReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||
'ManiphestReportController' => 'ManiphestController',
|
||||
'ManiphestTask' => 'ManiphestDAO',
|
||||
'ManiphestTaskAuxiliaryStorage' => 'ManiphestDAO',
|
||||
'ManiphestTaskDescriptionChangeController' => 'ManiphestController',
|
||||
|
|
|
@ -162,6 +162,7 @@ class AphrontDefaultApplicationConfiguration
|
|||
'/maniphest/' => array(
|
||||
'$' => 'ManiphestTaskListController',
|
||||
'view/(?P<view>\w+)/$' => 'ManiphestTaskListController',
|
||||
'report/(?:(?P<view>\w+)/)?$' => 'ManiphestReportController',
|
||||
'task/' => array(
|
||||
'create/$' => 'ManiphestTaskEditController',
|
||||
'edit/(?P<id>\d+)/$' => 'ManiphestTaskEditController',
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group maniphest
|
||||
*/
|
||||
final class ManiphestReportController extends ManiphestController {
|
||||
|
||||
private $view;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->view = idx($data, 'view');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$nav->setBaseURI(new PhutilURI('/maniphest/report/'));
|
||||
$nav->addFilter('user', 'User');
|
||||
$nav->addFilter('project', 'Project');
|
||||
|
||||
$this->view = $nav->selectFilter($this->view, 'user');
|
||||
|
||||
$tasks = id(new ManiphestTaskQuery())
|
||||
->withStatus(ManiphestTaskQuery::STATUS_OPEN)
|
||||
->execute();
|
||||
|
||||
$date = phabricator_date(time(), $user);
|
||||
|
||||
switch ($this->view) {
|
||||
case 'user':
|
||||
$result = mgroup($tasks, 'getOwnerPHID');
|
||||
$leftover = idx($result, '', array());
|
||||
unset($result['']);
|
||||
$leftover_name = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/maniphest/?users=PHID-!!!!-UP-FOR-GRABS',
|
||||
),
|
||||
'Up For Grabs');
|
||||
$col_header = 'User';
|
||||
$header = 'Open Tasks by User and Priority ('.$date.')';
|
||||
$link = '/maniphest/?users=';
|
||||
break;
|
||||
case 'project':
|
||||
$result = array();
|
||||
foreach ($tasks as $task) {
|
||||
$phids = $task->getProjectPHIDs();
|
||||
if ($phids) {
|
||||
foreach ($phids as $project_phid) {
|
||||
$result[$project_phid][] = $task;
|
||||
}
|
||||
} else {
|
||||
$leftover[] = $task;
|
||||
}
|
||||
}
|
||||
$leftover_name = 'Uncategorized';
|
||||
$col_header = 'Project';
|
||||
$header = 'Open Tasks by Project and Priority ('.$date.')';
|
||||
$link = '/maniphest/view/all/?projects=';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$phids = array_keys($result);
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||
$handles = msort($handles, 'getName');
|
||||
|
||||
$rows = array();
|
||||
$pri_total = array();
|
||||
foreach (array_merge($handles, array(null)) as $handle) {
|
||||
if ($handle) {
|
||||
$tasks = idx($result, $handle->getPHID(), array());
|
||||
$name = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $link.$handle->getPHID(),
|
||||
),
|
||||
phutil_escape_html($handle->getName()));
|
||||
} else {
|
||||
$tasks = $leftover;
|
||||
$name = $leftover_name;
|
||||
}
|
||||
|
||||
$tasks = mgroup($tasks, 'getPriority');
|
||||
|
||||
$row = array();
|
||||
$row[] = $name;
|
||||
$total = 0;
|
||||
foreach (ManiphestTaskPriority::getTaskPriorityMap() as $pri => $label) {
|
||||
$n = count(idx($tasks, $pri, array()));
|
||||
if ($n == 0) {
|
||||
$row[] = '-';
|
||||
} else {
|
||||
$row[] = number_format($n);
|
||||
}
|
||||
$total += $n;
|
||||
}
|
||||
$row[] = number_format($total);
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$cname = array($col_header);
|
||||
$cclass = array('pri right wide');
|
||||
foreach (ManiphestTaskPriority::getTaskPriorityMap() as $pri => $label) {
|
||||
$cname[] = $label;
|
||||
$cclass[] = 'n';
|
||||
}
|
||||
$cname[] = 'Total';
|
||||
$cclass[] = 'n';
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders($cname);
|
||||
$table->setColumnClasses($cclass);
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader($header);
|
||||
$panel->appendChild($table);
|
||||
|
||||
$nav->appendChild($panel);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$nav,
|
||||
array(
|
||||
'title' => 'Maniphest Reports',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
23
src/applications/maniphest/controller/report/__init__.php
Normal file
23
src/applications/maniphest/controller/report/__init__.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/maniphest/constants/priority');
|
||||
phutil_require_module('phabricator', 'applications/maniphest/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/maniphest/query');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
phutil_require_module('phabricator', 'view/layout/sidenavfilter');
|
||||
phutil_require_module('phabricator', 'view/utils');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'parser/uri');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('ManiphestReportController.php');
|
|
@ -9,7 +9,6 @@
|
|||
phutil_require_module('phabricator', 'aphront/response/ajax');
|
||||
phutil_require_module('phabricator', 'aphront/response/dialog');
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/project/constants/status');
|
||||
phutil_require_module('phabricator', 'applications/project/constants/transaction');
|
||||
phutil_require_module('phabricator', 'applications/project/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/project/editor/project');
|
||||
|
|
Loading…
Reference in a new issue