1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00

Add ability to sort by folder ID or name

This commit is contained in:
J. King 2021-02-02 11:51:19 -05:00
parent ed27e0aaaa
commit a43f8797c5
4 changed files with 14 additions and 5 deletions

View file

@ -49,6 +49,8 @@ For convenience the patterns are tested after collapsing whitespace. Unlike Mini
Nextcloud News' root folder and Tiny Tiny RSS' "Uncategorized" catgory are mapped to Miniflux's initial "All" category. This Miniflux category can be renamed, but it cannot be deleted. Attempting to do so will delete the child feeds it contains, but not the category itself. Nextcloud News' root folder and Tiny Tiny RSS' "Uncategorized" catgory are mapped to Miniflux's initial "All" category. This Miniflux category can be renamed, but it cannot be deleted. Attempting to do so will delete the child feeds it contains, but not the category itself.
Because the root folder does not existing in the database as a separate entity, it will always sort first when ordering by `category_id` or `category_title`.
# Interaction with nested categories # Interaction with nested categories
Tiny Tiny RSS is unique in allowing newsfeeds to be grouped into categories nested to arbitrary depth. When newsfeeds are placed into nested categories, they simply appear in the top-level category when accessed via the Miniflux protocol. This does not affect OPML exports, where full nesting is preserved. Tiny Tiny RSS is unique in allowing newsfeeds to be grouped into categories nested to arbitrary depth. When newsfeeds are placed into nested categories, they simply appear in the top-level category when accessed via the Miniflux protocol. This does not affect OPML exports, where full nesting is preserved.

View file

@ -1461,6 +1461,9 @@ class Database {
'guid' => "arsse_articles.guid", // The GUID of the article, as presented in the feed (NOTE: Picofeed actually provides a hash of the ID) 'guid' => "arsse_articles.guid", // The GUID of the article, as presented in the feed (NOTE: Picofeed actually provides a hash of the ID)
'fingerprint' => "arsse_articles.url_title_hash || ':' || arsse_articles.url_content_hash || ':' || arsse_articles.title_content_hash", // A combination of three hashes 'fingerprint' => "arsse_articles.url_title_hash || ':' || arsse_articles.url_content_hash || ':' || arsse_articles.title_content_hash", // A combination of three hashes
'folder' => "coalesce(arsse_subscriptions.folder,0)", // The folder of the article's feed. This is mainly for use in WHERE clauses 'folder' => "coalesce(arsse_subscriptions.folder,0)", // The folder of the article's feed. This is mainly for use in WHERE clauses
'top_folder' => "coalesce(folder_data.top,0)", // The top-most folder of the article's feed. This is mainly for use in WHERE clauses
'folder_name' => "folder_data.name", // The name of the folder of the article's feed. This is mainly for use in WHERE clauses
'top_folder_name' => "folder_data.top_name", // The name of the top-most folder of the article's feed. This is mainly for use in WHERE clauses
'subscription' => "arsse_subscriptions.id", // The article's parent subscription 'subscription' => "arsse_subscriptions.id", // The article's parent subscription
'feed' => "arsse_subscriptions.feed", // The article's parent feed 'feed' => "arsse_subscriptions.feed", // The article's parent feed
'hidden' => "coalesce(arsse_marks.hidden,0)", // Whether the article is hidden 'hidden' => "coalesce(arsse_marks.hidden,0)", // Whether the article is hidden
@ -1537,6 +1540,7 @@ class Database {
from arsse_articles from arsse_articles
join arsse_subscriptions on arsse_subscriptions.feed = arsse_articles.feed and arsse_subscriptions.owner = ? join arsse_subscriptions on arsse_subscriptions.feed = arsse_articles.feed and arsse_subscriptions.owner = ?
join arsse_feeds on arsse_subscriptions.feed = arsse_feeds.id join arsse_feeds on arsse_subscriptions.feed = arsse_feeds.id
left join folder_data on arsse_subscriptions.folder = folder_data.id
left join arsse_marks on arsse_marks.subscription = arsse_subscriptions.id and arsse_marks.article = arsse_articles.id left join arsse_marks on arsse_marks.subscription = arsse_subscriptions.id and arsse_marks.article = arsse_articles.id
left join arsse_enclosures on arsse_enclosures.article = arsse_articles.id left join arsse_enclosures on arsse_enclosures.article = arsse_articles.id
join ( join (
@ -1548,6 +1552,8 @@ class Database {
["str", "str"], ["str", "str"],
[$user, $user] [$user, $user]
); );
$q->setCTE("topmost(f_id,top)", "SELECT id,id from arsse_folders where owner = ? and parent is null union all select id,top from arsse_folders join topmost on parent=f_id", ["str"], [$user]);
$q->setCTE("folder_data(id,name,top,top_name)", "SELECT f1.id, f1.name, top, f2.name from arsse_folders as f1 join topmost on f1.id = f_id join arsse_folders as f2 on f2.id = top");
$q->setLimit($context->limit, $context->offset); $q->setLimit($context->limit, $context->offset);
// handle the simple context options // handle the simple context options
$options = [ $options = [
@ -1788,9 +1794,9 @@ class Database {
$order = $col[1] ?? ""; $order = $col[1] ?? "";
$col = $col[0]; $col = $col[0];
if ($order === "desc") { if ($order === "desc") {
$order = " desc"; $order = " ".$this->db->sqlToken("desc");
} elseif ($order === "asc" || $order === "") { } elseif ($order === "asc" || $order === "") {
$order = ""; $order = " ".$this->db->sqlToken("asc");
} else { } else {
// column direction spec is bogus // column direction spec is bogus
continue; continue;

View file

@ -936,9 +936,9 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
} elseif ($query['order'] === "published_at") { } elseif ($query['order'] === "published_at") {
$order = ["modified_date".$desc]; $order = ["modified_date".$desc];
} elseif ($query['order'] === "category_title") { } elseif ($query['order'] === "category_title") {
$order = []; // TODO $order = ["top_folder_name".$desc];
} elseif ($query['order'] === "catgory_id") { } elseif ($query['order'] === "catgory_id") {
$order = []; //TODO $order = ["top_folder".$desc];
} else { } else {
$order = []; $order = [];
} }

View file

@ -408,8 +408,9 @@ trait SeriesArticle {
], ],
]; ];
$this->fields = [ $this->fields = [
"id", "subscription", "feed", "modified_date", "marked_date", "unread", "starred", "edition", "edited_date", "id", "subscription", "feed", "modified_date", "marked_date", "unread", "starred", "hidden", "edition", "edited_date",
"url", "title", "subscription_title", "author", "guid", "published_date", "fingerprint", "url", "title", "subscription_title", "author", "guid", "published_date", "fingerprint",
"folder", "top_folder", "folder_name", "top_folder_name",
"content", "media_url", "media_type", "content", "media_url", "media_type",
"note", "note",
]; ];