@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorFactIntDatapoint extends PhabricatorFactDAO {
4
5 protected $keyID;
6 protected $objectID;
7 protected $dimensionID;
8 protected $value;
9 protected $epoch;
10
11 private $key;
12 private $objectPHID;
13 private $dimensionPHID;
14
15 protected function getConfiguration() {
16 return array(
17 self::CONFIG_TIMESTAMPS => false,
18 self::CONFIG_COLUMN_SCHEMA => array(
19 'id' => 'auto64',
20 'dimensionID' => 'id?',
21 'value' => 'sint64',
22 ),
23 self::CONFIG_KEY_SCHEMA => array(
24 'key_dimension' => array(
25 'columns' => array('keyID', 'dimensionID'),
26 ),
27 'key_object' => array(
28 'columns' => array('objectID'),
29 ),
30 ),
31 ) + parent::getConfiguration();
32 }
33
34 public function setKey($key) {
35 $this->key = $key;
36 return $this;
37 }
38
39 public function getKey() {
40 return $this->key;
41 }
42
43 public function setObjectPHID($object_phid) {
44 $this->objectPHID = $object_phid;
45 return $this;
46 }
47
48 public function getObjectPHID() {
49 return $this->objectPHID;
50 }
51
52 /**
53 * @param string $dimension_phid
54 */
55 public function setDimensionPHID($dimension_phid) {
56 $this->dimensionPHID = $dimension_phid;
57 return $this;
58 }
59
60 public function getDimensionPHID() {
61 return $this->dimensionPHID;
62 }
63
64 public function newDatapointVector() {
65 return $this->formatVector(
66 array(
67 $this->key,
68 $this->objectPHID,
69 $this->dimensionPHID,
70 $this->value,
71 $this->epoch,
72 ));
73 }
74
75 public function newRawVector(array $spec) {
76 return $this->formatVector(
77 array(
78 $spec['key'],
79 $spec['objectPHID'],
80 $spec['dimensionPHID'],
81 $spec['value'],
82 $spec['epoch'],
83 ));
84 }
85
86 private function formatVector(array $vector) {
87 return implode(':', $vector);
88 }
89
90}