From f0d4f2762d2b74eeadf2fb64ff83039b5cc16c26 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 3 Dec 2023 19:52:02 +0100 Subject: Rework keepmax (#5905) * Rework keepmax fix https://github.com/FreshRSS/FreshRSS/issues/5702 fix https://github.com/FreshRSS/FreshRSS/issues/5870 * More WIP * Minor progress * Progress * Beta * Improved debug message * Revert noCommit * Fix variable reset * Remove debug syslogs --- app/Models/EntryDAO.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'app/Models/EntryDAO.php') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 403f4e493..23ac3c918 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -273,6 +273,26 @@ SQL; } } + /** + * Count the number of new entries in the temporary table (which have not yet been committed), grouped by feed ID. + * @return array + */ + public function newUnreadEntriesPerFeed(): array { + $sql = <<<'SQL' + SELECT id_feed, COUNT(id) AS nb_entries FROM `_entrytmp` + WHERE is_read = 0 + GROUP BY id_feed + SQL; + $lines = $this->fetchAssoc($sql) ?? []; + $result = []; + foreach ($lines as $line) { + if (!empty($line['id_feed'])) { + $result[(int)$line['id_feed']] = (int)($line['nb_entries'] ?? 0); + } + } + return $result; + } + /** * Toggle favorite marker on one or more article * -- cgit v1.2.3