add ttrss_entries.date_updated; use date_updated instead of date_enered for expiry checking (bump schema)
This commit is contained in:
parent
70543b6a40
commit
25ea280502
9 changed files with 48 additions and 30 deletions
|
@ -319,9 +319,9 @@
|
|||
switch ($order_by) {
|
||||
case "date":
|
||||
if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) {
|
||||
$override_order = "date_entered";
|
||||
$override_order = "date_updated";
|
||||
} else {
|
||||
$override_order = "date_entered DESC";
|
||||
$override_order = "date_updated DESC";
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@
|
|||
if (DB_TYPE == "pgsql") {
|
||||
/* $result = db_query($link, "DELETE FROM ttrss_user_entries WHERE
|
||||
marked = false AND feed_id = '$feed_id' AND
|
||||
(SELECT date_entered FROM ttrss_entries WHERE
|
||||
(SELECT date_updated FROM ttrss_entries WHERE
|
||||
id = ref_id) < NOW() - INTERVAL '$purge_interval days'"); */
|
||||
|
||||
$pg_version = get_pgsql_version($link);
|
||||
|
@ -186,7 +186,7 @@
|
|||
marked = false AND
|
||||
feed_id = '$feed_id' AND
|
||||
$query_limit
|
||||
ttrss_entries.date_entered < NOW() - INTERVAL '$purge_interval days'");
|
||||
ttrss_entries.date_updated < NOW() - INTERVAL '$purge_interval days'");
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -196,7 +196,7 @@
|
|||
marked = false AND
|
||||
feed_id = '$feed_id' AND
|
||||
$query_limit
|
||||
ttrss_entries.date_entered < NOW() - INTERVAL '$purge_interval days'");
|
||||
ttrss_entries.date_updated < NOW() - INTERVAL '$purge_interval days'");
|
||||
}
|
||||
|
||||
$rows = pg_affected_rows($result);
|
||||
|
@ -205,7 +205,7 @@
|
|||
|
||||
/* $result = db_query($link, "DELETE FROM ttrss_user_entries WHERE
|
||||
marked = false AND feed_id = '$feed_id' AND
|
||||
(SELECT date_entered FROM ttrss_entries WHERE
|
||||
(SELECT date_updated FROM ttrss_entries WHERE
|
||||
id = ref_id) < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)"); */
|
||||
|
||||
$result = db_query($link, "DELETE FROM ttrss_user_entries
|
||||
|
@ -214,7 +214,7 @@
|
|||
marked = false AND
|
||||
feed_id = '$feed_id' AND
|
||||
$query_limit
|
||||
ttrss_entries.date_entered < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
|
||||
ttrss_entries.date_updated < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
|
||||
|
||||
$rows = mysql_affected_rows($link);
|
||||
|
||||
|
@ -1105,6 +1105,7 @@
|
|||
content,
|
||||
content_hash,
|
||||
no_orig_date,
|
||||
date_updated,
|
||||
date_entered,
|
||||
comments,
|
||||
num_comments,
|
||||
|
@ -1118,18 +1119,19 @@
|
|||
'$content_hash',
|
||||
$no_orig_date,
|
||||
NOW(),
|
||||
NOW(),
|
||||
'$entry_comments',
|
||||
'$num_comments',
|
||||
'$entry_author')");
|
||||
} else {
|
||||
// we keep encountering the entry in feeds, so we need to
|
||||
// update date_entered column so that we don't get horrible
|
||||
// update date_updated column so that we don't get horrible
|
||||
// dupes when the entry gets purged and reinserted again e.g.
|
||||
// in the case of SLOW SLOW OMG SLOW updating feeds
|
||||
|
||||
$base_entry_id = db_fetch_result($result, 0, "id");
|
||||
|
||||
db_query($link, "UPDATE ttrss_entries SET date_entered = NOW()
|
||||
db_query($link, "UPDATE ttrss_entries SET date_updated = NOW()
|
||||
WHERE id = '$base_entry_id'");
|
||||
}
|
||||
|
||||
|
@ -1137,7 +1139,7 @@
|
|||
|
||||
$result = db_query($link, "SELECT
|
||||
id,content_hash,no_orig_date,title,
|
||||
".SUBSTRING_FOR_DATE."(date_entered,1,19) as date_entered,
|
||||
".SUBSTRING_FOR_DATE."(date_updated,1,19) as date_updated,
|
||||
".SUBSTRING_FOR_DATE."(updated,1,19) as updated,
|
||||
num_comments
|
||||
FROM
|
||||
|
@ -1157,8 +1159,8 @@
|
|||
$orig_content_hash = db_fetch_result($result, 0, "content_hash");
|
||||
$orig_title = db_fetch_result($result, 0, "title");
|
||||
$orig_num_comments = db_fetch_result($result, 0, "num_comments");
|
||||
$orig_date_entered = strtotime(db_fetch_result($result,
|
||||
0, "date_entered"));
|
||||
$orig_date_updated = strtotime(db_fetch_result($result,
|
||||
0, "date_updated"));
|
||||
|
||||
$ref_id = db_fetch_result($result, 0, "id");
|
||||
$entry_ref_id = $ref_id;
|
||||
|
@ -2563,10 +2565,10 @@
|
|||
|
||||
function getMaxAgeSubquery($days = COUNTERS_MAX_AGE) {
|
||||
if (DB_TYPE == "pgsql") {
|
||||
return "ttrss_entries.date_entered >
|
||||
return "ttrss_entries.date_updated >
|
||||
NOW() - INTERVAL '$days days'";
|
||||
} else {
|
||||
return "ttrss_entries.date_entered >
|
||||
return "ttrss_entries.date_updated >
|
||||
DATE_SUB(NOW(), INTERVAL $days DAY)";
|
||||
}
|
||||
}
|
||||
|
@ -3576,7 +3578,7 @@
|
|||
}
|
||||
|
||||
$query = "SELECT DISTINCT
|
||||
date_entered,
|
||||
date_updated,
|
||||
guid,
|
||||
ttrss_entries.id,ttrss_entries.title,
|
||||
updated,
|
||||
|
@ -3646,7 +3648,7 @@
|
|||
if (!$limit) $limit = 30;
|
||||
|
||||
$qfh_ret = queryFeedHeadlines($link, $feed,
|
||||
$limit, false, $is_cat, $search, $search_mode, $match_on, "date_entered DESC", 0,
|
||||
$limit, false, $is_cat, $search, $search_mode, $match_on, "date_updated DESC", 0,
|
||||
$owner_uid);
|
||||
|
||||
$result = $qfh_ret[0];
|
||||
|
@ -3888,14 +3890,14 @@
|
|||
$affected_ids = array();
|
||||
|
||||
if (DB_TYPE == "pgsql") {
|
||||
$interval_query = "ttrss_entries.date_entered > NOW() - INTERVAL '$days days'";
|
||||
$interval_query = "ttrss_entries.date_updated > NOW() - INTERVAL '$days days'";
|
||||
} else if (DB_TYPE == "mysql") {
|
||||
$interval_query = "ttrss_entries.date_entered > DATE_SUB(NOW(), INTERVAL $days DAY)";
|
||||
$interval_query = "ttrss_entries.date_updated > DATE_SUB(NOW(), INTERVAL $days DAY)";
|
||||
}
|
||||
|
||||
$result = db_query($link, "SELECT ttrss_entries.title,
|
||||
ttrss_feeds.title AS feed_title,
|
||||
date_entered,
|
||||
date_updated,
|
||||
ttrss_user_entries.ref_id,
|
||||
link,
|
||||
SUBSTRING(content, 1, 120) AS excerpt,
|
||||
|
@ -3908,7 +3910,7 @@
|
|||
AND $interval_query
|
||||
AND ttrss_user_entries.owner_uid = $user_id
|
||||
AND unread = true
|
||||
ORDER BY ttrss_feeds.title, date_entered DESC
|
||||
ORDER BY ttrss_feeds.title, date_updated DESC
|
||||
LIMIT $limit");
|
||||
|
||||
$cur_feed_title = "";
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
require_once "functions.php";
|
||||
|
||||
define('EXPECTED_CONFIG_VERSION', 19);
|
||||
define('SCHEMA_VERSION', 66);
|
||||
define('SCHEMA_VERSION', 67);
|
||||
|
||||
if (!file_exists("config.php")) {
|
||||
print "<b>Fatal Error</b>: You forgot to copy
|
||||
|
|
|
@ -134,6 +134,7 @@ create table ttrss_entries (id integer not null primary key auto_increment,
|
|||
content_hash varchar(250) not null,
|
||||
no_orig_date bool not null default 0,
|
||||
date_entered datetime not null,
|
||||
date_updated datetime not null,
|
||||
num_comments integer not null default 0,
|
||||
comments varchar(250) not null default '',
|
||||
author varchar(250) not null default '') TYPE=InnoDB;
|
||||
|
@ -240,7 +241,7 @@ create table ttrss_tags (id integer primary key auto_increment,
|
|||
|
||||
create table ttrss_version (schema_version int not null) TYPE=InnoDB;
|
||||
|
||||
insert into ttrss_version values (66);
|
||||
insert into ttrss_version values (67);
|
||||
|
||||
create table ttrss_enclosures (id integer primary key auto_increment,
|
||||
content_url text not null,
|
||||
|
|
|
@ -117,7 +117,8 @@ create table ttrss_entries (id serial not null primary key,
|
|||
content text not null,
|
||||
content_hash varchar(250) not null,
|
||||
no_orig_date boolean not null default false,
|
||||
date_entered timestamp not null default NOW(),
|
||||
date_entered timestamp not null,
|
||||
date_updated timestamp not null,
|
||||
num_comments integer not null default 0,
|
||||
comments varchar(250) not null default '',
|
||||
author varchar(250) not null default '');
|
||||
|
@ -212,7 +213,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
|
|||
|
||||
create table ttrss_version (schema_version int not null);
|
||||
|
||||
insert into ttrss_version values (66);
|
||||
insert into ttrss_version values (67);
|
||||
|
||||
create table ttrss_enclosures (id serial not null primary key,
|
||||
content_url text not null,
|
||||
|
|
5
schema/versions/mysql/67.sql
Normal file
5
schema/versions/mysql/67.sql
Normal file
|
@ -0,0 +1,5 @@
|
|||
alter table ttrss_entries add column date_updated datetime;
|
||||
update ttrss_entries set date_updated = date_entered;
|
||||
alter table ttrss_entries change date_updated date_updated datetime not null;
|
||||
|
||||
update ttrss_version set schema_version = 67;
|
9
schema/versions/pgsql/67.sql
Normal file
9
schema/versions/pgsql/67.sql
Normal file
|
@ -0,0 +1,9 @@
|
|||
begin;
|
||||
|
||||
alter table ttrss_entries add column date_updated timestamp;
|
||||
update ttrss_entries set date_updated = date_entered;
|
||||
alter table ttrss_entries alter column date_updated set not null;
|
||||
|
||||
update ttrss_version set schema_version = 67;
|
||||
|
||||
commit;
|
|
@ -97,7 +97,7 @@
|
|||
updated,
|
||||
guid,
|
||||
link,
|
||||
SUBSTRING(date_entered,1,16) AS date_entered,
|
||||
SUBSTRING(date_updated,1,16) AS date_updated,
|
||||
SUBSTRING(last_read,1,16) AS last_read,
|
||||
comments,
|
||||
ttrss_feeds.feed_url AS feed_url,
|
||||
|
@ -118,7 +118,7 @@
|
|||
updated,
|
||||
guid,
|
||||
link,
|
||||
SUBSTRING(date_entered,1,16) AS date_entered,
|
||||
SUBSTRING(date_updated,1,16) AS date_updated,
|
||||
SUBSTRING(last_read,1,16) AS last_read,
|
||||
comments,
|
||||
ttrss_feeds.feed_url AS feed_url,
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
$entry_guid = db_escape_string($data["guid"]);
|
||||
$entry_link = db_escape_string($data["link"]);
|
||||
$updated = db_escape_string($data["updated"]);
|
||||
$date_entered = db_escape_string($data["date_entered"]);
|
||||
$date_updated = db_escape_string($data["date_updated"]);
|
||||
$entry_content = db_escape_string($data["content"]);
|
||||
$content_hash = "SHA1:" . sha1(strip_tags($entry_content));
|
||||
$entry_comments = db_escape_string($data["comments"]);
|
||||
|
@ -77,7 +77,7 @@
|
|||
content,
|
||||
content_hash,
|
||||
no_orig_date,
|
||||
date_entered,
|
||||
date_updated,
|
||||
comments)
|
||||
VALUES
|
||||
('$entry_title',
|
||||
|
@ -87,7 +87,7 @@
|
|||
'$entry_content',
|
||||
'$content_hash',
|
||||
false,
|
||||
'$date_entered',
|
||||
'$date_updated',
|
||||
'$entry_comments')");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue