FIX: Add time retention limit to search logs

3 years is a very conservative limit that allows for a very wide buffer
for year-over-year analysis. The max is set to 5 years because that is
the policy listed for logging in hosted Discourse.
This commit is contained in:
riking 2018-05-21 11:56:51 -07:00 committed by Sam
parent 1de0ef137e
commit 38a8e52ca4
3 changed files with 5 additions and 0 deletions

View File

@ -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

View File

@ -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"

View File

@ -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: