Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/harbormaster/query/HarbormasterBuildTargetSearchEngine.php
12256 views
1
<?php
2
3
final class HarbormasterBuildTargetSearchEngine
4
extends PhabricatorApplicationSearchEngine {
5
6
public function getResultTypeDescription() {
7
return pht('Harbormaster Build Targets');
8
}
9
10
public function getApplicationClassName() {
11
return 'PhabricatorHarbormasterApplication';
12
}
13
14
public function newQuery() {
15
return new HarbormasterBuildTargetQuery();
16
}
17
18
protected function buildCustomSearchFields() {
19
return array(
20
id(new PhabricatorSearchDatasourceField())
21
->setLabel(pht('Builds'))
22
->setKey('buildPHIDs')
23
->setAliases(array('build', 'builds', 'buildPHID'))
24
->setDescription(
25
pht('Search for targets of a given build.'))
26
->setDatasource(new HarbormasterBuildPlanDatasource()),
27
id(new PhabricatorSearchDateField())
28
->setLabel(pht('Created After'))
29
->setKey('createdStart')
30
->setDescription(
31
pht('Search for targets created on or after a particular date.')),
32
id(new PhabricatorSearchDateField())
33
->setLabel(pht('Created Before'))
34
->setKey('createdEnd')
35
->setDescription(
36
pht('Search for targets created on or before a particular date.')),
37
id(new PhabricatorSearchDateField())
38
->setLabel(pht('Started After'))
39
->setKey('startedStart')
40
->setDescription(
41
pht('Search for targets started on or after a particular date.')),
42
id(new PhabricatorSearchDateField())
43
->setLabel(pht('Started Before'))
44
->setKey('startedEnd')
45
->setDescription(
46
pht('Search for targets started on or before a particular date.')),
47
id(new PhabricatorSearchDateField())
48
->setLabel(pht('Completed After'))
49
->setKey('completedStart')
50
->setDescription(
51
pht('Search for targets completed on or after a particular date.')),
52
id(new PhabricatorSearchDateField())
53
->setLabel(pht('Completed Before'))
54
->setKey('completedEnd')
55
->setDescription(
56
pht('Search for targets completed on or before a particular date.')),
57
id(new PhabricatorSearchStringListField())
58
->setLabel(pht('Statuses'))
59
->setKey('statuses')
60
->setAliases(array('status'))
61
->setDescription(
62
pht('Search for targets with given statuses.')),
63
);
64
}
65
66
protected function buildQueryFromParameters(array $map) {
67
$query = $this->newQuery();
68
69
if ($map['buildPHIDs']) {
70
$query->withBuildPHIDs($map['buildPHIDs']);
71
}
72
73
if ($map['createdStart'] !== null || $map['createdEnd'] !== null) {
74
$query->withDateCreatedBetween(
75
$map['createdStart'],
76
$map['createdEnd']);
77
}
78
79
if ($map['startedStart'] !== null || $map['startedEnd'] !== null) {
80
$query->withDateStartedBetween(
81
$map['startedStart'],
82
$map['startedEnd']);
83
}
84
85
if ($map['completedStart'] !== null || $map['completedEnd'] !== null) {
86
$query->withDateCompletedBetween(
87
$map['completedStart'],
88
$map['completedEnd']);
89
}
90
91
if ($map['statuses']) {
92
$query->withTargetStatuses($map['statuses']);
93
}
94
95
return $query;
96
}
97
98
protected function getURI($path) {
99
return '/harbormaster/target/'.$path;
100
}
101
102
protected function getBuiltinQueryNames() {
103
return array(
104
'all' => pht('All Targets'),
105
);
106
}
107
108
public function buildSavedQueryFromBuiltin($query_key) {
109
$query = $this->newSavedQuery();
110
$query->setQueryKey($query_key);
111
112
switch ($query_key) {
113
case 'all':
114
return $query;
115
}
116
117
return parent::buildSavedQueryFromBuiltin($query_key);
118
}
119
120
protected function renderResultList(
121
array $builds,
122
PhabricatorSavedQuery $query,
123
array $handles) {
124
assert_instances_of($builds, 'HarbormasterBuildTarget');
125
126
// Currently, this only supports the "harbormaster.target.search"
127
// API method.
128
throw new PhutilMethodNotImplementedException();
129
}
130
131
}
132
133