]> git.wh0rd.org Git - tt-rss.git/commitdiff
add ttrss_entries.date_updated; use date_updated instead of date_enered for expiry...
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 27 Oct 2010 08:05:20 +0000 (12:05 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 27 Oct 2010 08:05:20 +0000 (12:05 +0400)
backend.php
functions.php
sanity_check.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/versions/mysql/67.sql [new file with mode: 0644]
schema/versions/pgsql/67.sql [new file with mode: 0644]
utils/xml-export.php
utils/xml-import.php

index 2dd3c5c9b5bb7ffa99bd171a6706d4e5176b8034..4b2202ce8f761fdff0f6a09f7aff17a0946d94c0 100644 (file)
                        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;
 
index dda8d894fd8e49e4dd3cba0bb022ec18f8b21f00..981923573e4f5f3b510946281dac6dbe27cb1c20 100644 (file)
                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);
                                        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 {
 
                                        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);
                
 /*                     $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 
                                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);
 
                                                        content,
                                                        content_hash,
                                                        no_orig_date,
+                                                       date_updated,
                                                        date_entered,
                                                        comments,
                                                        num_comments,
                                                        '$entry_content', 
                                                        '$content_hash',
                                                        $no_orig_date, 
-                                                       NOW(), 
+                                                       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'");
                                }
 
 
                                $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 
                                        $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;
 
        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)";
                }
        }
                                }
 
                                $query = "SELECT DISTINCT 
-                                               date_entered,
+                                               date_updated,
                                                guid,
                                                ttrss_entries.id,ttrss_entries.title,
                                                updated,
                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];
                $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,
                                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 = "";
index b0d7477c75be36164f6d99ccd55a2836334c9242..363c22661d8fa11d7da72778384e8d651cb6c786 100644 (file)
@@ -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 
index 0f4acf900d85dbd4167433a99851de625ee58f58..84eb985d19604e3ad571a21f1685c1418b942fc1 100644 (file)
@@ -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,
index 7225f10f8d30e02f25555ef4d7a61de577514775..ea5465dac9152c20f212cb14d48bdbeada6c8fef 100644 (file)
@@ -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,
diff --git a/schema/versions/mysql/67.sql b/schema/versions/mysql/67.sql
new file mode 100644 (file)
index 0000000..b501bf4
--- /dev/null
@@ -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;
diff --git a/schema/versions/pgsql/67.sql b/schema/versions/pgsql/67.sql
new file mode 100644 (file)
index 0000000..1e2aa44
--- /dev/null
@@ -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;
index 438f008d419ddd2ee85de0af6a27a9bdf9bd9129..6926fd6c2f17bef379cebd800d6eaef73e42de71 100644 (file)
@@ -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,
                                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,
index 0706b0fa2a346f98ca59faf23c868460196e11a2..96201d91ea7f3eba5b81fd2ddce3061d0338da6c 100644 (file)
@@ -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')");
                }