@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+58 -13
+2 -1
src/applications/maniphest/relationship/ManiphestTaskCloseAsDuplicateRelationship.php
··· 38 38 } 39 39 40 40 protected function newRelationshipSource() { 41 - return new ManiphestTaskRelationshipSource(); 41 + return id(new ManiphestTaskRelationshipSource()) 42 + ->setSelectedFilter('open'); 42 43 } 43 44 44 45 public function getRequiredRelationshipCapabilities() {
+2 -1
src/applications/maniphest/relationship/ManiphestTaskHasParentRelationship.php
··· 38 38 } 39 39 40 40 protected function newRelationshipSource() { 41 - return new ManiphestTaskRelationshipSource(); 41 + return id(new ManiphestTaskRelationshipSource()) 42 + ->setSelectedFilter('open'); 42 43 } 43 44 44 45 }
+2 -1
src/applications/maniphest/relationship/ManiphestTaskHasSubtaskRelationship.php
··· 38 38 } 39 39 40 40 protected function newRelationshipSource() { 41 - return new ManiphestTaskRelationshipSource(); 41 + return id(new ManiphestTaskRelationshipSource()) 42 + ->setSelectedFilter('open'); 42 43 } 43 44 44 45 }
+2 -1
src/applications/maniphest/relationship/ManiphestTaskMergeInRelationship.php
··· 38 38 } 39 39 40 40 protected function newRelationshipSource() { 41 - return new ManiphestTaskRelationshipSource(); 41 + return id(new ManiphestTaskRelationshipSource()) 42 + ->setSelectedFilter('open'); 42 43 } 43 44 44 45 public function getRequiredRelationshipCapabilities() {
+6 -9
src/applications/search/controller/PhabricatorSearchRelationshipController.php
··· 150 150 $handles = iterator_to_array($handles); 151 151 $handles = array_select_keys($handles, $dst_phids); 152 152 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 - 161 153 $dialog_title = $relationship->getDialogTitleText(); 162 154 $dialog_header = $relationship->getDialogHeaderText(); 163 155 $dialog_button = $relationship->getDialogButtonText(); ··· 165 157 166 158 $source_uri = $relationship->getSourceURI($object); 167 159 160 + $source = $relationship->newSource(); 161 + 162 + $filters = $source->getFilters(); 163 + $selected_filter = $source->getSelectedFilter(); 164 + 168 165 return id(new PhabricatorObjectSelectorDialog()) 169 166 ->setUser($viewer) 170 167 ->setInitialPHIDs($initial_phids) 171 168 ->setHandles($handles) 172 169 ->setFilters($filters) 173 - ->setSelectedFilter('created') 170 + ->setSelectedFilter($selected_filter) 174 171 ->setExcluded($src_phid) 175 172 ->setCancelURI($done_uri) 176 173 ->setSearchURI($source_uri)
+6
src/applications/search/relationship/DiffusionCommitRelationshipSource.php
··· 17 17 ); 18 18 } 19 19 20 + public function getFilters() { 21 + $filters = parent::getFilters(); 22 + unset($filters['assigned']); 23 + return $filters; 24 + } 25 + 20 26 }
+29
src/applications/search/relationship/PhabricatorObjectRelationshipSource.php
··· 3 3 abstract class PhabricatorObjectRelationshipSource extends Phobject { 4 4 5 5 private $viewer; 6 + private $selectedFilter; 6 7 7 8 final public function setViewer(PhabricatorUser $viewer) { 8 9 $this->viewer = $viewer; ··· 15 16 16 17 abstract public function isEnabledForObject($object); 17 18 abstract public function getResultPHIDTypes(); 19 + 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 + } 18 47 19 48 }
+6
src/applications/search/relationship/PholioMockRelationshipSource.php
··· 17 17 ); 18 18 } 19 19 20 + public function getFilters() { 21 + $filters = parent::getFilters(); 22 + unset($filters['assigned']); 23 + return $filters; 24 + } 25 + 20 26 }
+3
src/applications/search/storage/document/PhabricatorSearchDocument.php
··· 26 26 'documentCreated' => array( 27 27 'columns' => array('documentCreated'), 28 28 ), 29 + 'key_type' => array( 30 + 'columns' => array('documentType', 'documentCreated'), 31 + ), 29 32 ), 30 33 ) + parent::getConfiguration(); 31 34 }