Skip to content

Commit 167e793

Browse files
author
epriestley
committed
Modernize "PhabricatorRepositoryPushLogSearchEngine"
Summary: Depends on D18917. Ref T13046. While I'm in here, update this to use more modern construction. Test Plan: Browed and queried for push logs. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13046 Differential Revision: https://secure.phabricator.com/D18918
1 parent 778dfff commit 167e793

File tree

1 file changed

+24
-47
lines changed

1 file changed

+24
-47
lines changed

src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php

+24-47
Original file line numberDiff line numberDiff line change
@@ -11,63 +11,40 @@ public function getApplicationClassName() {
1111
return 'PhabricatorDiffusionApplication';
1212
}
1313

14-
public function buildSavedQueryFromRequest(AphrontRequest $request) {
15-
$saved = new PhabricatorSavedQuery();
16-
17-
$saved->setParameter(
18-
'repositoryPHIDs',
19-
$this->readPHIDsFromRequest(
20-
$request,
21-
'repositories',
22-
array(
23-
PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
24-
)));
25-
26-
$saved->setParameter(
27-
'pusherPHIDs',
28-
$this->readUsersFromRequest(
29-
$request,
30-
'pushers'));
31-
32-
return $saved;
14+
public function newQuery() {
15+
return new PhabricatorRepositoryPushLogQuery();
3316
}
3417

35-
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
36-
$query = id(new PhabricatorRepositoryPushLogQuery());
18+
protected function buildQueryFromParameters(array $map) {
19+
$query = $this->newQuery();
3720

38-
$repository_phids = $saved->getParameter('repositoryPHIDs');
39-
if ($repository_phids) {
40-
$query->withRepositoryPHIDs($repository_phids);
21+
if ($map['repositoryPHIDs']) {
22+
$query->withRepositoryPHIDs($map['repositoryPHIDs']);
4123
}
4224

43-
$pusher_phids = $saved->getParameter('pusherPHIDs');
44-
if ($pusher_phids) {
45-
$query->withPusherPHIDs($pusher_phids);
25+
if ($map['pusherPHIDs']) {
26+
$query->withPusherPHIDs($map['pusherPHIDs']);
4627
}
4728

4829
return $query;
4930
}
5031

51-
public function buildSearchForm(
52-
AphrontFormView $form,
53-
PhabricatorSavedQuery $saved_query) {
54-
55-
$repository_phids = $saved_query->getParameter('repositoryPHIDs', array());
56-
$pusher_phids = $saved_query->getParameter('pusherPHIDs', array());
57-
58-
$form
59-
->appendControl(
60-
id(new AphrontFormTokenizerControl())
61-
->setDatasource(new DiffusionRepositoryDatasource())
62-
->setName('repositories')
63-
->setLabel(pht('Repositories'))
64-
->setValue($repository_phids))
65-
->appendControl(
66-
id(new AphrontFormTokenizerControl())
67-
->setDatasource(new PhabricatorPeopleDatasource())
68-
->setName('pushers')
69-
->setLabel(pht('Pushers'))
70-
->setValue($pusher_phids));
32+
protected function buildCustomSearchFields() {
33+
return array(
34+
id(new PhabricatorSearchDatasourceField())
35+
->setDatasource(new DiffusionRepositoryDatasource())
36+
->setKey('repositoryPHIDs')
37+
->setAliases(array('repository', 'repositories', 'repositoryPHID'))
38+
->setLabel(pht('Repositories'))
39+
->setDescription(
40+
pht('Search for pull logs for specific repositories.')),
41+
id(new PhabricatorUsersSearchField())
42+
->setKey('pusherPHIDs')
43+
->setAliases(array('pusher', 'pushers', 'pusherPHID'))
44+
->setLabel(pht('Pushers'))
45+
->setDescription(
46+
pht('Search for pull logs by specific users.')),
47+
);
7148
}
7249

7350
protected function getURI($path) {

0 commit comments

Comments
 (0)