]> git.wh0rd.org Git - tt-rss.git/commitdiff
per-feed update intervals
authorAndrew Dolgov <fox@madoka.spb.ru>
Thu, 13 Oct 2005 03:15:09 +0000 (04:15 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Thu, 13 Oct 2005 03:15:09 +0000 (04:15 +0100)
backend.php
config.php-dist
functions.php
prefs.js
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
tt-rss.css

index b5de559c957cb20faae5684a40bc9396367abbf7..b947a147197d418a79f8b3d46878a44221b007aa 100644 (file)
                if ($subop == "editSave") {
                        $feed_title = db_escape_string($_GET["t"]);
                        $feed_link = db_escape_string($_GET["l"]);
+                       $upd_intl = db_escape_string($_GET["ui"]);
                        $feed_id = $_GET["id"];
 
+                       if (strtoupper($upd_intl) == "DEFAULT")
+                               $upd_intl = 0;
+
                        $result = db_query($link, "UPDATE ttrss_feeds SET 
-                               title = '$feed_title', feed_url = '$feed_link' WHERE id = '$feed_id'");                 
+                               title = '$feed_title', feed_url = '$feed_link',
+                               update_interval = '$upd_intl' WHERE id = '$feed_id'");                  
 
                }
 
                </table>";
 
                $result = db_query($link, "SELECT 
-                               id,title,feed_url,substring(last_updated,1,16) as last_updated
+                               id,title,feed_url,substring(last_updated,1,16) as last_updated,
+                               update_interval
                        FROM 
                                ttrss_feeds ORDER by title");
 
                print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">";
                print "<tr class=\"title\">
                                        <td>&nbsp;</td><td>Select</td><td width=\"40%\">Title</td>
-                                       <td width=\"40%\">Link</td><td>Last updated</td></tr>";
+                                       <td width=\"30%\">Link</td><td width=\"10%\">Update Interval</td>
+                                       <td>Last updated</td></tr>";
                
                $lnum = 0;
                
                                        $line["title"] . "</td>";               
                                print "<td><a href=\"javascript:editFeed($feed_id);\">" . 
                                        $line["feed_url"] . "</td>";            
-                       
+
+                               if ($line["update_interval"] == "0")
+                                       $line["update_interval"] = "Default";
+
+                               print "<td>" . $line["update_interval"] . "</td>";
+
 
                        } else if ($feed_id != $edit_feed_id) {
 
                                print "<td>".$line["title"]."</td>";            
                                print "<td>".$line["feed_url"]."</td>";         
 
+                               if ($line["update_interval"] == "0")
+                                       $line["update_interval"] = "Default";
+
+                               print "<td>" . $line["update_interval"] . "</td>";
+
                        } else {
 
                                print "<td><input disabled=\"true\" type=\"checkbox\"></td>";
 
                                print "<td><input id=\"iedit_title\" value=\"".$line["title"]."\"></td>";
                                print "<td><input id=\"iedit_link\" value=\"".$line["feed_url"]."\"></td>";
-                                               
+                               print "<td><input id=\"iedit_updintl\" value=\"".$line["update_interval"]."\"></td>";
+                                       
                        }
 
                        if (!$line["last_updated"]) $line["last_updated"] = "Never";
index a0940820eeebcbbebdf51de677e6752a37c19e4d..f56fb6dc902dd98dd74933797b986a93cdee95ee 100644 (file)
@@ -30,5 +30,7 @@
        // crafted SQL queries. This feature is highly experimental and
        // at this point not user friendly. Use with caution.
 
+       define(MIN_UPDATE_INTERVAL, 30);
+       // min. interval between feed updates, minutes
 ?>
 
index 0c0fc047febbd057bf73cf950328d81e8ba3cbce..a2e29655b8a84b94ad613465b723a66a74107e6b 100644 (file)
 
                db_query($link, "BEGIN");
 
-               $result = db_query($link, "SELECT feed_url,id,last_updated FROM ttrss_feeds");
+               $result = db_query($link, "SELECT feed_url,id,
+                       substring(last_updated,1,19) as last_updated,
+                       update_interval FROM ttrss_feeds");
 
                while ($line = db_fetch_assoc($result)) {
-//                     if (!$line["last_updated"] || time() - strtotime($line["last_updated"]) > 1800) {
+                       $upd_intl = $line["update_interval"];
+
+                       if (!$upd_intl) $upd_intl = MIN_UPDATE_INTERVAL;
+
+                       if (!$line["last_updated"] || 
+                               time() - strtotime($line["last_updated"]) > ($upd_intl * 60)) {
+                       
                                update_rss_feed($link, $line["feed_url"], $line["id"]);
-//                     }
+                       }
                }
 
                purge_old_posts($link);
index 2d04efedc82e96fc215f4c628c1eee03c73af9bd..1b52776745406337f666267e10d01d39b1d5ab31 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -454,9 +454,16 @@ function feedEditSave() {
 
        var link = document.getElementById("iedit_link").value;
        var title = document.getElementById("iedit_title").value;
+       var upd_intl = document.getElementById("iedit_updintl").value;
 
 //     notify("Saving feed.");
 
+       if (upd_intl < 0) {
+               notify("Update interval must be &gt;= 0 (0 = default)");
+               return;
+       }
+
+
        if (link.length == 0) {
                notify("Feed link cannot be blank.");
                return;
@@ -470,7 +477,8 @@ function feedEditSave() {
        active_feed = false;
 
        xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
-               feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) ,true);
+               feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
+               "&ui=" + param_escape(upd_intl), true);
        xmlhttp.onreadystatechange=feedlist_callback;
        xmlhttp.send(null);
 
index de01f20d611c8474c497e55df5e684d9ecc3f29d..408402c70ed8a1fc527660b1d527a7cef638f80a 100644 (file)
@@ -6,6 +6,7 @@ create table ttrss_feeds (id integer not null auto_increment primary key,
        title varchar(200) not null unique, 
        feed_url varchar(250) unique not null, 
        icon_url varchar(250) not null default '',
+       update_interval integer not null default 0,
        last_updated datetime default '') TYPE=InnoDB;
 
 insert into ttrss_feeds (title,feed_url) values ('Footnotes', 'http://gnomedesktop.org/node/feed');
index 77e88a158c4c2d061d6d549fe7f8e09ec51915e3..085bcc675829296274f77423bf52e5a55408cac4 100644 (file)
@@ -6,6 +6,7 @@ create table ttrss_feeds (id serial not null primary key,
        title varchar(200) not null unique, 
        feed_url varchar(250) unique not null, 
        icon_url varchar(250) not null default '',
+       update_interval integer not null default 0,
        last_updated timestamp default null);
 
 insert into ttrss_feeds (title,feed_url) values ('Footnotes', 'http://gnomedesktop.org/node/feed');
index 079ce827ca84085919829cc4915405f1433308a4..c0380934edecbefed7cbb514404e6c0950bade29 100644 (file)
@@ -204,7 +204,7 @@ a:hover {
        opacity : 0.8;
 }
 
-#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr {
+#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl {
        width : 100%;
        padding-left : 2px;
 }