Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/fact/chart/PhabricatorChartDataQuery.php
12256 views
1
<?php
2
3
final class PhabricatorChartDataQuery
4
extends Phobject {
5
6
private $limit;
7
private $minimumValue;
8
private $maximumValue;
9
10
public function setMinimumValue($minimum_value) {
11
$this->minimumValue = $minimum_value;
12
return $this;
13
}
14
15
public function getMinimumValue() {
16
return $this->minimumValue;
17
}
18
19
public function setMaximumValue($maximum_value) {
20
$this->maximumValue = $maximum_value;
21
return $this;
22
}
23
24
public function getMaximumValue() {
25
return $this->maximumValue;
26
}
27
28
public function setLimit($limit) {
29
$this->limit = $limit;
30
return $this;
31
}
32
33
public function getLimit() {
34
return $this->limit;
35
}
36
37
public function selectInputValues(array $xv) {
38
$result = array();
39
40
$x_min = $this->getMinimumValue();
41
$x_max = $this->getMaximumValue();
42
$limit = $this->getLimit();
43
44
if ($x_min !== null) {
45
foreach ($xv as $key => $x) {
46
if ($x < $x_min) {
47
unset($xv[$key]);
48
}
49
}
50
}
51
52
if ($x_max !== null) {
53
foreach ($xv as $key => $x) {
54
if ($x > $x_max) {
55
unset($xv[$key]);
56
}
57
}
58
}
59
60
// If we have too many data points, throw away some of the data.
61
62
// TODO: This doesn't work especially well right now.
63
64
if ($limit !== null) {
65
$count = count($xv);
66
if ($count > $limit) {
67
$ii = 0;
68
$every = ceil($count / $limit);
69
foreach ($xv as $key => $x) {
70
$ii++;
71
if (($ii % $every) && ($ii != $count)) {
72
unset($xv[$key]);
73
}
74
}
75
}
76
}
77
78
return array_values($xv);
79
}
80
81
}
82
83