From 70e71b8364c1317af04f92fd86df4541fa269e0c Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 3 Jan 2024 11:23:06 +0100 Subject: Auto-label (#5954) Add labels automatically to incoming articles fix https://github.com/FreshRSS/FreshRSS/issues/2380 fix https://github.com/FreshRSS/FreshRSS/issues/2420 fix https://github.com/FreshRSS/FreshRSS/issues/3279 fix https://github.com/FreshRSS/FreshRSS/discussions/4947 fix https://github.com/FreshRSS/FreshRSS/issues/5728 fix https://github.com/FreshRSS/FreshRSS/issues/5599 --- app/Models/EntryDAO.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'app/Models/EntryDAO.php') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 232db8521..b809c7475 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -95,7 +95,7 @@ SQL; private $addEntryPrepared = false; /** @param array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,'lastSeen':int,'hash':string, - * 'is_read':bool|int|null,'is_favorite':bool|int|null,'id_feed':int,'tags':string,'attributes':array} $valuesTmp */ + * 'is_read':bool|int|null,'is_favorite':bool|int|null,'id_feed':int,'tags':string,'attributes'?:null|string|array} $valuesTmp */ public function addEntry(array $valuesTmp, bool $useTmpTable = true): bool { if ($this->addEntryPrepared == null) { $sql = static::sqlIgnoreConflict( @@ -693,19 +693,22 @@ SQL; } /** @return Traversable}> */ - public function selectAll(): Traversable { + * 'hash':string,'is_read':bool,'is_favorite':bool,'id_feed':int,'tags':string,'attributes':?string}> */ + public function selectAll(?int $limit = null): Traversable { $content = static::isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content'; $hash = static::sqlHexEncode('hash'); $sql = <<= 0) { + $sql .= ' ORDER BY id DESC LIMIT ' . $limit; + } $stm = $this->pdo->query($sql); if ($stm != false) { while ($row = $stm->fetch(PDO::FETCH_ASSOC)) { /** @var array{'id':string,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int,'lastSeen':int, - * 'hash':string,'is_read':?bool,'is_favorite':?bool,'id_feed':int,'tags':string,'attributes':array} $row */ + * 'hash':string,'is_read':bool,'is_favorite':bool,'id_feed':int,'tags':string,'attributes':?string} $row */ yield $row; } } else { @@ -727,7 +730,7 @@ FROM `_entry` WHERE id_feed=:id_feed AND guid=:guid SQL; $res = $this->fetchAssoc($sql, [':id_feed' => $id_feed, ':guid' => $guid]); /** @var array $res */ + * 'is_read':int,'is_favorite':int,'tags':string,'attributes':?string}> $res */ return isset($res[0]) ? FreshRSS_Entry::fromArray($res[0]) : null; } @@ -740,7 +743,7 @@ FROM `_entry` WHERE id=:id SQL; $res = $this->fetchAssoc($sql, [':id' => $id]); /** @var array $res */ + * 'is_read':int,'is_favorite':int,'tags':string,'attributes':?string}> $res */ return isset($res[0]) ? FreshRSS_Entry::fromArray($res[0]) : null; } @@ -1167,7 +1170,7 @@ SQL; while ($row = $stm->fetch(PDO::FETCH_ASSOC)) { if (is_array($row)) { /** @var array{'id':string,'id_feed':int,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int, - * 'hash':string,'is_read':int,'is_favorite':int,'tags':string,'attributes'?:string} $row */ + * 'hash':string,'is_read':int,'is_favorite':int,'tags':string,'attributes'?:?string} $row */ yield FreshRSS_Entry::fromArray($row); } } @@ -1212,7 +1215,7 @@ SQL; while ($row = $stm->fetch(PDO::FETCH_ASSOC)) { if (is_array($row)) { /** @var array{'id':string,'id_feed':int,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int, - * 'hash':string,'is_read':int,'is_favorite':int,'tags':string,'attributes'?:string} $row */ + * 'hash':string,'is_read':int,'is_favorite':int,'tags':string,'attributes':?string} $row */ yield FreshRSS_Entry::fromArray($row); } } -- cgit v1.2.3