From 7e72033859f60f529d4d985da1e9cac0a691b2dc Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 15 Oct 2025 00:12:19 +0200 Subject: Filter on last user modified (#8093) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Example: `userdate:PT1H` to select only articles modified by user during the last hour Fix https://github.com/FreshRSS/FreshRSS/issues/4280#issuecomment-3393078024 Useful for instance to bulk mark as unread recently marked articles by error: 1. Click on the toggle button to show the read articles (making sure the toggle for the unread articles is off) 2. Sort by *User modified 9→1* 3. Filter by *user modified date*, for instance to the last 3 hours by typing `userdate:PT3H` 4. Click in the drop-down menu *Mark selection as unread* P.S.: I have added at the same time a bunch of unit tests for date-related logic --- app/Models/EntryDAO.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app/Models/EntryDAO.php') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 6eefd684c..c9fae7923 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -906,6 +906,14 @@ SQL; $sub_search .= 'AND ' . $alias . 'date <= ? '; $values[] = $filter->getMaxPubdate(); } + if ($filter->getMinUserdate() !== null) { + $sub_search .= 'AND ' . $alias . '`lastUserModified` >= ? '; + $values[] = $filter->getMinUserdate(); + } + if ($filter->getMaxUserdate() !== null) { + $sub_search .= 'AND ' . $alias . '`lastUserModified` <= ? '; + $values[] = $filter->getMaxUserdate(); + } //Negation of date intervals must be combined by OR if ($filter->getNotMinDate() !== null || $filter->getNotMaxDate() !== null) { @@ -938,6 +946,21 @@ SQL; } $sub_search .= ') '; } + if ($filter->getNotMinUserdate() !== null || $filter->getNotMaxUserdate() !== null) { + $sub_search .= 'AND ('; + if ($filter->getNotMinUserdate() !== null) { + $sub_search .= $alias . '`lastUserModified` < ?'; + $values[] = $filter->getNotMinUserdate(); + if ($filter->getNotMaxUserdate()) { + $sub_search .= ' OR '; + } + } + if ($filter->getNotMaxUserdate() !== null) { + $sub_search .= $alias . '`lastUserModified` > ?'; + $values[] = $filter->getNotMaxUserdate(); + } + $sub_search .= ') '; + } if ($filter->getFeedIds() !== null) { $sub_search .= 'AND ' . $alias . 'id_feed IN ('; -- cgit v1.2.3