mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Change very high/low search priority to rank at absolute ends.
Prior to this change, we had weights for very_high, high, low and very_low. This means there were 4 weights to tweak and what weights to use for `very_high/high` and `very_low/low` pair was hard to explain. This change makes it such that `very_high` search priority will always ensure that the posts are ranked at the top while `very_low` search priority will ensure that the posts are ranked at the very bottom.
This commit is contained in:
@@ -1019,17 +1019,25 @@ class Search
|
||||
)
|
||||
SQL
|
||||
|
||||
category_search_priority = <<~SQL
|
||||
(
|
||||
CASE categories.search_priority
|
||||
WHEN #{Searchable::PRIORITIES[:very_high]}
|
||||
THEN 3
|
||||
WHEN #{Searchable::PRIORITIES[:very_low]}
|
||||
THEN 1
|
||||
ELSE 2
|
||||
END
|
||||
)
|
||||
SQL
|
||||
|
||||
category_priority_weights = <<~SQL
|
||||
(
|
||||
CASE categories.search_priority
|
||||
WHEN #{Searchable::PRIORITIES[:very_low]}
|
||||
THEN #{SiteSetting.category_search_priority_very_low_weight}
|
||||
WHEN #{Searchable::PRIORITIES[:low]}
|
||||
THEN #{SiteSetting.category_search_priority_low_weight}
|
||||
WHEN #{Searchable::PRIORITIES[:high]}
|
||||
THEN #{SiteSetting.category_search_priority_high_weight}
|
||||
WHEN #{Searchable::PRIORITIES[:very_high]}
|
||||
THEN #{SiteSetting.category_search_priority_very_high_weight}
|
||||
ELSE
|
||||
CASE WHEN topics.closed
|
||||
THEN 0.9
|
||||
@@ -1048,9 +1056,9 @@ class Search
|
||||
|
||||
posts =
|
||||
if aggregate_search
|
||||
posts.order("MAX(#{data_ranking}) DESC")
|
||||
posts.order("MAX(#{category_search_priority}) DESC", "MAX(#{data_ranking}) DESC")
|
||||
else
|
||||
posts.order("#{data_ranking} DESC")
|
||||
posts.order("#{category_search_priority} DESC", "#{data_ranking} DESC")
|
||||
end
|
||||
|
||||
posts = posts.order("topics.bumped_at DESC")
|
||||
|
||||
@@ -9,14 +9,10 @@ class CategorySearchPriorityWeightsValidator
|
||||
val = val.to_f
|
||||
|
||||
case @name
|
||||
when "category_search_priority_very_low_weight"
|
||||
val < SiteSetting.category_search_priority_low_weight
|
||||
when "category_search_priority_low_weight"
|
||||
val < 1 && val > SiteSetting.category_search_priority_very_low_weight
|
||||
val < 1
|
||||
when "category_search_priority_high_weight"
|
||||
val > 1 && val < SiteSetting.category_search_priority_very_high_weight
|
||||
when "category_search_priority_very_high_weight"
|
||||
val > SiteSetting.category_search_priority_high_weight
|
||||
val > 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user