From d148926e2b96602707a4b012966e943e865d48d2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 13 Oct 2005 04:15:09 +0100 Subject: [PATCH] per-feed update intervals --- backend.php | 28 +++++++++++++++++++++++----- config.php-dist | 2 ++ functions.php | 14 +++++++++++--- prefs.js | 10 +++++++++- schema/ttrss_schema_mysql.sql | 1 + schema/ttrss_schema_pgsql.sql | 1 + tt-rss.css | 2 +- 7 files changed, 48 insertions(+), 10 deletions(-) diff --git a/backend.php b/backend.php index b5de559c..b947a147 100644 --- a/backend.php +++ b/backend.php @@ -693,10 +693,15 @@ 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'"); } @@ -743,14 +748,16 @@ "; $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 "

"; print " - "; + + "; $lnum = 0; @@ -787,7 +794,12 @@ $line["title"] . ""; print ""; - + + if ($line["update_interval"] == "0") + $line["update_interval"] = "Default"; + + print ""; + } else if ($feed_id != $edit_feed_id) { @@ -797,13 +809,19 @@ print ""; print ""; + if ($line["update_interval"] == "0") + $line["update_interval"] = "Default"; + + print ""; + } else { print ""; print ""; print ""; - + print ""; + } if (!$line["last_updated"]) $line["last_updated"] = "Never"; diff --git a/config.php-dist b/config.php-dist index a0940820..f56fb6dc 100644 --- a/config.php-dist +++ b/config.php-dist @@ -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 ?> diff --git a/functions.php b/functions.php index 0c0fc047..a2e29655 100644 --- a/functions.php +++ b/functions.php @@ -24,12 +24,20 @@ 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); diff --git a/prefs.js b/prefs.js index 2d04efed..1b527767 100644 --- 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 >= 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); diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index de01f20d..408402c7 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -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'); diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index 77e88a15..085bcc67 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -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'); diff --git a/tt-rss.css b/tt-rss.css index 079ce827..c0380934 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -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; } -- 2.39.5
 SelectTitleLinkLast updated
LinkUpdate IntervalLast updated
" . $line["feed_url"] . "" . $line["update_interval"] . "".$line["title"]."".$line["feed_url"]."" . $line["update_interval"] . "