Skip to content

Commit 163f2c4

Browse files
author
epriestley
committedJun 30, 2016
Refine available filters and defaults for relationship selection
Summary: Ref T4788. Fixes T10703. In the longer term I want to put this on top of ApplicationSearch, but that's somewhat complex and we're at a fairly good point to pause this feature for feedback. Inch toward that instead: provide more appropriate filters and defaults without rebuilding the underlying engine. Specifically: - No "assigned" for commits (barely makes sense). - No "assigned" for mocks (does not make sense). - Default to "open" for parent tasks, subtasks, close as duplicate, and merge into. Also, add a key to the `search_document` table to improve the performance of the "all open stuff of type X" query. "All Open Tasks" is about 100x faster on my machine with this key. Test Plan: - Clicked all object relationships, saw more sensible filters and defaults. - Saw "open" query about 100x faster locally (300ms to 3ms). Reviewers: chad Reviewed By: chad Maniphest Tasks: T4788, T10703 Differential Revision: https://secure.phabricator.com/D16202
1 parent 7574f8d commit 163f2c4

9 files changed

+58
-13
lines changed
 

‎src/applications/maniphest/relationship/ManiphestTaskCloseAsDuplicateRelationship.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public function getDialogButtonText() {
3838
}
3939

4040
protected function newRelationshipSource() {
41-
return new ManiphestTaskRelationshipSource();
41+
return id(new ManiphestTaskRelationshipSource())
42+
->setSelectedFilter('open');
4243
}
4344

4445
public function getRequiredRelationshipCapabilities() {

‎src/applications/maniphest/relationship/ManiphestTaskHasParentRelationship.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public function getDialogButtonText() {
3838
}
3939

4040
protected function newRelationshipSource() {
41-
return new ManiphestTaskRelationshipSource();
41+
return id(new ManiphestTaskRelationshipSource())
42+
->setSelectedFilter('open');
4243
}
4344

4445
}

‎src/applications/maniphest/relationship/ManiphestTaskHasSubtaskRelationship.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public function getDialogButtonText() {
3838
}
3939

4040
protected function newRelationshipSource() {
41-
return new ManiphestTaskRelationshipSource();
41+
return id(new ManiphestTaskRelationshipSource())
42+
->setSelectedFilter('open');
4243
}
4344

4445
}

‎src/applications/maniphest/relationship/ManiphestTaskMergeInRelationship.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public function getDialogButtonText() {
3838
}
3939

4040
protected function newRelationshipSource() {
41-
return new ManiphestTaskRelationshipSource();
41+
return id(new ManiphestTaskRelationshipSource())
42+
->setSelectedFilter('open');
4243
}
4344

4445
public function getRequiredRelationshipCapabilities() {

‎src/applications/search/controller/PhabricatorSearchRelationshipController.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -150,27 +150,24 @@ public function handleRequest(AphrontRequest $request) {
150150
$handles = iterator_to_array($handles);
151151
$handles = array_select_keys($handles, $dst_phids);
152152

153-
// TODO: These are hard-coded for now.
154-
$filters = array(
155-
'assigned' => pht('Assigned to Me'),
156-
'created' => pht('Created By Me'),
157-
'open' => pht('All Open Objects'),
158-
'all' => pht('All Objects'),
159-
);
160-
161153
$dialog_title = $relationship->getDialogTitleText();
162154
$dialog_header = $relationship->getDialogHeaderText();
163155
$dialog_button = $relationship->getDialogButtonText();
164156
$dialog_instructions = $relationship->getDialogInstructionsText();
165157

166158
$source_uri = $relationship->getSourceURI($object);
167159

160+
$source = $relationship->newSource();
161+
162+
$filters = $source->getFilters();
163+
$selected_filter = $source->getSelectedFilter();
164+
168165
return id(new PhabricatorObjectSelectorDialog())
169166
->setUser($viewer)
170167
->setInitialPHIDs($initial_phids)
171168
->setHandles($handles)
172169
->setFilters($filters)
173-
->setSelectedFilter('created')
170+
->setSelectedFilter($selected_filter)
174171
->setExcluded($src_phid)
175172
->setCancelURI($done_uri)
176173
->setSearchURI($source_uri)

‎src/applications/search/relationship/DiffusionCommitRelationshipSource.php

+6
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,10 @@ public function getResultPHIDTypes() {
1717
);
1818
}
1919

20+
public function getFilters() {
21+
$filters = parent::getFilters();
22+
unset($filters['assigned']);
23+
return $filters;
24+
}
25+
2026
}

‎src/applications/search/relationship/PhabricatorObjectRelationshipSource.php

+29
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
abstract class PhabricatorObjectRelationshipSource extends Phobject {
44

55
private $viewer;
6+
private $selectedFilter;
67

78
final public function setViewer(PhabricatorUser $viewer) {
89
$this->viewer = $viewer;
@@ -16,4 +17,32 @@ final public function getViewer() {
1617
abstract public function isEnabledForObject($object);
1718
abstract public function getResultPHIDTypes();
1819

20+
protected function getDefaultFilter() {
21+
return 'created';
22+
}
23+
24+
final public function setSelectedFilter($selected_filter) {
25+
$this->selectedFilter = $selected_filter;
26+
return $this;
27+
}
28+
29+
final public function getSelectedFilter() {
30+
if ($this->selectedFilter === null) {
31+
return $this->getDefaultFilter();
32+
}
33+
34+
return $this->selectedFilter;
35+
}
36+
37+
public function getFilters() {
38+
// TODO: These are hard-coded for now, and all of this will probably be
39+
// rewritten when we move to ApplicationSearch.
40+
return array(
41+
'assigned' => pht('Assigned to Me'),
42+
'created' => pht('Created By Me'),
43+
'open' => pht('All Open Objects'),
44+
'all' => pht('All Objects'),
45+
);
46+
}
47+
1948
}

‎src/applications/search/relationship/PholioMockRelationshipSource.php

+6
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,10 @@ public function getResultPHIDTypes() {
1717
);
1818
}
1919

20+
public function getFilters() {
21+
$filters = parent::getFilters();
22+
unset($filters['assigned']);
23+
return $filters;
24+
}
25+
2026
}

‎src/applications/search/storage/document/PhabricatorSearchDocument.php

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ protected function getConfiguration() {
2626
'documentCreated' => array(
2727
'columns' => array('documentCreated'),
2828
),
29+
'key_type' => array(
30+
'columns' => array('documentType', 'documentCreated'),
31+
),
2932
),
3033
) + parent::getConfiguration();
3134
}

0 commit comments

Comments
 (0)
Failed to load comments.