/** Returns the current (actual) schema version of the database; compared against self::SCHEMA_VERSION to know when an upgrade is required */
@ -748,7 +752,7 @@ class Database {
i.url as favicon,
t.top as top_folder,
coalesce(s.title, f.title) as title,
coalesce((articles - hidden - marked + hidden_marked), articles) as unread
coalesce((articles - hidden - marked), articles) as unread
FROM arsse_subscriptions as s
left join topmost as t on t.f_id = s.folder
join arsse_feeds as f on f.id = s.feed
@ -757,9 +761,8 @@ class Database {
left join (
select
subscription,
sum(cast((\"read\" = 1 and hidden = 0) as integer)) as marked,
sum(cast((\"read\" = 0 and hidden = 1) as integer)) as hidden,
sum(cast((\"read\" = 1 and hidden = 1) as integer)) as hidden_marked
sum(hidden) as hidden,
sum(cast((\"read\" = 1 and hidden = 0) as integer)) as marked
from arsse_marks group by subscription
) as mark_stats on mark_stats.subscription = s.id"
);
@ -1206,12 +1209,11 @@ class Database {
* Each record includes the following keys:
*
* - "owner": The user for whom to apply the filters
* - "sub": The subscription ID which ties the user to the feed
* - "keep": The "keep" rule; any articles which fail to match this rule are hidden
* - "block": The block rule; any article which matches this rule are hidden
*/
public function feedRulesGet(int $feedID): Db\Result {
return $this->db->prepare("SELECT owner, id as sub, keep_rule as keep, block_rule as block from arsse_subscriptions where feed = ? and (coalesce(keep_rule, '') || coalesce(block_rule, '')) <> ''", "int")->run($feedID);
return $this->db->prepare("SELECT owner, keep_rule as keep, block_rule as block from arsse_subscriptions where feed = ? and (coalesce(keep_rule, '') || coalesce(block_rule, '')) <> ''", "int")->run($feedID);
}
/** Retrieves various identifiers for the latest $count articles in the given newsfeed. The identifiers are:
assert(strlen($outColumns) > 0, new \Exception("No input columns matched whitelist"));
// define the basic query, to which we add lots of stuff where necessary
$q = new Query(
"SELECT
@ -1895,14 +1899,8 @@ class Database {
/** Returns the numeric identifier of the most recent edition of an article matching the given context */
public function editionLatest(string $user, Context $context = null): int {
$context = $context ?? new Context;
$q = new Query("SELECT max(arsse_editions.id) from arsse_editions left join arsse_articles on article = arsse_articles.id join arsse_subscriptions on arsse_articles.feed = arsse_subscriptions.feed and arsse_subscriptions.owner = ?", "str", $user);
if ($context->subscription()) {
// if a subscription is specified, make sure it exists
$out = $this->db->prepare("SELECT article from arsse_label_members join arsse_labels on label = id where assigned = 1 and $field = ? and owner = ? order by article", $type, "str")->run($id, $user)->getAll();