From: Andrew Dolgov Date: Fri, 16 Jan 2009 09:47:12 +0000 (+0100) Subject: move feedbrowser cache code to functions.php X-Git-Tag: 1.3.0~164 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=5e96ca9df247ad24845531bf53f7fce4707a07c5;p=tt-rss.git move feedbrowser cache code to functions.php --- diff --git a/functions.php b/functions.php index 593edaf1..47335688 100644 --- a/functions.php +++ b/functions.php @@ -5903,4 +5903,34 @@ } } } + + function update_feedbrowser_cache($link) { + + $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers + FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf + WHERE tf.feed_url = ttrss_feeds.feed_url + AND (private IS true OR feed_url LIKE '%:%@%/%')) + GROUP BY feed_url ORDER BY subscribers DESC"); + + db_query($link, "BEGIN"); + + db_query($link, "DELETE FROM ttrss_feedbrowser_cache"); + + $count = 0; + + while ($line = db_fetch_assoc($result)) { + $subscribers = db_escape_string($line["subscribers"]); + $feed_url = db_escape_string($line["feed_url"]); + + db_query($link, "INSERT INTO ttrss_feedbrowser_cache + (feed_url, subscribers) VALUES ('$feed_url', '$subscribers')"); + + ++$count; + } + + db_query($link, "COMMIT"); + + return $count; + + } ?> diff --git a/update_feedbrowser.php b/update_feedbrowser.php index b64bb256..4698918d 100644 --- a/update_feedbrowser.php +++ b/update_feedbrowser.php @@ -38,29 +38,7 @@ init_connection($link); - $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers - FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf - WHERE tf.feed_url = ttrss_feeds.feed_url - AND (private IS true OR feed_url LIKE '%:%@%/%')) - GROUP BY feed_url ORDER BY subscribers DESC"); - - db_query($link, "BEGIN"); - - db_query($link, "DELETE FROM ttrss_feedbrowser_cache"); - - $count = 0; - - while ($line = db_fetch_assoc($result)) { - $subscribers = db_escape_string($line["subscribers"]); - $feed_url = db_escape_string($line["feed_url"]); - - db_query($link, "INSERT INTO ttrss_feedbrowser_cache - (feed_url, subscribers) VALUES ('$feed_url', '$subscribers')"); - - ++$count; - } - - db_query($link, "COMMIT"); + $count = update_feedbrowser_cache($link); print "Finished, $count feeds processed.\n";