]> git.wh0rd.org Git - tt-rss.git/commitdiff
new option - ALLOW_DUPLICATE_POSTS
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 19 Nov 2005 10:32:59 +0000 (11:32 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 19 Nov 2005 10:32:59 +0000 (11:32 +0100)
functions.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql

index 7e2eb90a2459dce950e4b5a978759d66733b764d..78bc8979e4044899d9bfb435efd190f777b55b79 100644 (file)
                        }
                }       
 
+               // purge orphaned posts in main content table
+               db_query($link, "DELETE FROM ttrss_entries WHERE 
+                       (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0");
+
        }
 
        function purge_old_posts($link) {
                                purge_feed($link, $feed_id, $purge_interval);
                        }
                }       
+
+               // purge orphaned posts in main content table
+               db_query($link, "DELETE FROM ttrss_entries WHERE 
+                       (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0");
        }
 
        function update_all_feeds($link, $fetch) {
 
                                                // check for user post link to main table
 
+                                               // do we allow duplicate posts with same GUID in different feeds?
+                                               if (get_pref($link, "ALLOW_DUPLICATE_POSTS")) {
+                                                       $dupcheck_qpart = "AND feed_id = '$feed'";
+                                               } else { 
+                                                       $dupcheck_qpart = "";
+                                               }
+
                                                $result = db_query($link,
                                                        "SELECT ref_id FROM ttrss_user_entries WHERE
-                                                               ref_id = '$ref_id' AND owner_uid = '$owner_uid' AND 
-                                                               feed_id = '$feed'");
+                                                               ref_id = '$ref_id' AND owner_uid = '$owner_uid'
+                                                               $dupcheck_qpart");
 
                                                // okay it doesn't exist - create user entry
-
                                                if (db_num_rows($result) == 0) {
-
                                                        $result = db_query($link,
                                                                "INSERT INTO ttrss_user_entries 
                                                                        (ref_id, owner_uid, feed_id) 
                                                                VALUES ('$ref_id', '$owner_uid', '$feed')");
-
                                                }
                                }
 
index 6851d6170de68b95c44e558792222ee61e9d9525..587890527d19e3c62fe834b5250d455b140706ca 100644 (file)
@@ -169,6 +169,10 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_
 
 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_SPLASH', 1, 'false', 'Enable loading splashscreen',2);
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ALLOW_DUPLICATE_POSTS', 1, 'true', 'Allow duplicate posts',1,
+       'This option is useful when you are reading several planet-type aggregators with partially colliding userbase. 
+       When disabled, it forces same posts from different sources to appear only once');
+
 create table ttrss_user_prefs (
    owner_uid integer not null,
    pref_name varchar(250),
index 0abb81304413bfe836ce04086d55f28707547974..012ed3366ce70717b748392c3e2480d473567af0 100644 (file)
@@ -160,6 +160,10 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_
 
 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_SPLASH', 1, 'false', 'Enable loading splashscreen',2);
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ALLOW_DUPLICATE_POSTS', 1, 'true', 'Allow duplicate posts',1,
+       'This option is useful when you are reading several planet-type aggregators with partially colliding userbase. 
+       When disabled, it forces same posts from different sources to appear only once');
+
 create table ttrss_user_prefs (
        owner_uid integer not null references ttrss_users(id) on delete cascade,
        pref_name varchar(250) not null references ttrss_prefs(pref_name),