Skip to content

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

FIX: de-prioritize archived topics (#20161)

Sam5d28cb709acf
diff --git a/lib/search.rb b/lib/search.rb
index ae9ec947e37..af244565081 100644
--- a/lib/search.rb
+++ b/lib/search.rb
@@ -1161,7 +1161,9 @@ class Search
WHEN #{Searchable::PRIORITIES[:high]}
THEN #{SiteSetting.category_search_priority_high_weight}
ELSE
- CASE WHEN topics.closed
+ CASE WHEN topics.archived
+ THEN 0.85
+ WHEN topics.closed
THEN 0.9
ELSE 1
END
diff --git a/spec/lib/search_spec.rb b/spec/lib/search_spec.rb
index 515684c7670..feca2de42eb 100644
--- a/spec/lib/search_spec.rb
+++ b/spec/lib/search_spec.rb
@@ -948,15 +948,23 @@ RSpec.describe Search do
expect(result.blurb(result.posts.first)).to eq(expected_blurb)
end
- it "applies a small penalty to closed topic when ranking" do
- post =
+ it "applies a small penalty to closed topics and archived topics when ranking" do
+ archived_post =
+ Fabricate(
+ :post,
+ raw: "My weekly update",
+ topic:
+ Fabricate(:topic, title: "A topic that will be archived", archived: true, closed: true),
+ )
+
+ closed_post =
Fabricate(
:post,
raw: "My weekly update",
topic: Fabricate(:topic, title: "A topic that will be closed", closed: true),
)
- post2 =
+ open_post =
Fabricate(
:post,
raw: "My weekly update",
@@ -964,7 +972,7 @@ RSpec.describe Search do
)
result = Search.execute("weekly update")
- expect(result.posts.pluck(:id)).to eq([post2.id, post.id])
+ expect(result.posts.pluck(:id)).to eq([open_post.id, closed_post.id, archived_post.id])
end
it "can find posts by searching for a url prefix" do