aboutsummaryrefslogtreecommitdiff
path: root/app/Models/EntryDAO.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-02-26 09:01:25 +0100
committerGravatar GitHub <noreply@github.com> 2024-02-26 09:01:25 +0100
commitbfd277065c7bfd28779c585549dd9e9e577eabdf (patch)
tree15cca303b1a7627686e4107a678391dda9803f13 /app/Models/EntryDAO.php
parent39cc1c11ec596176e842cc98e6a54337e3c04d7e (diff)
Improve feed refresh (#6117)
* Improve feed refresh Better account for some edge cases for cron and automatic labels fix https://github.com/FreshRSS/FreshRSS/issues/6089 fix https://github.com/FreshRSS/FreshRSS/issues/6109 * Apply labels also to new entries already marked as read * Add case most relevant for cron
Diffstat (limited to 'app/Models/EntryDAO.php')
-rw-r--r--app/Models/EntryDAO.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index f770ce400..bb0b9af43 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -274,7 +274,29 @@ SQL;
}
/**
- * Count the number of new entries in the temporary table (which have not yet been committed), grouped by feed ID.
+ * 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}
+ */
+ public function countNewEntries(): array {
+ $sql = <<<'SQL'
+ SELECT is_read, COUNT(id) AS nb_entries FROM `_entrytmp`
+ GROUP BY is_read
+ 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 {