Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fact/fact/PhabricatorFact.php
Show All 32 Lines | abstract class PhabricatorFact extends Phobject { | ||||
final public function newDatapoint() { | final public function newDatapoint() { | ||||
return $this->newTemplateDatapoint() | return $this->newTemplateDatapoint() | ||||
->setKey($this->getKey()); | ->setKey($this->getKey()); | ||||
} | } | ||||
abstract protected function newTemplateDatapoint(); | abstract protected function newTemplateDatapoint(); | ||||
final public function getFunctionArguments() { | final public function getFunctionArguments() { | ||||
return array(); | $key = $this->getKey(); | ||||
$argv = array(); | |||||
if (preg_match('/\.project\z/', $key)) { | |||||
epriestley: This is a little crude for now. The `x.y.z.project` and `x.y.z.owner` facts are facts about… | |||||
$argv[] = id(new PhabricatorChartFunctionArgument()) | |||||
->setName('phid') | |||||
->setType('phid'); | |||||
} | |||||
if (preg_match('/\.owner\z/', $key)) { | |||||
$argv[] = id(new PhabricatorChartFunctionArgument()) | |||||
->setName('phid') | |||||
->setType('phid'); | |||||
} | } | ||||
return $argv; | |||||
} | |||||
final public function buildWhereClauseParts( | |||||
AphrontDatabaseConnection $conn, | |||||
PhabricatorChartFunctionArgumentParser $arguments) { | |||||
$where = array(); | |||||
$has_phid = $this->getFunctionArguments(); | |||||
if ($has_phid) { | |||||
$phid = $arguments->getArgumentValue('phid'); | |||||
$dimension_id = id(new PhabricatorFactObjectDimension()) | |||||
->newDimensionID($phid); | |||||
$where[] = qsprintf( | |||||
$conn, | |||||
'dimensionID = %d', | |||||
$dimension_id); | |||||
} | |||||
return $where; | |||||
} | |||||
} | } |
This is a little crude for now. The x.y.z.project and x.y.z.owner facts are facts about tasks tagged with projects and assigned to users, and have an object dimension value for which project/owner was tagged/assigned.
For example, if a task is created with alice as an owner, we'll get a row like:
..meaning "one task, PHID-TASK-abcd, was created on April 30th with alice as the owner".
So this code is saying "when you chart an owner/project fact, you should specify the PHID of the owner/project you care about", and the rest of the changes here are adding the right WHERE clause for that.