From 673067a52d44cbfc14327d226f4f1c4ce66f737a Mon Sep 17 00:00:00 2001 From: Federico Scodelaro Date: Fri, 10 Oct 2025 19:43:38 -0300 Subject: Last user modified (#7886) * feat: Add user modified functionality Closes https://github.com/FreshRSS/FreshRSS/issues/7862 Changes proposed in this pull request: This is an implementation of the proposed feature. It allows entries to have a new field that will be updated whenever an item is marked as read/unread or bookmark/removed from bookmarks. And a new sort criteria to sort by it. How to test the feature manually: 1. Mark items from a feed as read/unread 2. Mark items from a feed as bookmark / remove bookmark 3. Sort by the new criteria * feat: Add sort functionality * feat: Add sort nav button * fix: Use correct migrations * fix: Add internationalization * fix: Linter errors * chore: PR comments * Update app/i18n/fr/index.php Co-authored-by: Alexandre Alapetite * Update app/i18n/pl/index.php Co-authored-by: Inverle * Update app/i18n/nl/index.php Co-authored-by: Frans de Jonge * make fix-all * Fixes * More fixes sort * Fix wrong index * Fix unneeded column * Fix auto-create indexes * Some copilot suggestions * One more fix Co-authored-by: Alexandre Alapetite --------- Co-authored-by: Alexandre Alapetite Co-authored-by: Inverle Co-authored-by: Frans de Jonge --- app/Models/EntryDAOSQLite.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/Models/EntryDAOSQLite.php') diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php index d46b48f27..8bf0e2209 100644 --- a/app/Models/EntryDAOSQLite.php +++ b/app/Models/EntryDAOSQLite.php @@ -64,7 +64,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { #[\Override] protected function autoUpdateDb(array $errorInfo): bool { if (($tableInfo = $this->pdo->query("PRAGMA table_info('entry')")) !== false && ($columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1)) !== false) { - foreach (['attributes'] as $column) { + foreach (['attributes', 'lastUserModified'] as $column) { if (!in_array($column, $columns, true)) { return $this->addColumn($column); } @@ -124,8 +124,8 @@ SQL; } else { FreshRSS_UserDAO::touch(); $this->pdo->beginTransaction(); - $sql = 'UPDATE `_entry` SET is_read=? WHERE id=? AND is_read=?'; - $values = [$is_read ? 1 : 0, $ids, $is_read ? 0 : 1]; + $sql = 'UPDATE `_entry` SET is_read=?, `lastUserModified` = ? WHERE id=? AND is_read=?'; + $values = [$is_read ? 1 : 0, time(), $ids, $is_read ? 0 : 1]; $stm = $this->pdo->prepare($sql); if ($stm === false || !$stm->execute($values)) { $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo(); @@ -165,11 +165,11 @@ SQL; Minz_Log::debug('Calling markReadTag(0) is deprecated!'); } - $sql = 'UPDATE `_entry` SET is_read = ? WHERE is_read <> ? AND id <= ? AND ' + $sql = 'UPDATE `_entry` SET is_read = ?, `lastUserModified` = ? WHERE is_read <> ? AND id <= ? AND ' . 'id IN (SELECT et.id_entry FROM `_entrytag` et ' . ($id == 0 ? '' : 'WHERE et.id_tag = ?') . ')'; - $values = [$is_read ? 1 : 0, $is_read ? 1 : 0, $idMax]; + $values = [$is_read ? 1 : 0, time(), $is_read ? 1 : 0, $idMax]; if ($id != 0) { $values[] = $id; } -- cgit v1.2.3