mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: add topic_query_suggested_options modifier (#20893)
Add a modifier that will allow us to tune the results returned by suggested. At the moment the modifier allows us to toggle including random results. This was created for the discourse-ai module. It needs to switch off random results when it returns related topics. Longer term we can use it to toggle unread/new and other aspects. This also demonstrates how to test the contract when adding modifiers.
This commit is contained in:
@@ -605,7 +605,16 @@ class TopicView
|
||||
|
||||
def suggested_topics
|
||||
if @include_suggested
|
||||
@suggested_topics ||= TopicQuery.new(@user).list_suggested_for(topic, pm_params: pm_params)
|
||||
@suggested_topics ||=
|
||||
begin
|
||||
kwargs =
|
||||
DiscoursePluginRegistry.apply_modifier(
|
||||
:topic_view_suggested_topics_options,
|
||||
{ include_random: true, pm_params: pm_params },
|
||||
self,
|
||||
)
|
||||
TopicQuery.new(@user).list_suggested_for(topic, **kwargs)
|
||||
end
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user