1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Give "Burndown" charts a more straightforward definition and move all the event stuff into "Activity" charts

Summary:
Depends on D20818. Ref T13279. The behavior of the "burndown" chart has wandered fairly far afield; make it look more like a burndown.

Move the other thing into an "Activity" chart.

Test Plan: {F6865207}

Maniphest Tasks: T13279

Differential Revision: https://secure.phabricator.com/D20819
This commit is contained in:
epriestley 2019-09-17 12:54:29 -07:00
parent c06dd4818b
commit 16de9151c7
4 changed files with 203 additions and 113 deletions

View file

@ -4224,6 +4224,7 @@ phutil_register_library_map(array(
'PhabricatorProfileMenuItemView' => 'applications/search/engine/PhabricatorProfileMenuItemView.php',
'PhabricatorProfileMenuItemViewList' => 'applications/search/engine/PhabricatorProfileMenuItemViewList.php',
'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php',
'PhabricatorProjectActivityChartEngine' => 'applications/project/chart/PhabricatorProjectActivityChartEngine.php',
'PhabricatorProjectAddHeraldAction' => 'applications/project/herald/PhabricatorProjectAddHeraldAction.php',
'PhabricatorProjectApplication' => 'applications/project/application/PhabricatorProjectApplication.php',
'PhabricatorProjectArchiveController' => 'applications/project/controller/PhabricatorProjectArchiveController.php',
@ -10733,6 +10734,7 @@ phutil_register_library_map(array(
'PhabricatorSpacesInterface',
'PhabricatorEditEngineSubtypeInterface',
),
'PhabricatorProjectActivityChartEngine' => 'PhabricatorChartEngine',
'PhabricatorProjectAddHeraldAction' => 'PhabricatorProjectHeraldAction',
'PhabricatorProjectApplication' => 'PhabricatorApplication',
'PhabricatorProjectArchiveController' => 'PhabricatorProjectController',

View file

@ -0,0 +1,135 @@
<?php
final class PhabricatorProjectActivityChartEngine
extends PhabricatorChartEngine {
const CHARTENGINEKEY = 'project.activity';
public function setProjects(array $projects) {
assert_instances_of($projects, 'PhabricatorProject');
$project_phids = mpull($projects, 'getPHID');
return $this->setEngineParameter('projectPHIDs', $project_phids);
}
protected function newChart(PhabricatorFactChart $chart, array $map) {
$viewer = $this->getViewer();
$map = $map + array(
'projectPHIDs' => array(),
);
if ($map['projectPHIDs']) {
$projects = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withPHIDs($map['projectPHIDs'])
->execute();
$project_phids = mpull($projects, 'getPHID');
} else {
$project_phids = array();
}
$project_phid = head($project_phids);
$functions = array();
$stacks = array();
$function = $this->newFunction(
array(
'accumulate',
array(
'compose',
array('fact', 'tasks.open-count.assign.project', $project_phid),
array('min', 0),
),
));
$function->getFunctionLabel()
->setKey('moved-in')
->setName(pht('Tasks Moved Into Project'))
->setColor('rgba(128, 128, 200, 1)')
->setFillColor('rgba(128, 128, 200, 0.15)');
$functions[] = $function;
$function = $this->newFunction(
array(
'accumulate',
array(
'compose',
array('fact', 'tasks.open-count.status.project', $project_phid),
array('min', 0),
),
));
$function->getFunctionLabel()
->setKey('reopened')
->setName(pht('Tasks Reopened'))
->setColor('rgba(128, 128, 200, 1)')
->setFillColor('rgba(128, 128, 200, 0.15)');
$functions[] = $function;
$function = $this->newFunction(
array(
'accumulate',
array('fact', 'tasks.open-count.create.project', $project_phid),
));
$function->getFunctionLabel()
->setKey('created')
->setName(pht('Tasks Created'))
->setColor('rgba(0, 0, 200, 1)')
->setFillColor('rgba(0, 0, 200, 0.15)');
$functions[] = $function;
$function = $this->newFunction(
array(
'accumulate',
array(
'compose',
array('fact', 'tasks.open-count.status.project', $project_phid),
array('max', 0),
),
));
$function->getFunctionLabel()
->setKey('closed')
->setName(pht('Tasks Closed'))
->setColor('rgba(0, 200, 0, 1)')
->setFillColor('rgba(0, 200, 0, 0.15)');
$functions[] = $function;
$function = $this->newFunction(
array(
'accumulate',
array(
'compose',
array('fact', 'tasks.open-count.assign.project', $project_phid),
array('max', 0),
),
));
$function->getFunctionLabel()
->setKey('moved-out')
->setName(pht('Tasks Moved Out of Project'))
->setColor('rgba(128, 200, 128, 1)')
->setFillColor('rgba(128, 200, 128, 0.15)');
$functions[] = $function;
$stacks[] = array('created', 'reopened', 'moved-in');
$stacks[] = array('closed', 'moved-out');
$datasets = array();
$dataset = id(new PhabricatorChartStackedAreaDataset())
->setFunctions($functions)
->setStacks($stacks);
$datasets[] = $dataset;
$chart->attachDatasets($datasets);
}
}

View file

@ -29,140 +29,79 @@ final class PhabricatorProjectBurndownChartEngine
}
$functions = array();
$stacks = array();
if ($project_phids) {
foreach ($project_phids as $project_phid) {
$function = $this->newFunction(
$open_function = $this->newFunction(
array(
'accumulate',
array(
'accumulate',
array(
'compose',
array('fact', 'tasks.open-count.assign.project', $project_phid),
array('min', 0),
),
));
'sum',
$this->newFactSum(
'tasks.open-count.create.project', $project_phids),
$this->newFactSum(
'tasks.open-count.status.project', $project_phids),
$this->newFactSum(
'tasks.open-count.assign.project', $project_phids),
),
));
$function->getFunctionLabel()
->setKey('moved-in')
->setName(pht('Tasks Moved Into Project'))
->setColor('rgba(128, 128, 200, 1)')
->setFillColor('rgba(128, 128, 200, 0.15)');
$functions[] = $function;
$function = $this->newFunction(
array(
'accumulate',
array(
'compose',
array('fact', 'tasks.open-count.status.project', $project_phid),
array('min', 0),
),
));
$function->getFunctionLabel()
->setKey('reopened')
->setName(pht('Tasks Reopened'))
->setColor('rgba(128, 128, 200, 1)')
->setFillColor('rgba(128, 128, 200, 0.15)');
$functions[] = $function;
$function = $this->newFunction(
array(
'accumulate',
array('fact', 'tasks.open-count.create.project', $project_phid),
));
$function->getFunctionLabel()
->setKey('created')
->setName(pht('Tasks Created'))
->setColor('rgba(0, 0, 200, 1)')
->setFillColor('rgba(0, 0, 200, 0.15)');
$functions[] = $function;
$function = $this->newFunction(
array(
'accumulate',
array(
'compose',
array('fact', 'tasks.open-count.status.project', $project_phid),
array('max', 0),
),
));
$function->getFunctionLabel()
->setKey('closed')
->setName(pht('Tasks Closed'))
->setColor('rgba(0, 200, 0, 1)')
->setFillColor('rgba(0, 200, 0, 0.15)');
$functions[] = $function;
$function = $this->newFunction(
array(
'accumulate',
array(
'compose',
array('fact', 'tasks.open-count.assign.project', $project_phid),
array('max', 0),
),
));
$function->getFunctionLabel()
->setKey('moved-out')
->setName(pht('Tasks Moved Out of Project'))
->setColor('rgba(128, 200, 128, 1)')
->setFillColor('rgba(128, 200, 128, 0.15)');
$functions[] = $function;
$stacks[] = array('created', 'reopened', 'moved-in');
$stacks[] = array('closed', 'moved-out');
}
$closed_function = $this->newFunction(
array(
'accumulate',
$this->newFactSum('tasks.open-count.status.project', $project_phids),
));
} else {
$function = $this->newFunction(
$open_function = $this->newFunction(
array(
'accumulate',
array('fact', 'tasks.open-count.create'),
));
$function->getFunctionLabel()
->setKey('open')
->setName(pht('Open Tasks'))
->setColor('rgba(0, 0, 200, 1)')
->setFillColor('rgba(0, 0, 200, 0.15)');
$functions[] = $function;
$function = $this->newFunction(
$closed_function = $this->newFunction(
array(
'accumulate',
array('fact', 'tasks.open-count.status'),
));
$function->getFunctionLabel()
->setKey('closed')
->setName(pht('Closed Tasks'))
->setColor('rgba(0, 200, 0, 1)')
->setFillColor('rgba(0, 200, 0, 0.15)');
$functions[] = $function;
}
$open_function->getFunctionLabel()
->setKey('open')
->setName(pht('Open Tasks'))
->setColor('rgba(0, 0, 200, 1)')
->setFillColor('rgba(0, 0, 200, 0.15)');
$closed_function->getFunctionLabel()
->setKey('closed')
->setName(pht('Closed Tasks'))
->setColor('rgba(0, 200, 0, 1)')
->setFillColor('rgba(0, 200, 0, 0.15)');
$datasets = array();
$dataset = id(new PhabricatorChartStackedAreaDataset())
->setFunctions($functions);
if ($stacks) {
$dataset->setStacks($stacks);
}
->setFunctions(
array(
$open_function,
$closed_function,
))
->setStacks(
array(
array('open'),
array('closed'),
));
$datasets[] = $dataset;
$chart->attachDatasets($datasets);
}
private function newFactSum($fact_key, array $phids) {
$result = array();
$result[] = 'sum';
foreach ($phids as $phid) {
$result[] = array('fact', $fact_key, $phid);
}
return $result;
}
}

View file

@ -44,10 +44,24 @@ final class PhabricatorProjectReportsController
->setParentPanelPHIDs(array())
->renderPanel();
$activity_panel = id(new PhabricatorProjectActivityChartEngine())
->setViewer($viewer)
->setProjects(array($project))
->buildChartPanel();
$activity_panel->setName(pht('%s: Activity', $project->getName()));
$activity_view = id(new PhabricatorDashboardPanelRenderingEngine())
->setViewer($viewer)
->setPanel($activity_panel)
->setParentPanelPHIDs(array())
->renderPanel();
$view = id(new PHUITwoColumnView())
->setFooter(
array(
$chart_view,
$activity_view,
));
return $this->newPage()