Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15333905
D18029.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D18029.diff
View Options
diff --git a/src/applications/feed/query/PhabricatorFeedQuery.php b/src/applications/feed/query/PhabricatorFeedQuery.php
--- a/src/applications/feed/query/PhabricatorFeedQuery.php
+++ b/src/applications/feed/query/PhabricatorFeedQuery.php
@@ -5,6 +5,8 @@
private $filterPHIDs;
private $chronologicalKeys;
+ private $rangeMin;
+ private $rangeMax;
public function withFilterPHIDs(array $phids) {
$this->filterPHIDs = $phids;
@@ -16,6 +18,12 @@
return $this;
}
+ public function withEpochInRange($range_min, $range_max) {
+ $this->rangeMin = $range_min;
+ $this->rangeMax = $range_max;
+ return $this;
+ }
+
public function newResultObject() {
return new PhabricatorFeedStoryData();
}
@@ -74,6 +82,24 @@
implode(', ', $keys));
}
+ // NOTE: We may not have 64-bit PHP, so do the shifts in MySQL instead.
+ // From EXPLAIN, it appears like MySQL is smart enough to compute the
+ // result and make use of keys to execute the query.
+
+ if ($this->rangeMin !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'ref.chronologicalKey >= (%d << 32)',
+ $this->rangeMin);
+ }
+
+ if ($this->rangeMax !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'ref.chronologicalKey < (%d << 32)',
+ $this->rangeMax);
+ }
+
return $where;
}
diff --git a/src/applications/feed/query/PhabricatorFeedSearchEngine.php b/src/applications/feed/query/PhabricatorFeedSearchEngine.php
--- a/src/applications/feed/query/PhabricatorFeedSearchEngine.php
+++ b/src/applications/feed/query/PhabricatorFeedSearchEngine.php
@@ -30,6 +30,12 @@
->setDatasource(new PhabricatorProjectDatasource())
->setLabel(pht('Include Projects'))
->setKey('projectPHIDs'),
+ id(new PhabricatorSearchDateControlField())
+ ->setLabel(pht('Occurs After'))
+ ->setKey('rangeStart'),
+ id(new PhabricatorSearchDateControlField())
+ ->setLabel(pht('Occurs Before'))
+ ->setKey('rangeEnd'),
// NOTE: This is a legacy field retained only for backward
// compatibility. If the projects field used EdgeLogic, we could use
@@ -71,6 +77,30 @@
$query->withFilterPHIDs($phids);
}
+ $range_min = $map['rangeStart'];
+ if ($range_min) {
+ $range_min = $range_min->getEpoch();
+ }
+
+ $range_max = $map['rangeEnd'];
+ if ($range_max) {
+ $range_max = $range_max->getEpoch();
+ }
+
+ if ($range_min && $range_max) {
+ if ($range_min > $range_max) {
+ throw new PhabricatorSearchConstraintException(
+ pht(
+ 'The specified "Occurs Before" date is earlier in time than the '.
+ 'specified "Occurs After" date, so this query can never match '.
+ 'any results.'));
+ }
+ }
+
+ if ($range_min || $range_max) {
+ $query->withEpochInRange($range_min, $range_max);
+ }
+
return $query;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 9, 5:28 AM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7386808
Default Alt Text
D18029.diff (2 KB)
Attached To
Mode
D18029: Allow users to query feed by a date range
Attached
Detach File
Event Timeline
Log In to Comment