From 86c4a30744fe838a86572031e6dd5a616ec76104 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Thu, 17 Dec 2020 18:12:52 -0500 Subject: [PATCH] Adjust articleStarred function to discount hidden --- lib/Database.php | 4 ++-- tests/cases/Database/SeriesArticle.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Database.php b/lib/Database.php index 466a0362..55c21e0f 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -1750,7 +1750,7 @@ class Database { return $out; } - /** Returns statistics about the articles starred by the given user + /** Returns statistics about the articles starred by the given user. Hidden articles are excluded * * The associative array returned has the following keys: * @@ -1765,7 +1765,7 @@ class Database { coalesce(sum(abs(\"read\" - 1)),0) as unread, coalesce(sum(\"read\"),0) as \"read\" FROM ( - select \"read\" from arsse_marks where starred = 1 and subscription in (select id from arsse_subscriptions where owner = ?) + select \"read\" from arsse_marks where starred = 1 and hidden <> 1 and subscription in (select id from arsse_subscriptions where owner = ?) ) as starred_data", "str" )->run($user)->getRow(); diff --git a/tests/cases/Database/SeriesArticle.php b/tests/cases/Database/SeriesArticle.php index 37dc10bf..a6b6bdbd 100644 --- a/tests/cases/Database/SeriesArticle.php +++ b/tests/cases/Database/SeriesArticle.php @@ -252,6 +252,7 @@ trait SeriesArticle { [12, 4,1,1,'2017-01-01 00:00:00','ach',0], [1, 2,0,0,'2010-01-01 00:00:00','Some Note',0], [3, 5,0,0,'2000-01-01 00:00:00','',1], + [6, 1,0,1,'2010-01-01 00:00:00','',1], ], ], 'arsse_categories' => [ // author-supplied categories @@ -969,7 +970,7 @@ trait SeriesArticle { $setSize = (new \ReflectionClassConstant(Database::class, "LIMIT_SET_SIZE"))->getValue(); $this->assertSame(2, Arsse::$db->articleCount("john.doe@example.com", (new Context)->starred(true))); $this->assertSame(4, Arsse::$db->articleCount("john.doe@example.com", (new Context)->folder(1))); - $this->assertSame(0, Arsse::$db->articleCount("jane.doe@example.com", (new Context)->starred(true))); + $this->assertSame(1, Arsse::$db->articleCount("jane.doe@example.com", (new Context)->starred(true))); $this->assertSame(10, Arsse::$db->articleCount("john.doe@example.com", (new Context)->articles(range(1, $setSize * 3)))); }