Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F548466
PhabricatorProjectBurndownChartEngine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
PhabricatorProjectBurndownChartEngine.php
View Options
<?php
final
class
PhabricatorProjectBurndownChartEngine
extends
PhabricatorChartEngine
{
const
CHARTENGINEKEY
=
'project.burndown'
;
/**
* @param array<PhabricatorProject> $projects
*/
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
();
}
$functions
=
array
();
if
(
$project_phids
)
{
$open_function
=
$this
->
newFunction
(
array
(
'accumulate'
,
array
(
'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
),
),
));
$closed_function
=
$this
->
newFunction
(
array
(
'accumulate'
,
$this
->
newFactSum
(
'tasks.open-count.status.project'
,
$project_phids
),
));
}
else
{
$open_function
=
$this
->
newFunction
(
array
(
'accumulate'
,
array
(
'sum'
,
array
(
'fact'
,
'tasks.open-count.create'
),
array
(
'fact'
,
'tasks.open-count.status'
),
),
));
$closed_function
=
$this
->
newFunction
(
array
(
'accumulate'
,
array
(
'fact'
,
'tasks.open-count.status'
),
));
}
$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
(
array
(
$open_function
,
$closed_function
,
))
->
setStacks
(
array
(
array
(
'open'
),
array
(
'closed'
),
));
$datasets
[]
=
$dataset
;
$chart
->
attachDatasets
(
$datasets
);
}
/**
* @param string $fact_key The key of the new fact sum
* (e.g. "tasks.open-count.assign.project")
* @param array<string> Project PHIDs
*/
private
function
newFactSum
(
$fact_key
,
array
$phids
)
{
$result
=
array
();
$result
[]
=
'sum'
;
foreach
(
$phids
as
$phid
)
{
$result
[]
=
array
(
'fact'
,
$fact_key
,
$phid
);
}
return
$result
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 1:49 PM (1 d, 23 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
108383
Default Alt Text
PhabricatorProjectBurndownChartEngine.php (3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment