summaryrefslogtreecommitdiff
path: root/classes/rssutils.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/rssutils.php')
-rwxr-xr-xclasses/rssutils.php63
1 files changed, 17 insertions, 46 deletions
diff --git a/classes/rssutils.php b/classes/rssutils.php
index 6048c8310..8feffa662 100755
--- a/classes/rssutils.php
+++ b/classes/rssutils.php
@@ -19,51 +19,9 @@ class RSSUtils {
return preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $str);
}
- static function update_feedbrowser_cache() {
-
+ static function cleanup_feed_browser() {
$pdo = Db::pdo();
-
- $sth = $pdo->query("SELECT feed_url, site_url, title, COUNT(id) AS subscribers
- FROM ttrss_feeds WHERE feed_url NOT IN (SELECT feed_url FROM ttrss_feeds
- WHERE private IS true OR auth_login != '' OR auth_pass != '' OR feed_url LIKE '%:%@%/%')
- GROUP BY feed_url, site_url, title ORDER BY subscribers DESC LIMIT 1000");
-
- $pdo->beginTransaction();
-
$pdo->query("DELETE FROM ttrss_feedbrowser_cache");
-
- $count = 0;
-
- while ($line = $sth->fetch()) {
-
- $subscribers = $line["subscribers"];
- $feed_url = $line["feed_url"];
- $title = $line["title"];
- $site_url = $line["site_url"];
-
- $tmph = $pdo->prepare("SELECT subscribers FROM
- ttrss_feedbrowser_cache WHERE feed_url = ?");
- $tmph->execute([$feed_url]);
-
- if (!$tmph->fetch()) {
-
- $tmph = $pdo->prepare("INSERT INTO ttrss_feedbrowser_cache
- (feed_url, site_url, title, subscribers)
- VALUES
- (?, ?, ?, ?)");
-
- $tmph->execute([$feed_url, $site_url, $title, $subscribers]);
-
- ++$count;
-
- }
-
- }
-
- $pdo->commit();
-
- return $count;
-
}
static function update_daemon_common($limit = DAEMON_FEED_LIMIT) {
@@ -1288,6 +1246,20 @@ class RSSUtils {
}
}
+ static function expire_feed_archive() {
+ Debug::log("Removing old archived feeds...");
+
+ $pdo = Db::pdo();
+
+ if (DB_TYPE == "pgsql") {
+ $pdo->query("DELETE FROM ttrss_archived_feeds
+ WHERE created < NOW() - INTERVAL '1 month'");
+ } else {
+ $pdo->query("DELETE FROM ttrss_archived_feeds
+ WHERE created < DATE_SUB(NOW(), INTERVAL 1 MONTH)");
+ }
+ }
+
static function expire_lock_files() {
Debug::log("Removing old lock files...", Debug::$LOG_VERBOSE);
@@ -1526,9 +1498,8 @@ class RSSUtils {
RSSUtils::expire_cached_files();
RSSUtils::expire_lock_files();
RSSUtils::expire_error_log();
-
- $count = RSSUtils::update_feedbrowser_cache();
- Debug::log("Feedbrowser updated, $count feeds processed.");
+ RSSUtils::expire_feed_archive();
+ RSSUtils::cleanup_feed_browser();
Article::purge_orphans();
RSSUtils::cleanup_counters_cache();