Page MenuHomePhabricator
Paste P1147

Fork of P1146 t.php
ActivePublic

Authored by hach-que on May 18 2014, 2:39 AM.
Tags
None
Referenced Files
F156269: Fork_of_P1146_t.php
May 18 2014, 2:41 AM
F156268: Fork_of_P1146_t.php
May 18 2014, 2:39 AM
Subscribers
None
<?php
# magic
class B {
public function getRawDataModel() {
id(new FactRawDataModel())
->addColumn("branchPHID", FactRawDataModel::TYPE_PHID)
->addColumn("projectPHID", FactRawDataModel::TYPE_PHID)
->addColumn("path", FactRawDataModel::TYPE_STRING)
->addColumn("technicalDebtChange", FactRawDataModel::TYPE_NUMERIC)
->addUniqueKey(array("branchPHID", "projectPHID", "path"))
->addFilterOneOrNone("path")
->addFilterManyOrNone("projectPHID");
}
public function getChart(array $raw_facts) {
$chart = new FactChart();
$chart->setType("linechart");
$sum = array();
foreach ($raw_facts as $raw) {
if (!array_key_exists($sum, $raw->get("projectPHID"))) {
$chart->addLine($raw->get("projectPHID"));
$sum[$raw->get("projectPHID")] = 0;
}
$sum[$raw->get("projectPHID")] += $raw->get("technicalDebtChange");
$chart->addDataPoint(
// line
$raw->get("projectPHID"),
// x
$raw->getEpoch(),
// y
$sum[$raw->get("projectPHID")]);
}
return $chart;
}
}

Event Timeline

hach-que changed the title of this paste from untitled to Fork of P1146 t.php.
hach-que updated the paste's language from autodetect to autodetect.
hach-que edited the content of this paste. (Show Details)