diff options
author | Andrew Dolgov <[email protected]> | 2010-11-13 19:59:42 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2010-11-13 19:59:42 +0300 |
commit | 868650e463d5803006fabad47931ca5797ba250c (patch) | |
tree | a87d73248ad514411e3f43f18d90a3835debff7f /functions.php | |
parent | d3204726a56471bf8f7add5fd38db6dd149fb022 (diff) |
implement automatic tags table maintenance
Diffstat (limited to 'functions.php')
-rw-r--r-- | functions.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/functions.php b/functions.php index 553b26563..2331c89f4 100644 --- a/functions.php +++ b/functions.php @@ -5798,6 +5798,10 @@ purge_orphans($link); + $rc = cleanup_tags($link, 14, 50000); + + if ($debug) _debug("$rc uncached tags cleaned."); + } // function update_daemon_common function sanitize_article_content($text) { @@ -7137,4 +7141,22 @@ return $ids; } + function cleanup_tags($link, $days = 14, $limit = 1000) { + + if (DB_TYPE == "pgsql") { + $interval_query = "date_updated < NOW() - INTERVAL '$days days'"; + } else if (DB_TYPE == "mysql") { + $interval_query = "date_updated < DATE_SUB(NOW(), INTERVAL $days DAY)"; + } + + $query = "SELECT ttrss_tags.id AS id + FROM ttrss_tags, ttrss_user_entries, ttrss_entries + WHERE post_int_id = int_id AND $interval_query AND + ref_id = ttrss_entries.id AND tag_cache != '' LIMIT $limit"; + + $result = db_query($link, $query); + + return db_affected_rows($link, $result); + } + ?> |