Browse Source

Added annotation context to satisfy the TTRSS "has_note" view mode

microsub
J. King 7 years ago
parent
commit
b0da9a1d06
  1. 4
      lib/Database.php
  2. 5
      lib/Misc/Context.php
  3. 1
      tests/Misc/TestContext.php
  4. 4
      tests/lib/Database/SeriesArticle.php

4
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;
}

5
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);
}
}

1
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;

4
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() {

Loading…
Cancel
Save