chore: Move embedding generation to sidekiq (#9238)

chore: Move embedding generation to a job
This commit is contained in:
Sojan Jose
2024-04-16 09:43:16 -07:00
committed by GitHub
parent 5cc41c9ed5
commit d12c38c344
2 changed files with 11 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
class Portal::ArticleIndexingJob < ApplicationJob
queue_as :low
def perform(article)
article.generate_and_save_article_seach_terms
end
end

View File

@@ -39,6 +39,10 @@ module Enterprise::Concerns::Article
def add_article_embedding
return unless account.feature_enabled?('help_center_embedding_search')
Portal::ArticleIndexingJob.perform_later(self)
end
def generate_and_save_article_seach_terms
terms = generate_article_search_terms
article_embeddings.destroy_all
terms.each { |term| article_embeddings.create!(term: term) }