mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Properly revert edition querying
This commit is contained in:
parent
770e8fc98d
commit
04d26fc911
2 changed files with 5 additions and 41 deletions
|
@ -1650,9 +1650,12 @@ class Database {
|
|||
// handle the simple context options
|
||||
$options = [
|
||||
// each context array consists of a column identifier (see $colDefs above), a comparison operator, and a data type; the "between" operator has special handling
|
||||
"edition" => ["edition", "=", "int"],
|
||||
"editions" => ["edition", "in", "int"],
|
||||
"article" => ["id", "=", "int"],
|
||||
"articles" => ["id", "in", "int"],
|
||||
"articleRange" => ["id", "between", "int"],
|
||||
"editionRange" => ["edition", "between", "int"],
|
||||
"modifiedRange" => ["modified_date", "between", "datetime"],
|
||||
"markedRange" => ["marked_date", "between", "datetime"],
|
||||
"folderShallow" => ["folder", "=", "int"],
|
||||
|
@ -1808,45 +1811,6 @@ class Database {
|
|||
}
|
||||
}
|
||||
}
|
||||
// handle edition-related selections
|
||||
if ($context->edition()) {
|
||||
$q->setWhere("{$colDefs['id']} = (select article from arsse_editions where id = ?)", "int", $context->edition);
|
||||
}
|
||||
if ($context->not->edition()) {
|
||||
$q->setWhereNot("{$colDefs['id']} = (select article from arsse_editions where id = ?)", "int", $context->not->edition);
|
||||
}
|
||||
if ($context->editions()) {
|
||||
[$inClause, $inTypes, $inValues] = $this->generateIn($context->editions, "int");
|
||||
$q->setWhere("{$colDefs['id']} in (select article from arsse_editions where id in ($inClause))", $inTypes, $inValues);
|
||||
}
|
||||
if ($context->not->editions()) {
|
||||
[$inClause, $inTypes, $inValues] = $this->generateIn($context->not->editions, "int");
|
||||
$q->setWhereNot("{$colDefs['id']} in (select article from arsse_editions where id in ($inClause))", $inTypes, $inValues);
|
||||
}
|
||||
if ($context->editionRange()) {
|
||||
if ($context->editionRange[0] === null) {
|
||||
// range is open at the low end
|
||||
$q->setWhere("{$colDefs['id']} in (select article from arsse_editions where id <= ?)", "int", $context->editionRange[1]);
|
||||
} elseif ($context->editionRange[1] === null) {
|
||||
// range is open at the high end
|
||||
$q->setWhere("{$colDefs['id']} in (select article from arsse_editions where id >= ?)", "int", $context->editionRange[0]);
|
||||
} else {
|
||||
// range is bounded in both directions
|
||||
$q->setWhere("{$colDefs['id']} in (select article from arsse_editions where id between ? and ?)", ["int", "int"], $context->editionRange);
|
||||
}
|
||||
}
|
||||
if ($context->not->editionRange()) {
|
||||
if ($context->not->editionRange[0] === null) {
|
||||
// range is open at the low end
|
||||
$q->setWhereNot("{$colDefs['id']} in (select article from arsse_editions where id <= ?)", "int", $context->not->editionRange[1]);
|
||||
} elseif ($context->not->editionRange[1] === null) {
|
||||
// range is open at the high end
|
||||
$q->setWhereNot("{$colDefs['id']} in (select article from arsse_editions where id >= ?)", "int", $context->not->editionRange[0]);
|
||||
} else {
|
||||
// range is bounded in both directions
|
||||
$q->setWhereNot("{$colDefs['id']} in (select article from arsse_editions where id between ? and ?)", ["int", "int"], $context->not->editionRange);
|
||||
}
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ trait SeriesArticle {
|
|||
'Not hidden' => [(new Context)->hidden(false), [1,2,3,4,5,7,8,19,20]],
|
||||
'Labelled' => [(new Context)->labelled(true), [1,5,8,19,20]],
|
||||
'Not labelled' => [(new Context)->labelled(false), [2,3,4,6,7]],
|
||||
'Not after edition 999' => [(new Context)->subscription(5)->editionRange(null, 999), [19, 20]],
|
||||
'Not after edition 999' => [(new Context)->subscription(5)->editionRange(null, 999), [19]],
|
||||
'Not after edition 19' => [(new Context)->subscription(5)->editionRange(null, 19), [19]],
|
||||
'Not before edition 999' => [(new Context)->subscription(5)->editionRange(999, null), [20]],
|
||||
'Not before edition 1001' => [(new Context)->subscription(5)->editionRange(1001, null), [20]],
|
||||
|
@ -435,7 +435,7 @@ trait SeriesArticle {
|
|||
'With label "Fascinating"' => [(new Context)->labelName("Fascinating"), [1,5,20]],
|
||||
'With label "Interesting" or "Fascinating"' => [(new Context)->labelNames(["Interesting","Fascinating"]), [1,5,19,20]],
|
||||
'Article ID 20' => [(new Context)->article(20), [20]],
|
||||
'Edition ID 20' => [(new Context)->edition(20), [20]],
|
||||
'Edition ID 20' => [(new Context)->edition(20), []],
|
||||
'Edition ID 1001' => [(new Context)->edition(1001), [20]],
|
||||
'Multiple articles' => [(new Context)->articles([1,20,50]), [1,20]],
|
||||
'Multiple starred articles' => [(new Context)->articles([1,2,3])->starred(true), [1]],
|
||||
|
|
Loading…
Reference in a new issue