aboutsummaryrefslogtreecommitdiff
path: root/app/Models/EntryDAO.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2020-04-01 17:26:19 +0200
committerGravatar GitHub <noreply@github.com> 2020-04-01 17:26:19 +0200
commit61c8026ac98a5ed7d4c715102d66d56d967553ab (patch)
treed10292dc8446d29fbe2f7b71856c7c2a4bd98e09 /app/Models/EntryDAO.php
parent656b61ff2956351538cc70fe79cc534b1eb58e0c (diff)
Implement negation for searching by date intervals (#2869)
* Implement negation for searching by date intervals #fix https://github.com/FreshRSS/FreshRSS/issues/2866 Allow searching for e.g. `!date:P1W` to exlude all articles newer than one week. More generally, allows exclusion on some date intervals. * Fix OR
Diffstat (limited to 'app/Models/EntryDAO.php')
-rw-r--r--app/Models/EntryDAO.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index ebe530ec1..1cca5cd75 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -720,6 +720,38 @@ SQL;
$values[] = $filter->getMaxPubdate();
}
+ //Negation of date intervals must be combined by OR
+ if ($filter->getNotMinDate() || $filter->getNotMaxDate()) {
+ $sub_search .= 'AND (';
+ if ($filter->getNotMinDate()) {
+ $sub_search .= $alias . 'id < ?';
+ $values[] = "{$filter->getNotMinDate()}000000";
+ if ($filter->getNotMaxDate()) {
+ $sub_search .= ' OR ';
+ }
+ }
+ if ($filter->getNotMaxDate()) {
+ $sub_search .= $alias . 'id > ?';
+ $values[] = "{$filter->getNotMaxDate()}000000";
+ }
+ $sub_search .= ') ';
+ }
+ if ($filter->getNotMinPubdate() || $filter->getNotMaxPubdate()) {
+ $sub_search .= 'AND (';
+ if ($filter->getNotMinPubdate()) {
+ $sub_search .= $alias . 'date < ?';
+ $values[] = $filter->getNotMinPubdate();
+ if ($filter->getNotMaxPubdate()) {
+ $sub_search .= ' OR ';
+ }
+ }
+ if ($filter->getNotMaxPubdate()) {
+ $sub_search .= $alias . 'date > ?';
+ $values[] = $filter->getNotMaxPubdate();
+ }
+ $sub_search .= ') ';
+ }
+
if ($filter->getAuthor()) {
foreach ($filter->getAuthor() as $author) {
$sub_search .= 'AND ' . $alias . 'author LIKE ? ';