From c6c1893dc0be027adf17355f6bd607f00b94b7bf Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 5 Oct 2018 11:07:28 -0700 Subject: [PATCH] Allow revisions to be filtered by created date Summary: Ref T13202. See PHI906. This is a reasonable capability which we support in some other applications already. (The only real reason not to support this is that it creates some clutter in the UI, but I think we're generally in better shape now than we were in the past, and we could make this UI collapse/fold at some point.) Test Plan: Ran queries with a minimum date, a maximum date, both, and neither. Saw appropriate results in all cases. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13202 Differential Revision: https://secure.phabricator.com/D19732 --- .../query/DifferentialRevisionQuery.php | 22 +++++++++++++++++++ .../DifferentialRevisionSearchEngine.php | 16 ++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/applications/differential/query/DifferentialRevisionQuery.php b/src/applications/differential/query/DifferentialRevisionQuery.php index 727a4ca184..bc93de2db2 100644 --- a/src/applications/differential/query/DifferentialRevisionQuery.php +++ b/src/applications/differential/query/DifferentialRevisionQuery.php @@ -25,6 +25,8 @@ final class DifferentialRevisionQuery private $updatedEpochMax; private $statuses; private $isOpen; + private $createdEpochMin; + private $createdEpochMax; const ORDER_MODIFIED = 'order-modified'; const ORDER_CREATED = 'order-created'; @@ -206,6 +208,12 @@ final class DifferentialRevisionQuery return $this; } + public function withCreatedEpochBetween($min, $max) { + $this->createdEpochMin = $min; + $this->createdEpochMax = $max; + return $this; + } + /** * Set whether or not the query should load the active diff for each @@ -687,6 +695,20 @@ final class DifferentialRevisionQuery $this->updatedEpochMax); } + if ($this->createdEpochMin !== null) { + $where[] = qsprintf( + $conn_r, + 'r.dateCreated >= %d', + $this->createdEpochMin); + } + + if ($this->createdEpochMax !== null) { + $where[] = qsprintf( + $conn_r, + 'r.dateCreated <= %d', + $this->createdEpochMax); + } + if ($this->statuses !== null) { $where[] = qsprintf( $conn_r, diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php index 835291fba8..557ca23078 100644 --- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php +++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php @@ -45,6 +45,12 @@ final class DifferentialRevisionSearchEngine $query->withStatuses($map['statuses']); } + if ($map['createdStart'] || $map['createdEnd']) { + $query->withCreatedEpochBetween( + $map['createdStart'], + $map['createdEnd']); + } + return $query; } @@ -84,6 +90,16 @@ final class DifferentialRevisionSearchEngine ->setDatasource(new DifferentialRevisionStatusFunctionDatasource()) ->setDescription( pht('Find revisions with particular statuses.')), + id(new PhabricatorSearchDateField()) + ->setLabel(pht('Created After')) + ->setKey('createdStart') + ->setDescription( + pht('Find revisions created at or after a particular time.')), + id(new PhabricatorSearchDateField()) + ->setLabel(pht('Created Before')) + ->setKey('createdEnd') + ->setDescription( + pht('Find revisions created at or before a particular time.')), ); } -- 2.51.2