FEATURE: Enable gists on all topic lists (#922)
This commit is contained in:
parent
48d08dedd4
commit
fb80d776d8
|
@ -12,9 +12,7 @@ export default class AiTopicGist extends Component {
|
|||
|
||||
get showGist() {
|
||||
return (
|
||||
this.router.currentRoute.attributes?.filterType === "hot" &&
|
||||
this.args.topic?.ai_topic_gist &&
|
||||
!this.args.topic?.excerpt &&
|
||||
this.prefersGist &&
|
||||
!this.args.topic?.excerpt
|
||||
);
|
||||
|
|
|
@ -18,7 +18,9 @@ module DiscourseAi
|
|||
end
|
||||
|
||||
plugin.register_modifier(:topic_query_create_list_topics) do |topics, options|
|
||||
if options[:filter] == :hot && SiteSetting.ai_summarization_enabled &&
|
||||
skipped_filters = %i[suggested semantic_related]
|
||||
|
||||
if !skipped_filters.include?(options[:filter]) && SiteSetting.ai_summarization_enabled &&
|
||||
SiteSetting.ai_summarize_max_hot_topics_gists_per_batch > 0
|
||||
topics.includes(:ai_summaries).where(
|
||||
"ai_summaries.id IS NULL OR ai_summaries.summary_type = ?",
|
||||
|
@ -34,9 +36,7 @@ module DiscourseAi
|
|||
:ai_topic_gist,
|
||||
include_condition: -> { scope.can_see_gists? },
|
||||
) do
|
||||
# Options is defined at the instance level so we cannot run this check inside "include_condition".
|
||||
return if options[:filter] != :hot
|
||||
|
||||
return if %i[suggested semantic_related].include?(options[:filter])
|
||||
summaries = object.ai_summaries.to_a
|
||||
|
||||
# Summaries should always have one or zero elements here.
|
||||
|
|
|
@ -71,20 +71,6 @@ RSpec.describe DiscourseAi::Summarization::EntryPoint do
|
|||
expect(serialized[:ai_topic_gist]).to be_present
|
||||
end
|
||||
|
||||
it "doesn't include the summary when looking at other topic lists" do
|
||||
gist_topic = topic_query.list_hot.topics.find { |t| t.id == topic_ai_gist.target_id }
|
||||
|
||||
serialized =
|
||||
TopicListItemSerializer.new(
|
||||
gist_topic,
|
||||
scope: Guardian.new(user),
|
||||
root: false,
|
||||
filter: :latest,
|
||||
).as_json
|
||||
|
||||
expect(serialized[:ai_topic_gist]).to be_nil
|
||||
end
|
||||
|
||||
it "doesn't include the summary when the user is not a member of the opt-in group" do
|
||||
SiteSetting.ai_hot_topic_gists_allowed_groups = ""
|
||||
|
||||
|
|
Loading…
Reference in New Issue