Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/chart/PhabricatorChartFunction.php
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | if (!$this->argumentParser) { | ||||
$parser = id(new PhabricatorChartFunctionArgumentParser()) | $parser = id(new PhabricatorChartFunctionArgumentParser()) | ||||
->setFunction($this); | ->setFunction($this); | ||||
$this->argumentParser = $parser; | $this->argumentParser = $parser; | ||||
} | } | ||||
return $this->argumentParser; | return $this->argumentParser; | ||||
} | } | ||||
public function selectAllFunctions() { | |||||
$result = array(); | |||||
$result[] = $this; | |||||
$parser = $this->getArgumentParser(); | |||||
foreach ($parser->getAllArguments() as $argument) { | |||||
if ($argument->getType() !== 'function') { | |||||
continue; | |||||
} | |||||
$name = $argument->getName(); | |||||
$value = $this->getArgument($name); | |||||
foreach ($value->selectAllFunctions() as $subfunction) { | |||||
$result[] = $subfunction; | |||||
} | |||||
} | |||||
return $result; | |||||
} | |||||
public function loadData() { | public function loadData() { | ||||
return; | return; | ||||
} | } | ||||
protected function setSourceFunction(PhabricatorChartFunction $source) { | protected function setSourceFunction(PhabricatorChartFunction $source) { | ||||
$this->sourceFunction = $source; | $this->sourceFunction = $source; | ||||
return $this; | return $this; | ||||
} | } | ||||
Show All 28 Lines | protected function evaluateFunction($x) { | ||||
throw new PhutilMethodNotImplementedException(); | throw new PhutilMethodNotImplementedException(); | ||||
} | } | ||||
public function hasDomain() { | public function hasDomain() { | ||||
if ($this->canEvaluateFunction()) { | if ($this->canEvaluateFunction()) { | ||||
return false; | return false; | ||||
} | } | ||||
if ($this->isImpulseFunction()) { | |||||
return true; | |||||
} | |||||
$source_function = $this->getSourceFunction(); | |||||
if ($source_function) { | |||||
return $source_function->hasDomain(); | |||||
} | |||||
throw new PhutilMethodNotImplementedException(); | |||||
} | |||||
public function isImpulseFunction() { | |||||
return false; | |||||
} | |||||
public function getDomain() { | |||||
// TODO: We can examine the data to fit a better domain. | |||||
Lint: TODO Comment: This comment has a TODO. | |||||
if ($this->isImpulseFunction()) { | |||||
$now = PhabricatorTime::getNow(); | |||||
return array($now - phutil_units('90 days in seconds'), $now); | |||||
} | |||||
$source_function = $this->getSourceFunction(); | |||||
if ($source_function) { | |||||
return $source_function->getDomain(); | |||||
} | |||||
throw new PhutilMethodNotImplementedException(); | throw new PhutilMethodNotImplementedException(); | ||||
} | } | ||||
public function getDatapoints(PhabricatorChartDataQuery $query) { | public function getDatapoints(PhabricatorChartDataQuery $query) { | ||||
if ($this->canEvaluateFunction()) { | if ($this->canEvaluateFunction()) { | ||||
$points = $this->newSourceDatapoints($query); | $points = $this->newSourceDatapoints($query); | ||||
foreach ($points as $key => $point) { | foreach ($points as $key => $point) { | ||||
$y = $point['y']; | $y = $point['y']; | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |
This comment has a TODO.