mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-23 06:34:55 +00:00
Added oldestArticle and latestArticle context options
This commit is contained in:
parent
50185ab8f6
commit
2037efce61
4 changed files with 22 additions and 1 deletions
|
@ -917,7 +917,13 @@ class Database {
|
||||||
}
|
}
|
||||||
$q->setWhere("exists(select article from arsse_label_members where assigned is 1 and article is arsse_articles.id and label is ?)", "int", $id);
|
$q->setWhere("exists(select article from arsse_label_members where assigned is 1 and article is arsse_articles.id and label is ?)", "int", $id);
|
||||||
}
|
}
|
||||||
// filter based on edition offset
|
// filter based on article or edition offset
|
||||||
|
if ($context->oldestArticle()) {
|
||||||
|
$q->setWhere("arsse_articles.id >= ?", "int", $context->oldestArticle);
|
||||||
|
}
|
||||||
|
if ($context->latestArticle()) {
|
||||||
|
$q->setWhere("arsse_articles.id <= ?", "int", $context->latestArticle);
|
||||||
|
}
|
||||||
if ($context->oldestEdition()) {
|
if ($context->oldestEdition()) {
|
||||||
$q->setWhere("edition >= ?", "int", $context->oldestEdition);
|
$q->setWhere("edition >= ?", "int", $context->oldestEdition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ class Context {
|
||||||
public $folder;
|
public $folder;
|
||||||
public $folderShallow;
|
public $folderShallow;
|
||||||
public $subscription;
|
public $subscription;
|
||||||
|
public $oldestArticle;
|
||||||
|
public $latestArticle;
|
||||||
public $oldestEdition;
|
public $oldestEdition;
|
||||||
public $latestEdition;
|
public $latestEdition;
|
||||||
public $unread = null;
|
public $unread = null;
|
||||||
|
@ -81,6 +83,14 @@ class Context {
|
||||||
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function latestArticle(int $spec = null) {
|
||||||
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function oldestArticle(int $spec = null) {
|
||||||
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
||||||
|
}
|
||||||
|
|
||||||
public function latestEdition(int $spec = null) {
|
public function latestEdition(int $spec = null) {
|
||||||
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@ class TestContext extends Test\AbstractTest {
|
||||||
'subscription' => 2112,
|
'subscription' => 2112,
|
||||||
'article' => 255,
|
'article' => 255,
|
||||||
'edition' => 65535,
|
'edition' => 65535,
|
||||||
|
'latestArticle' => 47,
|
||||||
|
'oldestArticle' => 1337,
|
||||||
'latestEdition' => 47,
|
'latestEdition' => 47,
|
||||||
'oldestEdition' => 1337,
|
'oldestEdition' => 1337,
|
||||||
'unread' => true,
|
'unread' => true,
|
||||||
|
|
|
@ -411,6 +411,9 @@ trait SeriesArticle {
|
||||||
$this->compareIds([19], (new Context)->subscription(5)->latestEdition(19));
|
$this->compareIds([19], (new Context)->subscription(5)->latestEdition(19));
|
||||||
$this->compareIds([20], (new Context)->subscription(5)->oldestEdition(999));
|
$this->compareIds([20], (new Context)->subscription(5)->oldestEdition(999));
|
||||||
$this->compareIds([20], (new Context)->subscription(5)->oldestEdition(1001));
|
$this->compareIds([20], (new Context)->subscription(5)->oldestEdition(1001));
|
||||||
|
// get items relative to article ID
|
||||||
|
$this->compareIds([1,2,3], (new Context)->latestArticle(3));
|
||||||
|
$this->compareIds([19,20], (new Context)->oldestArticle(19));
|
||||||
// get items relative to (feed) modification date
|
// get items relative to (feed) modification date
|
||||||
$exp = [2,4,6,8,20];
|
$exp = [2,4,6,8,20];
|
||||||
$this->compareIds($exp, (new Context)->modifiedSince("2005-01-01T00:00:00Z"));
|
$this->compareIds($exp, (new Context)->modifiedSince("2005-01-01T00:00:00Z"));
|
||||||
|
|
Loading…
Reference in a new issue