Browse Source

Adjust articleStarred function to discount hidden

rpm
J. King 3 years ago
parent
commit
86c4a30744
  1. 4
      lib/Database.php
  2. 3
      tests/cases/Database/SeriesArticle.php

4
lib/Database.php

@ -1750,7 +1750,7 @@ class Database {
return $out; 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: * The associative array returned has the following keys:
* *
@ -1765,7 +1765,7 @@ class Database {
coalesce(sum(abs(\"read\" - 1)),0) as unread, coalesce(sum(abs(\"read\" - 1)),0) as unread,
coalesce(sum(\"read\"),0) as \"read\" coalesce(sum(\"read\"),0) as \"read\"
FROM ( 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", ) as starred_data",
"str" "str"
)->run($user)->getRow(); )->run($user)->getRow();

3
tests/cases/Database/SeriesArticle.php

@ -252,6 +252,7 @@ trait SeriesArticle {
[12, 4,1,1,'2017-01-01 00:00:00','ach',0], [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], [1, 2,0,0,'2010-01-01 00:00:00','Some Note',0],
[3, 5,0,0,'2000-01-01 00:00:00','',1], [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 'arsse_categories' => [ // author-supplied categories
@ -969,7 +970,7 @@ trait SeriesArticle {
$setSize = (new \ReflectionClassConstant(Database::class, "LIMIT_SET_SIZE"))->getValue(); $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(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(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)))); $this->assertSame(10, Arsse::$db->articleCount("john.doe@example.com", (new Context)->articles(range(1, $setSize * 3))));
} }

Loading…
Cancel
Save