aboutsummaryrefslogtreecommitdiff
path: root/app/Models/EntryDAO.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Models/EntryDAO.php')
-rw-r--r--app/Models/EntryDAO.php20
1 files changed, 20 insertions, 0 deletions
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
@@ -274,6 +274,26 @@ SQL;
}
/**
+ * Count the number of new 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;
+ }
+
+ /**
* Toggle favorite marker on one or more article
*
* @todo simplify the query by removing the str_repeat. I am pretty sure