Differential D20819 Diff 49636 src/applications/project/chart/PhabricatorProjectBurndownChartEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/chart/PhabricatorProjectBurndownChartEngine.php
Show All 23 Lines | if ($map['projectPHIDs']) { | ||||
->withPHIDs($map['projectPHIDs']) | ->withPHIDs($map['projectPHIDs']) | ||||
->execute(); | ->execute(); | ||||
$project_phids = mpull($projects, 'getPHID'); | $project_phids = mpull($projects, 'getPHID'); | ||||
} else { | } else { | ||||
$project_phids = array(); | $project_phids = array(); | ||||
} | } | ||||
$functions = array(); | $functions = array(); | ||||
$stacks = array(); | |||||
if ($project_phids) { | if ($project_phids) { | ||||
foreach ($project_phids as $project_phid) { | $open_function = $this->newFunction( | ||||
$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( | array( | ||||
'accumulate', | 'accumulate', | ||||
array( | array( | ||||
'compose', | 'sum', | ||||
array('fact', 'tasks.open-count.status.project', $project_phid), | $this->newFactSum( | ||||
array('min', 0), | '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() | $closed_function = $this->newFunction( | ||||
->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( | array( | ||||
'accumulate', | 'accumulate', | ||||
array('fact', 'tasks.open-count.create.project', $project_phid), | $this->newFactSum('tasks.open-count.status.project', $project_phids), | ||||
)); | )); | ||||
} else { | |||||
$function->getFunctionLabel() | $open_function = $this->newFunction( | ||||
->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( | array( | ||||
'accumulate', | 'accumulate', | ||||
array( | array('fact', 'tasks.open-count.create'), | ||||
'compose', | |||||
array('fact', 'tasks.open-count.status.project', $project_phid), | |||||
array('max', 0), | |||||
), | |||||
)); | )); | ||||
$function->getFunctionLabel() | $closed_function = $this->newFunction( | ||||
->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( | array( | ||||
'accumulate', | 'accumulate', | ||||
array( | array('fact', 'tasks.open-count.status'), | ||||
'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'); | |||||
} | } | ||||
} else { | |||||
$function = $this->newFunction( | |||||
array( | |||||
'accumulate', | |||||
array('fact', 'tasks.open-count.create'), | |||||
)); | |||||
$function->getFunctionLabel() | $open_function->getFunctionLabel() | ||||
->setKey('open') | ->setKey('open') | ||||
->setName(pht('Open Tasks')) | ->setName(pht('Open Tasks')) | ||||
->setColor('rgba(0, 0, 200, 1)') | ->setColor('rgba(0, 0, 200, 1)') | ||||
->setFillColor('rgba(0, 0, 200, 0.15)'); | ->setFillColor('rgba(0, 0, 200, 0.15)'); | ||||
$functions[] = $function; | $closed_function->getFunctionLabel() | ||||
$function = $this->newFunction( | |||||
array( | |||||
'accumulate', | |||||
array('fact', 'tasks.open-count.status'), | |||||
)); | |||||
$function->getFunctionLabel() | |||||
->setKey('closed') | ->setKey('closed') | ||||
->setName(pht('Closed Tasks')) | ->setName(pht('Closed Tasks')) | ||||
->setColor('rgba(0, 200, 0, 1)') | ->setColor('rgba(0, 200, 0, 1)') | ||||
->setFillColor('rgba(0, 200, 0, 0.15)'); | ->setFillColor('rgba(0, 200, 0, 0.15)'); | ||||
$functions[] = $function; | |||||
} | |||||
$datasets = array(); | $datasets = array(); | ||||
$dataset = id(new PhabricatorChartStackedAreaDataset()) | $dataset = id(new PhabricatorChartStackedAreaDataset()) | ||||
->setFunctions($functions); | ->setFunctions( | ||||
array( | |||||
if ($stacks) { | $open_function, | ||||
$dataset->setStacks($stacks); | $closed_function, | ||||
} | )) | ||||
->setStacks( | |||||
array( | |||||
array('open'), | |||||
array('closed'), | |||||
)); | |||||
$datasets[] = $dataset; | $datasets[] = $dataset; | ||||
$chart->attachDatasets($datasets); | $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; | |||||
} | |||||
} | } |