FIX: de-prioritize archived topics (#20161)

Previously due to an error archived topics were more prominent in search
than closed topics.

This amends our internal logic to ensure archived topics are bumped down
the list.
This commit is contained in:
Sam 2023-02-03 13:23:27 +11:00 committed by GitHub
parent 7fd63b34b1
commit 5d28cb709a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

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

View File

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