Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/conduit/query/PhabricatorConduitLogQuery.php
12262 views
1
<?php
2
3
final class PhabricatorConduitLogQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $ids;
7
private $callerPHIDs;
8
private $methods;
9
private $methodStatuses;
10
private $epochMin;
11
private $epochMax;
12
13
public function withIDs(array $ids) {
14
$this->ids = $ids;
15
return $this;
16
}
17
18
public function withCallerPHIDs(array $phids) {
19
$this->callerPHIDs = $phids;
20
return $this;
21
}
22
23
public function withMethods(array $methods) {
24
$this->methods = $methods;
25
return $this;
26
}
27
28
public function withMethodStatuses(array $statuses) {
29
$this->methodStatuses = $statuses;
30
return $this;
31
}
32
33
public function withEpochBetween($epoch_min, $epoch_max) {
34
$this->epochMin = $epoch_min;
35
$this->epochMax = $epoch_max;
36
return $this;
37
}
38
39
public function newResultObject() {
40
return new PhabricatorConduitMethodCallLog();
41
}
42
43
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
44
$where = parent::buildWhereClauseParts($conn);
45
46
if ($this->ids !== null) {
47
$where[] = qsprintf(
48
$conn,
49
'id IN (%Ld)',
50
$this->ids);
51
}
52
53
if ($this->callerPHIDs !== null) {
54
$where[] = qsprintf(
55
$conn,
56
'callerPHID IN (%Ls)',
57
$this->callerPHIDs);
58
}
59
60
if ($this->methods !== null) {
61
$where[] = qsprintf(
62
$conn,
63
'method IN (%Ls)',
64
$this->methods);
65
}
66
67
if ($this->methodStatuses !== null) {
68
$statuses = array_fuse($this->methodStatuses);
69
70
$methods = id(new PhabricatorConduitMethodQuery())
71
->setViewer($this->getViewer())
72
->execute();
73
74
$method_names = array();
75
foreach ($methods as $method) {
76
$status = $method->getMethodStatus();
77
if (isset($statuses[$status])) {
78
$method_names[] = $method->getAPIMethodName();
79
}
80
}
81
82
if (!$method_names) {
83
throw new PhabricatorEmptyQueryException();
84
}
85
86
$where[] = qsprintf(
87
$conn,
88
'method IN (%Ls)',
89
$method_names);
90
}
91
92
if ($this->epochMin !== null) {
93
$where[] = qsprintf(
94
$conn,
95
'dateCreated >= %d',
96
$this->epochMin);
97
}
98
99
if ($this->epochMax !== null) {
100
$where[] = qsprintf(
101
$conn,
102
'dateCreated <= %d',
103
$this->epochMax);
104
}
105
106
return $where;
107
}
108
109
public function getQueryApplicationClass() {
110
return 'PhabricatorConduitApplication';
111
}
112
113
}
114
115