implement proper last_marked/last_published feeds for proper sorting of

published and marked virtual feeds, remove sorting by last_read
workaround
api: add pubsubhubbub ping when article is being set published
bump schema
This commit is contained in:
Andrew Dolgov 2013-03-17 15:32:44 +04:00
parent f01c8ec4f1
commit 7873d58822
8 changed files with 65 additions and 22 deletions

View File

@ -219,12 +219,15 @@ class API extends Handler {
switch ($field_raw) {
case 0:
$field = "marked";
$additional_fields = ",last_marked = NOW()";
break;
case 1:
$field = "published";
$additional_fields = ",last_published = NOW()";
break;
case 2:
$field = "unread";
$additional_fields = ",last_read = NOW()";
break;
case 3:
$field = "note";
@ -248,14 +251,7 @@ class API extends Handler {
$article_ids = join(", ", $article_ids);
if ($field == "unread") {
$result = db_query($this->link, "UPDATE ttrss_user_entries SET $field = $set_to,
last_read = NOW()
WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]);
} else {
$result = db_query($this->link, "UPDATE ttrss_user_entries SET $field = $set_to
WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]);
}
$result = db_query($this->link, "UPDATE ttrss_user_entries SET $field = $set_to $additional_fields WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]);
$num_updated = db_affected_rows($this->link, $result);
@ -268,6 +264,17 @@ class API extends Handler {
}
}
if ($num_updated > 0 && $field == "published") {
if (PUBSUBHUBBUB_HUB) {
$rss_link = get_self_url_prefix() .
"/public.php?op=rss&id=-2&key=" .
get_feed_access_key($this->link, -2, false);
$p = new Publisher(PUBSUBHUBBUB_HUB);
$pubsub_result = $p->publish_update($rss_link);
}
}
print $this->wrap(self::STATUS_OK, array("status" => "OK",
"updated" => $num_updated));

View File

@ -140,7 +140,8 @@ class RPC extends Handler_Protected {
$mark = "false";
}
$result = db_query($this->link, "UPDATE ttrss_user_entries SET marked = $mark
$result = db_query($this->link, "UPDATE ttrss_user_entries SET marked = $mark,
last_marked = NOW()
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
print json_encode(array("message" => "UPDATE_COUNTERS"));
@ -219,7 +220,7 @@ class RPC extends Handler_Protected {
}
$result = db_query($this->link, "UPDATE ttrss_user_entries SET
published = $pub, last_read = NOW()
published = $pub, last_published = NOW()
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
$pubsub_result = false;
@ -779,15 +780,15 @@ class RPC extends Handler_Protected {
if ($cmode == 0) {
db_query($link, "UPDATE ttrss_user_entries SET
marked = false,last_read = NOW()
marked = false, last_marked = NOW()
WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
} else if ($cmode == 1) {
db_query($link, "UPDATE ttrss_user_entries SET
marked = true
marked = true, last_marked = NOW()
WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
} else {
db_query($link, "UPDATE ttrss_user_entries SET
marked = NOT marked,last_read = NOW()
marked = NOT marked,last_marked = NOW()
WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
}
}
@ -804,15 +805,15 @@ class RPC extends Handler_Protected {
if ($cmode == 0) {
db_query($link, "UPDATE ttrss_user_entries SET
published = false,last_read = NOW()
published = false,last_published = NOW()
WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
} else if ($cmode == 1) {
db_query($link, "UPDATE ttrss_user_entries SET
published = true,last_read = NOW()
published = true,last_published = NOW()
WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
} else {
db_query($link, "UPDATE ttrss_user_entries SET
published = NOT published,last_read = NOW()
published = NOT published,last_published = NOW()
WHERE ($ids_qpart) AND owner_uid = " . $_SESSION["uid"]);
}

View File

@ -1,6 +1,6 @@
<?php
define('EXPECTED_CONFIG_VERSION', 26);
define('SCHEMA_VERSION', 104);
define('SCHEMA_VERSION', 105);
$fetch_last_error = false;
$pluginhost = false;
@ -2310,6 +2310,8 @@
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
$allow_archived = true;
if (!$override_order) $override_order = "last_marked DESC, updated DESC";
} else if ($feed == -2) { // published virtual feed OR labels category
if (!$cat_view) {
@ -2317,7 +2319,7 @@
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
$allow_archived = true;
if (!$override_order) $override_order = "last_read DESC, updated DESC";
if (!$override_order) $override_order = "last_published DESC, updated DESC";
} else {
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
@ -2450,6 +2452,7 @@
comments,
int_id,
unread,feed_id,marked,published,link,last_read,orig_feed_id,
last_marked, last_published,
".SUBSTRING_FOR_DATE."(last_read,1,19) as last_read_noms,
$vfeed_query_part
$content_query_part
@ -2492,6 +2495,7 @@
"label_cache," .
"link," .
"last_read," .
"last_marked, last_published, " .
SUBSTRING_FOR_DATE . "(last_read,1,19) as last_read_noms," .
$since_id_part .
$vfeed_query_part .

View File

@ -766,12 +766,17 @@
}
}
$last_marked = ($marked == 'true') ? 'NOW()' : 'NULL';
$last_published = ($published == 'true') ? 'NOW()' : 'NULL';
$result = db_query($link,
"INSERT INTO ttrss_user_entries
(ref_id, owner_uid, feed_id, unread, last_read, marked,
published, score, tag_cache, label_cache, uuid)
published, score, tag_cache, label_cache, uuid,
last_marked, last_published)
VALUES ('$ref_id', '$owner_uid', '$feed', $unread,
$last_read_qpart, $marked, $published, '$score', '', '', '')");
$last_read_qpart, $marked, $published, '$score', '', '',
'', $last_marked, $last_published)");
if (PUBSUBHUBBUB_HUB && $published == 'true') {
$rss_link = get_self_url_prefix() .

View File

@ -179,6 +179,8 @@ create table ttrss_user_entries (
last_read datetime,
score int not null default 0,
note longtext,
last_marked datetime,
last_published datetime,
unread bool not null default 1,
index (ref_id),
foreign key (ref_id) references ttrss_entries(id) ON DELETE CASCADE,
@ -310,7 +312,7 @@ create table ttrss_tags (id integer primary key auto_increment,
create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
insert into ttrss_version values (104);
insert into ttrss_version values (105);
create table ttrss_enclosures (id integer primary key auto_increment,
content_url text not null,

View File

@ -159,6 +159,8 @@ create table ttrss_user_entries (
label_cache text not null,
last_read timestamp,
score int not null default 0,
last_marked timestamp,
last_published timestamp,
note text,
unread boolean not null default true);
@ -258,7 +260,7 @@ create index ttrss_tags_post_int_id_idx on ttrss_tags(post_int_id);
create table ttrss_version (schema_version int not null);
insert into ttrss_version values (104);
insert into ttrss_version values (105);
create table ttrss_enclosures (id serial not null primary key,
content_url text not null,

View File

@ -0,0 +1,11 @@
begin;
alter table ttrss_user_entries add column last_marked datetime;
alter table ttrss_user_entries add column last_published datetime;
update ttrss_user_entries set last_published = last_read where published = true;
update ttrss_user_entries set last_marked = last_read where marked = true;
update ttrss_version set schema_version = 105;
commit;

View File

@ -0,0 +1,11 @@
begin;
alter table ttrss_user_entries add column last_marked timestamp;
alter table ttrss_user_entries add column last_published timestamp;
update ttrss_user_entries set last_published = last_read where published = true;
update ttrss_user_entries set last_marked = last_read where marked = true;
update ttrss_version set schema_version = 105;
commit;