@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.

Provide URI/API support for querying subtasks/parents of a particular task

Summary:
Ref T8126. Ref T4788. This adds a way to query by parent or subtask.

I plan to link to this from the task graph (e.g., {nav View > Search Subtasks} or similar, in a dropdown on the "Task Graph" element) as a way to let us bail out if tasks have 300 subtasks and send the user to a big query result list. That'll give us more flexibility to tailor the UI for reasonable numbers of tasks.

There's no UI for this unless you specify a query yourself, so the only ways to get to it are:

- Manually put `?parentIDs=...` into the URI.
- Use the API.
- Future link from task graphs.

It doesn't seem too useful to me on its own, outside of the context of links from tasks.

Test Plan:
- Manually put `?parentIDs=...` and `?subtaskIDs=...` into Maniphest query UI, got expected results.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4788, T8126

Differential Revision: https://secure.phabricator.com/D16341

+65 -4
+47 -4
src/applications/maniphest/query/ManiphestTaskQuery.php
··· 22 22 private $bridgedObjectPHIDs; 23 23 private $hasOpenParents; 24 24 private $hasOpenSubtasks; 25 + private $parentTaskIDs; 26 + private $subtaskIDs; 25 27 26 28 private $fullTextSearch = ''; 27 29 ··· 158 160 159 161 public function withOpenParents($value) { 160 162 $this->hasOpenParents = $value; 163 + return $this; 164 + } 165 + 166 + public function withParentTaskIDs(array $ids) { 167 + $this->parentTaskIDs = $ids; 168 + return $this; 169 + } 170 + 171 + public function withSubtaskIDs(array $ids) { 172 + $this->subtaskIDs = $ids; 161 173 return $this; 162 174 } 163 175 ··· 512 524 $edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE; 513 525 $task_table = $this->newResultObject()->getTableName(); 514 526 527 + $parent_type = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST; 528 + $subtask_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST; 529 + 515 530 $joins = array(); 516 531 if ($this->hasOpenParents !== null) { 517 - $parent_type = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST; 518 - 519 532 if ($this->hasOpenParents) { 520 533 $join_type = 'JOIN'; 521 534 } else { ··· 539 552 } 540 553 541 554 if ($this->hasOpenSubtasks !== null) { 542 - $subtask_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST; 543 - 544 555 if ($this->hasOpenSubtasks) { 545 556 $join_type = 'JOIN'; 546 557 } else { ··· 602 613 break; 603 614 } 604 615 616 + if ($this->parentTaskIDs !== null) { 617 + $joins[] = qsprintf( 618 + $conn, 619 + 'JOIN %T e_has_parent 620 + ON e_has_parent.src = task.phid 621 + AND e_has_parent.type = %d 622 + JOIN %T has_parent 623 + ON e_has_parent.dst = has_parent.phid 624 + AND has_parent.id IN (%Ld)', 625 + $edge_table, 626 + $parent_type, 627 + $task_table, 628 + $this->parentTaskIDs); 629 + } 630 + 631 + if ($this->subtaskIDs !== null) { 632 + $joins[] = qsprintf( 633 + $conn, 634 + 'JOIN %T e_has_subtask 635 + ON e_has_subtask.src = task.phid 636 + AND e_has_subtask.type = %d 637 + JOIN %T has_subtask 638 + ON e_has_subtask.dst = has_subtask.phid 639 + AND has_subtask.id IN (%Ld)', 640 + $edge_table, 641 + $subtask_type, 642 + $task_table, 643 + $this->subtaskIDs); 644 + } 645 + 605 646 $joins[] = parent::buildJoinClauseParts($conn); 606 647 607 648 return $joins; ··· 611 652 $joined_multiple_rows = 612 653 ($this->hasOpenParents !== null) || 613 654 ($this->hasOpenSubtasks !== null) || 655 + ($this->parentTaskIDs !== null) || 656 + ($this->subtaskIDs !== null) || 614 657 $this->shouldGroupQueryResultRows(); 615 658 616 659 $joined_project_name = ($this->groupBy == self::GROUP_PROJECT);
+18
src/applications/maniphest/query/ManiphestTaskSearchEngine.php
··· 92 92 pht('(Show All)'), 93 93 pht('Show Only Tasks With Open Subtasks'), 94 94 pht('Show Only Tasks Without Open Subtasks')), 95 + id(new PhabricatorIDsSearchField()) 96 + ->setLabel(pht('Parent IDs')) 97 + ->setKey('parentIDs') 98 + ->setAliases(array('parentID')), 99 + id(new PhabricatorIDsSearchField()) 100 + ->setLabel(pht('Subtask IDs')) 101 + ->setKey('subtaskIDs') 102 + ->setAliases(array('subtaskID')), 95 103 id(new PhabricatorSearchSelectField()) 96 104 ->setLabel(pht('Group By')) 97 105 ->setKey('group') ··· 125 133 'fulltext', 126 134 'hasParents', 127 135 'hasSubtasks', 136 + 'parentIDs', 137 + 'subtaskIDs', 128 138 'group', 129 139 'order', 130 140 'ids', ··· 194 204 195 205 if (strlen($map['fulltext'])) { 196 206 $query->withFullTextSearch($map['fulltext']); 207 + } 208 + 209 + if ($map['parentIDs']) { 210 + $query->withParentTaskIDs($map['parentIDs']); 211 + } 212 + 213 + if ($map['subtaskIDs']) { 214 + $query->withSubtaskIDs($map['subtaskIDs']); 197 215 } 198 216 199 217 $group = idx($map, 'group');