Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15384759
D18029.id43362.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.id43362.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
@@ -27,6 +27,12 @@
id(new PhabricatorProjectSearchField())
->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. Users can now run an equivalent query by searching for
@@ -68,6 +74,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
Sat, Mar 15, 8:43 PM (1 w, 13 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7703503
Default Alt Text
D18029.id43362.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