mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Further simplifications
This commit is contained in:
parent
0bd01849bb
commit
2489743d0f
2 changed files with 9 additions and 12 deletions
|
@ -1449,6 +1449,7 @@ class Database {
|
||||||
*/
|
*/
|
||||||
protected function articleColumns(): array {
|
protected function articleColumns(): array {
|
||||||
$greatest = $this->db->sqlToken("greatest");
|
$greatest = $this->db->sqlToken("greatest");
|
||||||
|
$least = $this->db->sqlToken("least");
|
||||||
return [
|
return [
|
||||||
'id' => "arsse_articles.id", // The article's unchanging numeric ID
|
'id' => "arsse_articles.id", // The article's unchanging numeric ID
|
||||||
'edition' => "latest_editions.edition", // The article's numeric ID which increases each time it is modified in the feed
|
'edition' => "latest_editions.edition", // The article's numeric ID which increases each time it is modified in the feed
|
||||||
|
@ -1468,6 +1469,8 @@ class Database {
|
||||||
'hidden' => "coalesce(arsse_marks.hidden,0)", // Whether the article is hidden
|
'hidden' => "coalesce(arsse_marks.hidden,0)", // Whether the article is hidden
|
||||||
'starred' => "coalesce(arsse_marks.starred,0)", // Whether the article is starred
|
'starred' => "coalesce(arsse_marks.starred,0)", // Whether the article is starred
|
||||||
'unread' => "abs(coalesce(arsse_marks.read,0) - 1)", // Whether the article is unread
|
'unread' => "abs(coalesce(arsse_marks.read,0) - 1)", // Whether the article is unread
|
||||||
|
'labelled' => "$least(coalesce(label_stats.assigned,0),1)", // Whether the article has at least one label
|
||||||
|
'annotated' => "(case when coalesce(arsse_marks.note,'') <> '' then 1 else 0 end)", // Whether the article has a note
|
||||||
'note' => "coalesce(arsse_marks.note,'')", // The article's note, if any
|
'note' => "coalesce(arsse_marks.note,'')", // The article's note, if any
|
||||||
'published_date' => "arsse_articles.published", // The date at which the article was first published i.e. its creation date
|
'published_date' => "arsse_articles.published", // The date at which the article was first published i.e. its creation date
|
||||||
'edited_date' => "arsse_articles.edited", // The date at which the article was last edited according to the feed
|
'edited_date' => "arsse_articles.edited", // The date at which the article was last edited according to the feed
|
||||||
|
@ -1536,7 +1539,7 @@ class Database {
|
||||||
$q = new Query(
|
$q = new Query(
|
||||||
"WITH RECURSIVE
|
"WITH RECURSIVE
|
||||||
folders(id,req) as (
|
folders(id,req) as (
|
||||||
select * from (select 0,0 union select f.id,f.id from arsse_folders as f where owner = ?) union all select f.id,req from arsse_folders as f join folders on coalesce(parent,0)=folders.id
|
select 0, 0 union all select f.id, f.id from arsse_folders as f where owner = ? union all select f1.id, req from arsse_folders as f1 join folders on coalesce(parent,0)=folders.id
|
||||||
),
|
),
|
||||||
folders_top(id,top) as (
|
folders_top(id,top) as (
|
||||||
select f.id, f.id from arsse_folders as f where owner = ? and parent is null union all select f.id, top from arsse_folders as f join folders_top as t on parent=t.id
|
select f.id, f.id from arsse_folders as f where owner = ? and parent is null union all select f.id, top from arsse_folders as f join folders_top as t on parent=t.id
|
||||||
|
@ -1586,6 +1589,8 @@ class Database {
|
||||||
"unread" => ["unread", "=", "bool"],
|
"unread" => ["unread", "=", "bool"],
|
||||||
"starred" => ["starred", "=", "bool"],
|
"starred" => ["starred", "=", "bool"],
|
||||||
"hidden" => ["hidden", "=", "bool"],
|
"hidden" => ["hidden", "=", "bool"],
|
||||||
|
"labelled" => ["labelled", "=", "bool"],
|
||||||
|
"annotated" => ["annotated", "=", "bool"],
|
||||||
];
|
];
|
||||||
foreach ($options as $m => [$col, $op, $type]) {
|
foreach ($options as $m => [$col, $op, $type]) {
|
||||||
if (!$context->$m()) {
|
if (!$context->$m()) {
|
||||||
|
@ -1682,16 +1687,6 @@ class Database {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// handle context options with more than one operator
|
|
||||||
if ($context->annotated()) {
|
|
||||||
$comp = ($context->annotated) ? "<>" : "=";
|
|
||||||
$q->setWhere("coalesce(arsse_marks.note,'') $comp ''");
|
|
||||||
}
|
|
||||||
if ($context->labelled()) {
|
|
||||||
// any label (true) or no label (false)
|
|
||||||
$op = $context->labelled ? ">" : "=";
|
|
||||||
$q->setWhere("coalesce(label_stats.assigned,0) $op 0");
|
|
||||||
}
|
|
||||||
// handle text-matching context options
|
// handle text-matching context options
|
||||||
$options = [
|
$options = [
|
||||||
"titleTerms" => ["title"],
|
"titleTerms" => ["title"],
|
||||||
|
|
|
@ -120,6 +120,8 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
|
||||||
switch (strtolower($token)) {
|
switch (strtolower($token)) {
|
||||||
case "greatest":
|
case "greatest":
|
||||||
return "max";
|
return "max";
|
||||||
|
case "least":
|
||||||
|
return "min";
|
||||||
case "asc":
|
case "asc":
|
||||||
return "";
|
return "";
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue