Skip to content

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

DEV: update composer similar topics limit (#32934)

David Battersby6d42d95341ef
diff --git a/app/models/topic.rb b/app/models/topic.rb
index a2119c430c0..310521256ff 100644
--- a/app/models/topic.rb
+++ b/app/models/topic.rb
@@ -706,9 +706,10 @@ class Topic < ActiveRecord::Base
end
MAX_SIMILAR_BODY_LENGTH = 200
+ SIMILAR_TOPIC_SEARCH_LIMIT = 10
+ SIMILAR_TOPIC_LIMIT = 3
def self.similar_to(title, raw, user = nil)
- return [] if SiteSetting.max_similar_results == 0
return [] if title.blank?
raw = raw.presence || ""
@@ -759,7 +760,7 @@ class Topic < ActiveRecord::Base
.where("c.topic_id IS NULL")
.where("topics.category_id NOT IN (#{excluded_category_ids_sql})")
.order("ts_rank(search_data, #{tsquery}) DESC")
- .limit(SiteSetting.max_similar_results * 3)
+ .limit(SIMILAR_TOPIC_SEARCH_LIMIT)
candidate_ids = candidates.pluck(:id)
@@ -770,7 +771,7 @@ class Topic < ActiveRecord::Base
.joins("JOIN posts AS p ON p.topic_id = topics.id AND p.post_number = 1")
.where("topics.id IN (?)", candidate_ids)
.order("similarity DESC")
- .limit(SiteSetting.max_similar_results)
+ .limit(SIMILAR_TOPIC_LIMIT)
if raw.present?
similars.select(
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index e8217cf4069..213a5416d8f 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -2255,7 +2255,6 @@ en:
authorized_extensions: "A list of file extensions allowed for upload"
authorized_extensions_for_staff: "A list of file extensions allowed for upload for staff users in addition to the list defined in the `authorized_extensions` site setting."
theme_authorized_extensions: "A list of file extensions allowed for theme uploads"
- max_similar_results: "How many similar topics to show above the editor when composing a new topic. Comparison is based on title and body."
max_image_megapixels: "Maximum number of megapixels allowed for an image. Images with a higher number of megapixels will be rejected."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 01ba3985aec..9fb0a929ff8 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -3180,9 +3180,6 @@ uncategorized:
validator: "RegexpListValidator"
area: "permalinks"
- max_similar_results:
- default: 5
- area: "posts_and_topics"
minimum_topics_similar:
default: 50
area: "posts_and_topics"