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:
Alan Guo Xiang Tan
2020-12-23 15:14:41 +08:00
parent 082a77df69
commit ebe4896e48
7 changed files with 80 additions and 49 deletions

View File

@ -5,24 +5,16 @@ require 'validators/category_search_priority_weights_validator'
RSpec.describe CategorySearchPriorityWeightsValidator do
it "should validate the results correctly" do
expect do
SiteSetting.category_search_priority_very_low_weight = 0.9
end.to raise_error(Discourse::InvalidParameters)
[1, 0].each do |value|
[1, 1.1].each do |value|
expect do
SiteSetting.category_search_priority_low_weight = value
end.to raise_error(Discourse::InvalidParameters)
end
['0.2', 10].each do |value|
[1, "0.9"].each do |value|
expect do
SiteSetting.category_search_priority_high_weight = value
end.to raise_error(Discourse::InvalidParameters)
end
expect do
SiteSetting.category_search_priority_very_high_weight = 1.1
end.to raise_error(Discourse::InvalidParameters)
end
end