mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 13:08:40 +08:00
Store summaries by locale so topics can serve and regenerate the appropriate localized version. Generate gists for source and translated locales, and make backfills handle each locale independently.
31 lines
913 B
Ruby
Vendored
31 lines
913 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module DiscourseAi
|
|
module TopicExtensions
|
|
extend ActiveSupport::Concern
|
|
|
|
prepended do
|
|
has_many :ai_summaries, as: :target
|
|
|
|
has_many :ai_gist_summaries,
|
|
-> { where(summary_type: AiSummary.summary_types[:gist]) },
|
|
class_name: "AiSummary",
|
|
as: :target
|
|
|
|
has_many :inferred_concept_topics
|
|
has_many :inferred_concepts, through: :inferred_concept_topics
|
|
|
|
has_many :ai_conversation_stars,
|
|
class_name: "DiscourseAi::AiBot::ConversationStar",
|
|
foreign_key: :topic_id
|
|
|
|
def self.ai_conversation_custom_field_join_sql
|
|
<<~SQL.squish
|
|
INNER JOIN topic_custom_fields tcf ON tcf.topic_id = topics.id
|
|
AND tcf.name = #{connection.quote(DiscourseAi::AiBot::TOPIC_AI_BOT_PM_FIELD)}
|
|
AND tcf.value = 't'
|
|
SQL
|
|
end
|
|
end
|
|
end
|
|
end
|