diff options
Diffstat (limited to 'app/Models/EntryDAO.php')
| -rw-r--r-- | app/Models/EntryDAO.php | 43 |
1 files changed, 6 insertions, 37 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 0b289eb41..ec627dda1 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -274,45 +274,14 @@ SQL; } /** - * Count the number of new entries in the temporary table (which have not yet been committed), grouped by read / unread. - * @return array{'all':int,'unread':int,'read':int} + * Count the number of new entries in the temporary table (which have not yet been committed). */ - public function countNewEntries(): array { + public function countNewEntries(): int { $sql = <<<'SQL' - SELECT is_read, COUNT(id) AS nb_entries FROM `_entrytmp` - GROUP BY is_read + SELECT COUNT(id) AS nb_entries FROM `_entrytmp` SQL; - $lines = $this->fetchAssoc($sql) ?? []; - $nbRead = 0; - $nbUnread = 0; - foreach ($lines as $line) { - if (empty($line['is_read'])) { - $nbUnread = (int)($line['nb_entries'] ?? 0); - } else { - $nbRead = (int)($line['nb_entries'] ?? 0); - } - } - return ['all' => $nbRead + $nbUnread, 'unread' => $nbUnread, 'read' => $nbRead]; - } - - /** - * Count the number of new unread entries in the temporary table (which have not yet been committed), grouped by feed ID. - * @return array<int,int> - */ - 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; + $res = $this->fetchColumn($sql, 0); + return isset($res[0]) ? (int)$res[0] : -1; } /** @@ -651,7 +620,7 @@ SQL; } /** - * Remember to call updateCachedValue($id_feed) or updateCachedValues() just after. + * Remember to call updateCachedValues($id_feed) or updateCachedValues() just after. * @param array<string,bool|int|string> $options * @return int|false */ |
