mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-03 14:32:40 +00:00
Added annotation context to satisfy the TTRSS "has_note" view mode
This commit is contained in:
parent
b595815eb9
commit
b0da9a1d06
4 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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…
Reference in a new issue