From 3a1cd1ec8e9918c3eed94d1ad61f01fc50b07161 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 24 Aug 2007 18:27:29 +0100 Subject: [PATCH] UNDO: new option: COUNTERS_MAX_AGE --- config.php-dist | 5 ---- functions.php | 64 ++++++++++--------------------------------------- 2 files changed, 13 insertions(+), 56 deletions(-) diff --git a/config.php-dist b/config.php-dist index 0cd257be..3f48c542 100644 --- a/config.php-dist +++ b/config.php-dist @@ -163,11 +163,6 @@ // to any feeds using HTTP Digest authentication and Magpie XML parsing // errors are bothering you too much, you can try enabling SimplePie. - define('COUNTERS_MAX_AGE', 365); - // Hard limit for unread counters calculation. Try tweaking this - // parameter to speed up tt-rss when having a huge number of articles - // in the database (better yet, enable purging!) - define('CONFIG_VERSION', 9); // Expected config version. Please update this option in config.php // if necessary (after migrating all new options from this file). diff --git a/functions.php b/functions.php index 026a5caa..89863f06 100644 --- a/functions.php +++ b/functions.php @@ -1900,11 +1900,8 @@ print ""; - $age_qpart = getMaxAgeSubquery(); - $result = db_query($link, "SELECT cat_id,SUM((SELECT COUNT(int_id) - FROM ttrss_user_entries, ttrss_entries WHERE feed_id = ttrss_feeds.id - AND id = ref_id AND $age_qpart + FROM ttrss_user_entries WHERE feed_id = ttrss_feeds.id AND unread = true)) AS unread FROM ttrss_feeds WHERE hidden = false AND owner_uid = ".$_SESSION["uid"]." GROUP BY cat_id"); @@ -1925,9 +1922,7 @@ } else { $cat_query = "cat_id IS NULL"; } - - $age_qpart = getMaxAgeSubquery(); - + $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE $cat_query AND hidden = false AND owner_uid = " . $_SESSION["uid"]); @@ -1942,9 +1937,8 @@ $match_part = implode(" OR ", $cat_feeds); $result = db_query($link, "SELECT COUNT(int_id) AS unread - FROM ttrss_user_entries,ttrss_entries - WHERE unread = true AND ($match_part) AND id = ref_id - AND $age_qpart AND owner_uid = " . $_SESSION["uid"]); + FROM ttrss_user_entries + WHERE unread = true AND ($match_part) AND owner_uid = " . $_SESSION["uid"]); $unread = 0; @@ -1971,21 +1965,9 @@ } } - function getMaxAgeSubquery($days = COUNTERS_MAX_AGE) { - if (DB_TYPE == "pgsql") { - return "ttrss_entries.date_entered > - NOW() - INTERVAL '$days days'"; - } else { - return "ttrss_entries.date_entered > - DATE_SUB(NOW(), INTERVAL $days DAY)"; - } - } - function getFeedUnread($link, $feed, $is_cat = false) { $n_feed = sprintf("%d", $feed); - $age_qpart = getMaxAgeSubquery(); - if ($is_cat) { return getCategoryUnread($link, $n_feed); } else if ($n_feed == -1) { @@ -2022,12 +2004,9 @@ $match_part = implode(" OR ", $linked_feeds); $result = db_query($link, "SELECT COUNT(int_id) AS unread - FROM ttrss_user_entries,ttrss_entries - WHERE unread = true AND - ttrss_user_entries.ref_id = ttrss_entries.id AND - $age_qpart AND - ($match_part) AND - owner_uid = " . $_SESSION["uid"]); + FROM ttrss_user_entries + WHERE unread = true AND ($match_part) + AND owner_uid = " . $_SESSION["uid"]); $unread = 0; @@ -2058,15 +2037,13 @@ ttrss_user_entries.feed_id = ttrss_feeds.id AND ttrss_user_entries.ref_id = ttrss_entries.id AND ttrss_feeds.hidden = false AND - $age_qpart AND unread = true AND ($match_part) AND ttrss_user_entries.owner_uid = " . $_SESSION["uid"]); } else { $result = db_query($link, "SELECT COUNT(post_int_id) AS unread - FROM ttrss_tags,ttrss_user_entries,ttrss_entries - WHERE tag_name = '$feed' AND post_int_id = int_id AND ref_id = id - AND unread = true AND $age_qpart AND + FROM ttrss_tags,ttrss_user_entries + WHERE tag_name = '$feed' AND post_int_id = int_id AND unread = true AND ttrss_tags.owner_uid = " . $_SESSION["uid"]); } @@ -2083,14 +2060,11 @@ $user_id = $_SESSION["uid"]; } - $age_qpart = getMaxAgeSubquery(); - $result = db_query($link, "SELECT count(ttrss_entries.id) as c_id FROM ttrss_entries,ttrss_user_entries,ttrss_feeds WHERE unread = true AND ttrss_user_entries.feed_id = ttrss_feeds.id AND ttrss_user_entries.ref_id = ttrss_entries.id AND hidden = false AND - $age_qpart AND ttrss_user_entries.owner_uid = '$user_id'"); $c_id = db_fetch_result($result, 0, "c_id"); return $c_id; @@ -2134,11 +2108,8 @@ select tag_name,0 as count FROM ttrss_tags WHERE ttrss_tags.owner_uid = ".$_SESSION["uid"]); */ - $age_qpart = getMaxAgeSubquery(); - $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id) - FROM ttrss_user_entries,ttrss_entries WHERE int_id = post_int_id - AND ref_id = id AND $age_qpart + FROM ttrss_user_entries WHERE int_id = post_int_id AND unread = true)) AS count FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']." GROUP BY tag_name ORDER BY count DESC LIMIT 55"); @@ -2170,8 +2141,6 @@ function getLabelCounters($link, $smart_mode = SMART_RPC_COUNTERS, $ret_mode = false) { - $age_qpart = getMaxAgeSubquery(); - if ($smart_mode) { if (!$_SESSION["lctr_last_value"]) { $_SESSION["lctr_last_value"] = array(); @@ -2225,7 +2194,6 @@ $tmp_result = db_query($link, "SELECT count(ttrss_entries.id) as count FROM ttrss_user_entries,ttrss_entries,ttrss_feeds WHERE (" . $line["sql_exp"] . ") AND unread = true AND ttrss_feeds.hidden = false AND - $age_qpart AND ttrss_user_entries.feed_id = ttrss_feeds.id AND ttrss_user_entries.ref_id = ttrss_entries.id AND ttrss_user_entries.owner_uid = ".$_SESSION["uid"]); @@ -2270,8 +2238,6 @@ function getFeedCounters($link, $smart_mode = SMART_RPC_COUNTERS) { - $age_qpart = getMaxAgeSubquery(); - if ($smart_mode) { if (!$_SESSION["fctr_last_value"]) { $_SESSION["fctr_last_value"] = array(); @@ -2299,7 +2265,7 @@ AND ttrss_user_entries.owner_uid = ttrss_feeds.owner_uid AND ttrss_user_entries.unread = true) LEFT JOIN ttrss_entries ON (ttrss_user_entries.ref_id = ttrss_entries.id) - WHERE ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND $age_qpart + WHERE ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND parent_feed IS NULL GROUP BY ttrss_feeds.id, ttrss_feeds.title, ttrss_feeds.last_updated, last_error"); @@ -2322,11 +2288,10 @@ $has_img = is_file(ICONS_DIR . "/$id.ico"); $tmp_result = db_query($link, - "SELECT ttrss_feeds.id,COUNT(unread) AS unread + "SELECT id,COUNT(unread) AS unread FROM ttrss_feeds LEFT JOIN ttrss_user_entries ON (ttrss_feeds.id = ttrss_user_entries.feed_id) - LEFT JOIN ttrss_entries ON (ttrss_user_entries.ref_id = ttrss_entries.id) - WHERE parent_feed = '$id' AND $age_qpart AND unread = true GROUP BY ttrss_feeds.id"); + WHERE parent_feed = '$id' AND unread = true GROUP BY ttrss_feeds.id"); if (db_num_rows($tmp_result) > 0) { while ($l = db_fetch_assoc($tmp_result)) { @@ -3687,13 +3652,10 @@ } } - $age_qpart = getMaxAgeSubquery(); - $result = db_query($link, "SELECT ttrss_feeds.*, SUBSTRING(last_updated,1,19) AS last_updated_noms, (SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries WHERE feed_id = ttrss_feeds.id AND unread = true - AND $age_qpart AND ttrss_user_entries.ref_id = ttrss_entries.id AND owner_uid = '$owner_uid') as unread, cat_id,last_error, -- 2.39.5