diff options
| author | 2024-02-26 09:01:25 +0100 | |
|---|---|---|
| committer | 2024-02-26 09:01:25 +0100 | |
| commit | bfd277065c7bfd28779c585549dd9e9e577eabdf (patch) | |
| tree | 15cca303b1a7627686e4107a678391dda9803f13 /app/Models/EntryDAO.php | |
| parent | 39cc1c11ec596176e842cc98e6a54337e3c04d7e (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.php | 24 |
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 { |
