diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php --- a/src/applications/maniphest/query/ManiphestTaskQuery.php +++ b/src/applications/maniphest/query/ManiphestTaskQuery.php @@ -23,6 +23,9 @@ private $parentTaskIDs; private $subtaskIDs; private $subtypes; + private $closedEpochMin; + private $closedEpochMax; + private $closerPHIDs; private $status = 'status-any'; const STATUS_ANY = 'status-any'; @@ -179,6 +182,17 @@ return $this; } + public function withClosedEpochBetween($min, $max) { + $this->closedEpochMin = $min; + $this->closedEpochMax = $max; + return $this; + } + + public function withCloserPHIDs(array $phids) { + $this->closerPHIDs = $phids; + return $this; + } + public function needSubscriberPHIDs($bool) { $this->needSubscriberPHIDs = $bool; return $this; @@ -379,6 +393,27 @@ $this->dateModifiedBefore); } + if ($this->closedEpochMin !== null) { + $where[] = qsprintf( + $conn, + 'task.closedEpoch >= %d', + $this->closedEpochMin); + } + + if ($this->closedEpochMax !== null) { + $where[] = qsprintf( + $conn, + 'task.closedEpoch <= %d', + $this->closedEpochMax); + } + + if ($this->closerPHIDs !== null) { + $where[] = qsprintf( + $conn, + 'task.closerPHID IN (%Ls)', + $this->closerPHIDs); + } + if ($this->priorities !== null) { $where[] = qsprintf( $conn, @@ -722,7 +757,11 @@ 'outdated' => array( 'vector' => array('-updated', '-id'), 'name' => pht('Date Updated (Oldest First)'), - ), + ), + 'closed' => array( + 'vector' => array('closed', 'id'), + 'name' => pht('Date Closed (Latest First)'), + ), 'title' => array( 'vector' => array('title', 'id'), 'name' => pht('Title'), @@ -741,6 +780,7 @@ 'outdated', 'newest', 'oldest', + 'closed', 'title', )) + $orders; @@ -790,6 +830,12 @@ 'column' => 'dateModified', 'type' => 'int', ), + 'closed' => array( + 'table' => 'task', + 'column' => 'closedEpoch', + 'type' => 'int', + 'null' => 'tail', + ), ); } @@ -808,6 +854,7 @@ 'status' => $task->getStatus(), 'title' => $task->getTitle(), 'updated' => $task->getDateModified(), + 'closed' => $task->getClosedEpoch(), ); foreach ($keys as $key) { diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php --- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php +++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php @@ -126,6 +126,17 @@ id(new PhabricatorSearchDateField()) ->setLabel(pht('Updated Before')) ->setKey('modifiedEnd'), + id(new PhabricatorSearchDateField()) + ->setLabel(pht('Closed After')) + ->setKey('closedStart'), + id(new PhabricatorSearchDateField()) + ->setLabel(pht('Closed Before')) + ->setKey('closedEnd'), + id(new PhabricatorUsersSearchField()) + ->setLabel(pht('Closed By')) + ->setKey('closerPHIDs') + ->setAliases(array('closer', 'closerPHID', 'closers')) + ->setDescription(pht('Search for tasks closed by certain users.')), id(new PhabricatorSearchTextField()) ->setLabel(pht('Page Size')) ->setKey('limit'), @@ -153,6 +164,9 @@ 'createdEnd', 'modifiedStart', 'modifiedEnd', + 'closedStart', + 'closedEnd', + 'closerPHIDs', 'limit', ); } @@ -208,6 +222,14 @@ $query->withDateModifiedBefore($map['modifiedEnd']); } + if ($map['closedStart'] || $map['closedEnd']) { + $query->withClosedEpochBetween($map['closedStart'], $map['closedEnd']); + } + + if ($map['closerPHIDs']) { + $query->withCloserPHIDs($map['closerPHIDs']); + } + if ($map['hasParents'] !== null) { $query->withOpenParents($map['hasParents']); }