Skip to content

A platform for community discussion. Free, open, simple.

FIX: Add time retention limit to search logs

riking38a8e52ca492
diff --git a/app/models/search_log.rb b/app/models/search_log.rb
index c74d97bb0fb..2d818dbe74d 100644
--- a/app/models/search_log.rb
+++ b/app/models/search_log.rb
@@ -134,6 +134,7 @@ class SearchLog < ActiveRecord::Base
if search_id.present?
SearchLog.where('id < ?', search_id[0]).delete_all
end
+ SearchLog.where('created_at < TIMESTAMP ?', SiteSetting.search_query_log_max_retention_days.days.ago).delete_all
end
end
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 9214cc324dd..aa81d9773cb 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -1069,6 +1069,7 @@ en:
search_recent_posts_size: "How many recent posts to keep in the index"
log_search_queries: "Log search queries performed by users"
search_query_log_max_size: "Maximum amount of search queries to keep"
+ search_query_log_max_retention_days: "Maximum amount of time to keep search queries, in days. Default is 3 years (1095 days)."
allow_uncategorized_topics: "Allow topics to be created without a category. WARNING: If there are any uncategorized topics, you must recategorize them before turning this off."
allow_duplicate_topic_titles: "Allow topics with identical, duplicate titles."
unique_posts_mins: "How many minutes before a user can make a post with the same content again"
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 1d8f9555e75..7ee7e1cb358 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -1362,6 +1362,9 @@ search:
search_query_log_max_size:
default: 1000000
max: 1000000
+ search_query_log_max_retention_days:
+ default: 1095 # 3 years
+ max: 1825 # 5 years
uncategorized:
version_checks: