mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-04-19 11:55:50 +00:00
Test unread counts in subscriptionList
This commit is contained in:
parent
f635155687
commit
ef3cb4fa54
4 changed files with 50 additions and 8 deletions
|
@ -409,7 +409,7 @@ class Database {
|
|||
arsse_subscriptions.id,
|
||||
url,favicon,source,folder,added,pinned,err_count,err_msg,order_type,
|
||||
CASE WHEN arsse_subscriptions.title is not null THEN arsse_subscriptions.title ELSE arsse_feeds.title END as title,
|
||||
(SELECT count(*) from arsse_articles where feed is arsse_subscriptions.feed) - (SELECT count(*) from (SELECT article,feed from arsse_subscription_articles join arsse_articles on article = arsse_articles.id where owner is ? and feed is arsse_feeds.id and read is 1)) as unread
|
||||
(SELECT count(*) from arsse_articles where feed is arsse_subscriptions.feed) - (SELECT count(*) from (SELECT article,feed from arsse_marks join arsse_articles on article = arsse_articles.id where owner is ? and feed is arsse_feeds.id and read is 1)) as unread
|
||||
from arsse_subscriptions join arsse_feeds on feed = arsse_feeds.id where owner is ?";
|
||||
if(!is_null($folder)) {
|
||||
if(!$this->db->prepare("SELECT count(*) from arsse_folders where owner is ? and id is ?", "str", "int")->run($user, $folder)->getValue()) {
|
||||
|
@ -502,7 +502,7 @@ class Database {
|
|||
}
|
||||
if(sizeof($feed->changedItems)) {
|
||||
$qDeleteCategories = $this->db->prepare('DELETE FROM arsse_categories WHERE article is ?', 'int');
|
||||
$qClearReadMarks = $this->db->prepare('UPDATE arsse_subscription_articles SET read = 0, modified = CURRENT_TIMESTAMP WHERE article is ?', 'int');
|
||||
$qClearReadMarks = $this->db->prepare('UPDATE arsse_marks SET read = 0, modified = CURRENT_TIMESTAMP WHERE article is ?', 'int');
|
||||
$qUpdateArticle = $this->db->prepare(
|
||||
'UPDATE arsse_articles SET url = ?, title = ?, author = ?, published = ?, edited = ?, modified = CURRENT_TIMESTAMP, guid = ?, content = ?, url_title_hash = ?, url_content_hash = ?, title_content_hash = ? WHERE id is ?',
|
||||
'str', 'str', 'str', 'datetime', 'datetime', 'str', 'str', 'str', 'str', 'str', 'int'
|
||||
|
|
|
@ -64,7 +64,7 @@ create table arsse_folders(
|
|||
create table arsse_articles(
|
||||
id integer primary key, -- sequence number
|
||||
feed integer not null references arsse_feeds(id) on delete cascade, -- feed for the subscription
|
||||
url TEXT not null, -- URL of article
|
||||
url TEXT, -- URL of article
|
||||
title TEXT, -- article title
|
||||
author TEXT, -- author's name
|
||||
published datetime, -- time of original publication
|
||||
|
@ -72,9 +72,9 @@ create table arsse_articles(
|
|||
modified datetime not null default CURRENT_TIMESTAMP, -- date when article properties were last modified
|
||||
guid TEXT, -- GUID
|
||||
content TEXT, -- content, as (X)HTML
|
||||
url_title_hash varchar(64), -- hash of URL + title; used when checking for updates and for identification if there is no guid.
|
||||
url_content_hash varchar(64), -- hash of URL + content, enclosure URL, & content type; used when checking for updates and for identification if there is no guid.
|
||||
title_content_hash varchar(64) -- hash of title + content, enclosure URL, & content type; used when checking for updates and for identification if there is no guid.
|
||||
url_title_hash TEXT not null, -- hash of URL + title; used when checking for updates and for identification if there is no guid.
|
||||
url_content_hash TEXT not null, -- hash of URL + content, enclosure URL, & content type; used when checking for updates and for identification if there is no guid.
|
||||
title_content_hash TEXT not null -- hash of title + content, enclosure URL, & content type; used when checking for updates and for identification if there is no guid.
|
||||
);
|
||||
|
||||
-- enclosures associated with articles
|
||||
|
@ -85,7 +85,7 @@ create table arsse_enclosures(
|
|||
);
|
||||
|
||||
-- users' actions on newsfeed entries
|
||||
create table arsse_subscription_articles(
|
||||
create table arsse_marks(
|
||||
id integer primary key,
|
||||
article integer not null references arsse_articles(id) on delete cascade,
|
||||
owner TEXT not null references arsse_users(id) on delete cascade on update cascade,
|
||||
|
|
|
@ -38,6 +38,47 @@ trait SeriesSubscription {
|
|||
[3,"john.doe@example.com",3,"Ook",2],
|
||||
]
|
||||
],
|
||||
'arsse_articles' => [
|
||||
'columns' => [
|
||||
'id' => "int",
|
||||
'feed' => "int",
|
||||
'url_title_hash' => "str",
|
||||
'url_content_hash' => "str",
|
||||
'title_content_hash' => "str",
|
||||
],
|
||||
'rows' => [
|
||||
[1,2,"","",""],
|
||||
[2,2,"","",""],
|
||||
[3,2,"","",""],
|
||||
[4,2,"","",""],
|
||||
[5,2,"","",""],
|
||||
[6,3,"","",""],
|
||||
[7,3,"","",""],
|
||||
[8,3,"","",""],
|
||||
]
|
||||
],
|
||||
'arsse_marks' => [
|
||||
'columns' => [
|
||||
'id' => "int",
|
||||
'article' => "int",
|
||||
'owner' => "str",
|
||||
'read' => "bool",
|
||||
'starred' => "bool",
|
||||
],
|
||||
'rows' => [
|
||||
[1,1,"jane.doe@example.com",true,false],
|
||||
[2,2,"jane.doe@example.com",true,false],
|
||||
[3,3,"jane.doe@example.com",true,false],
|
||||
[4,4,"jane.doe@example.com",true,false],
|
||||
[5,5,"jane.doe@example.com",true,false],
|
||||
[6,6,"jane.doe@example.com",true,false],
|
||||
[7,7,"jane.doe@example.com",true,false],
|
||||
[8,8,"jane.doe@example.com",true,false],
|
||||
[9, 1,"john.doe@example.com",true,false],
|
||||
[10,7,"john.doe@example.com",true,false],
|
||||
[11,8,"john.doe@example.com",true,false],
|
||||
]
|
||||
],
|
||||
];
|
||||
// merge tables
|
||||
$this->data = array_merge($this->data, $data);
|
||||
|
@ -152,11 +193,13 @@ trait SeriesSubscription {
|
|||
'url' => "http://example.com/feed2",
|
||||
'title' => "Eek",
|
||||
'folder' => null,
|
||||
'unread' => 4,
|
||||
],
|
||||
[
|
||||
'url' => "http://example.com/feed3",
|
||||
'title' => "Ook",
|
||||
'folder' => 2,
|
||||
'unread' => 1,
|
||||
],
|
||||
];
|
||||
$this->assertResult($exp, Data::$db->subscriptionList($user));
|
||||
|
|
|
@ -154,7 +154,6 @@ trait Setup {
|
|||
foreach($x as $field => $value) {
|
||||
$valid = true;
|
||||
if(!array_key_exists($field, $r) || $r[$field] !== $value) {
|
||||
echo "$field\n";
|
||||
$valid = false;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue