mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: suggested topics sometimes adds new topics from other categories before new topics of the current category
This commit is contained in:
@@ -31,14 +31,19 @@ class SuggestedTopicsBuilder
|
||||
end
|
||||
|
||||
def splice_results(results, priority)
|
||||
if @category_id &&
|
||||
priority == :high &&
|
||||
non_category_index = @results.index{|r| r.category_id != @category_id}
|
||||
if @category_id && priority == :high
|
||||
|
||||
category_results, non_category_results = results.partition{|r| r.category_id == @category_id}
|
||||
# Topics from category @category_id need to be first in the list, all others after.
|
||||
|
||||
@results.insert non_category_index, *category_results
|
||||
@results.concat non_category_results
|
||||
other_category_index = @results.index { |r| r.category_id != @category_id }
|
||||
category_results, other_category_results = results.partition{ |r| r.category_id == @category_id }
|
||||
|
||||
if other_category_index
|
||||
@results.insert other_category_index, *category_results
|
||||
else
|
||||
@results.concat category_results
|
||||
end
|
||||
@results.concat other_category_results
|
||||
else
|
||||
@results.concat results
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user