diff --git a/lib/Database.php b/lib/Database.php index 48ea6b8..d67f386 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -944,6 +944,10 @@ class Database { if ($context->starred()) { $q->setWhere("starred is ?", "bool", $context->starred); } + // filter based on whether the article has a note + if ($context->annotated()) { + $q->setWhere((!$context->annotated ? "not " : "")."exists(select modified from arsse_marks where article is arsse_articles.id and note <> '' and subscription in (select sub from subscribed_feeds))"); + } // return the query return $q; } diff --git a/lib/Misc/Context.php b/lib/Misc/Context.php index edc9fb4..b36a032 100644 --- a/lib/Misc/Context.php +++ b/lib/Misc/Context.php @@ -31,6 +31,7 @@ class Context { public $label; public $labelName; public $labelled = null; + public $annotated = null; protected $props = []; @@ -149,4 +150,8 @@ class Context { public function labelled(bool $spec = null) { return $this->act(__FUNCTION__, func_num_args(), $spec); } + + public function annotated(bool $spec = null) { + return $this->act(__FUNCTION__, func_num_args(), $spec); + } } diff --git a/tests/Misc/TestContext.php b/tests/Misc/TestContext.php index 6626bf5..13f11b7 100644 --- a/tests/Misc/TestContext.php +++ b/tests/Misc/TestContext.php @@ -45,6 +45,7 @@ class TestContext extends Test\AbstractTest { 'label' => 2112, 'labelName' => "Rush", 'labelled' => true, + 'annotated' => true, ]; $times = ['modifiedSince','notModifiedSince','markedSince','notMarkedSince']; $c = new Context; diff --git a/tests/lib/Database/SeriesArticle.php b/tests/lib/Database/SeriesArticle.php index ec24d72..afab611 100644 --- a/tests/lib/Database/SeriesArticle.php +++ b/tests/lib/Database/SeriesArticle.php @@ -212,6 +212,7 @@ trait SeriesArticle { [11, 20,1,0,'2017-01-01 00:00:00','eek'], [12, 3,0,1,'2017-01-01 00:00:00','ack'], [12, 4,1,1,'2017-01-01 00:00:00','ach'], + [1, 2,0,0,'2010-01-01 00:00:00','Some Note'], ] ], 'arsse_labels' => [ @@ -447,6 +448,9 @@ trait SeriesArticle { // get multiple specific articles or editions $this->compareIds([1,20], (new Context)->articles([1,20,50])); $this->compareIds([1,20], (new Context)->editions([1,1001,50])); + // get articles base on whether or not they have notes + $this->compareIds([1,3,4,5,6,7,8,19,20], (new Context)->annotated(false)); + $this->compareIds([2], (new Context)->annotated(true)); } public function testListArticlesOfAMissingFolder() {