From 1186ba1109f5bd431461051426faec53c32cdb2a Mon Sep 17 00:00:00 2001 From: Noikoio Date: Fri, 8 Mar 2019 18:53:57 -0800 Subject: [PATCH] Add automatic MessageCache cleanup on startup --- RegexBot/Module/ModLogs/MessageCache.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/RegexBot/Module/ModLogs/MessageCache.cs b/RegexBot/Module/ModLogs/MessageCache.cs index 00bb39f..da0b05e 100644 --- a/RegexBot/Module/ModLogs/MessageCache.cs +++ b/RegexBot/Module/ModLogs/MessageCache.cs @@ -278,6 +278,14 @@ namespace Noikoio.RegexBot.Module.ModLogs + ")"; c.ExecuteNonQuery(); } + + // For lack of an automated mechanism, delete old messages on startup here. + using (var c = db.CreateCommand()) + { + c.CommandText = "DELETE FROM " + TableMessage + " WHERE " + + "coalesce(edited_ts, created_ts) < (now() - interval '90 days')"; + c.ExecuteNonQuery(); + } } }