implement automatic tags table maintenance
This commit is contained in:
parent
d3204726a5
commit
868650e463
|
@ -5798,6 +5798,10 @@
|
||||||
|
|
||||||
purge_orphans($link);
|
purge_orphans($link);
|
||||||
|
|
||||||
|
$rc = cleanup_tags($link, 14, 50000);
|
||||||
|
|
||||||
|
if ($debug) _debug("$rc uncached tags cleaned.");
|
||||||
|
|
||||||
} // function update_daemon_common
|
} // function update_daemon_common
|
||||||
|
|
||||||
function sanitize_article_content($text) {
|
function sanitize_article_content($text) {
|
||||||
|
@ -7137,4 +7141,22 @@
|
||||||
return $ids;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
print " -feeds - update feeds\n";
|
print " -feeds - update feeds\n";
|
||||||
print " -feedbrowser - update feedbrowser\n";
|
print " -feedbrowser - update feedbrowser\n";
|
||||||
print " -daemon - start single-process update daemon\n";
|
print " -daemon - start single-process update daemon\n";
|
||||||
|
print " -cleanup-tags - perform tags table maintenance\n";
|
||||||
print " -help - show this help\n";
|
print " -help - show this help\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -89,6 +90,11 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($op == "-cleanup-tags") {
|
||||||
|
$rc = cleanup_tags($link, 14, 50000);
|
||||||
|
print "$rc tags deleted.\n";
|
||||||
|
}
|
||||||
|
|
||||||
db_close($link);
|
db_close($link);
|
||||||
|
|
||||||
unlink(LOCK_DIRECTORY . "/$lock_filename");
|
unlink(LOCK_DIRECTORY . "/$lock_filename");
|
||||||
|
|
Loading…
Reference in New Issue