From 5d73494a182fb58518e6e64f7877c3fe7d71eaf8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 16 Nov 2005 10:37:50 +0100 Subject: [PATCH] per-feed purge intervals --- backend.php | 34 +++++++++++++++++++++++++++------- functions.php | 31 ++++++++++++++++++++++++++++--- prefs.js | 7 ++++++- tt-rss.css | 3 ++- 4 files changed, 63 insertions(+), 12 deletions(-) diff --git a/backend.php b/backend.php index 3a155090..7781828a 100644 --- a/backend.php +++ b/backend.php @@ -816,14 +816,20 @@ $feed_title = db_escape_string($_GET["t"]); $feed_link = db_escape_string($_GET["l"]); $upd_intl = db_escape_string($_GET["ui"]); + $purge_intl = db_escape_string($_GET["pi"]); $feed_id = $_GET["id"]; if (strtoupper($upd_intl) == "DEFAULT") $upd_intl = 0; + if (strtoupper($purge_intl) == "DEFAULT") + $purge_intl = 0; + $result = db_query($link, "UPDATE ttrss_feeds SET title = '$feed_title', feed_url = '$feed_link', - update_interval = '$upd_intl' WHERE id = '$feed_id'"); + update_interval = '$upd_intl', + purge_interval = '$purge_intl' + WHERE id = '$feed_id'"); } @@ -892,14 +898,16 @@ $result = db_query($link, "SELECT id,title,feed_url,substring(last_updated,1,16) as last_updated, - update_interval + update_interval,purge_interval FROM ttrss_feeds ORDER by title"); print "

"; print " - - + + + + "; $lnum = 0; @@ -937,15 +945,21 @@ type=\"checkbox\" id=\"FRCHK-".$line["id"]."\">"; print ""; + $edit_title . ""; print ""; + $edit_link . ""; if ($line["update_interval"] == "0") $line["update_interval"] = "Default"; - print ""; + print ""; + if ($line["purge_interval"] == "0") + $line["purge_interval"] = "Default"; + + print ""; } else if ($feed_id != $edit_feed_id) { @@ -960,6 +974,11 @@ print ""; + if ($line["purge_interval"] == "0") + $line["purge_interval"] = "Default"; + + print ""; + } else { print ""; @@ -967,6 +986,7 @@ print ""; print ""; print ""; + print ""; } diff --git a/functions.php b/functions.php index 28cbb1cd..4ab9ac7d 100644 --- a/functions.php +++ b/functions.php @@ -4,18 +4,43 @@ define('MAGPIE_OUTPUT_ENCODING', 'UTF-8'); function purge_old_posts($link) { + + $result = db_query($link, "SELECT id,purge_interval FROM ttrss_feeds"); + + while ($line = db_fetch_assoc($result)) { + + $feed_id = $line["id"]; + $purge_interval = $line["purge_interval"]; + + if ($purge_interval == 0) $purge_interval = PURGE_OLD_DAYS; + + if ($purge_interval != 0) { + + if (DB_TYPE == "pgsql") { + db_query($link, "DELETE FROM ttrss_entries WHERE + marked = false AND feed_id = '$feed_id' AND + date_entered < NOW() - INTERVAL '$purge_interval days'"); + } else { + db_query($link, "DELETE FROM ttrss_entries WHERE + marked = false AND AND feed_id = '$feed_id' AND + date_entered < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)"); + } + } + } + + /* if (PURGE_OLD_DAYS > 0) { if (DB_TYPE == "pgsql") { $result = db_query($link, "DELETE FROM ttrss_entries WHERE - marked = false AND + marked = false AND feed_id = '$feed_id' AND date_entered < NOW() - INTERVAL '".PURGE_OLD_DAYS." days'"); } else { $result = db_query($link, "DELETE FROM ttrss_entries WHERE - marked = false AND + marked = false AND AND feed_id = '$feed_id' AND date_entered < DATE_SUB(NOW(), INTERVAL ".PURGE_OLD_DAYS." DAY)"); } - } + } */ } function update_all_feeds($link, $fetch) { diff --git a/prefs.js b/prefs.js index 0f545b7f..5c6f7a7f 100644 --- a/prefs.js +++ b/prefs.js @@ -462,6 +462,7 @@ function feedEditSave() { var link = document.getElementById("iedit_link").value; var title = document.getElementById("iedit_title").value; var upd_intl = document.getElementById("iedit_updintl").value; + var purge_intl = document.getElementById("iedit_purgintl").value; // notify("Saving feed."); @@ -470,6 +471,10 @@ function feedEditSave() { return; } + if (purge_intl < 0) { + notify("Purge days must be >= 0 (0 = default)"); + return; + } if (link.length == 0) { notify("Feed link cannot be blank."); @@ -485,7 +490,7 @@ function feedEditSave() { xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" + feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) + - "&ui=" + param_escape(upd_intl), true); + "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl), true); xmlhttp.onreadystatechange=feedlist_callback; xmlhttp.send(null); diff --git a/tt-rss.css b/tt-rss.css index ed5796eb..933575ab 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -240,7 +240,8 @@ a:hover { opacity : 0.8; } -#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl { +#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl, +#iedit_purgintl { width : 100%; padding-left : 2px; } -- 2.39.5
 SelectTitleLinkUpdate Interval SelectTitleLinkUpdate IntervalPurge Days Last updated
" . - $edit_title . "" . - $edit_link . "" . $line["update_interval"] . "" . + $line["update_interval"] . "" . + $line["purge_interval"] . "" . $line["update_interval"] . "" . $line["purge_interval"] . "