discourse-ai/app/jobs/regular/post_sentiment_analysis.rb

16 lines
409 B
Ruby
Raw Normal View History

2023-02-22 18:46:53 -05:00
# frozen_string_literal: true
module ::Jobs
class PostSentimentAnalysis < ::Jobs::Base
2023-02-22 18:46:53 -05:00
def execute(args)
return unless SiteSetting.ai_sentiment_enabled
return if (post_id = args[:post_id]).blank?
2023-02-22 18:46:53 -05:00
post = Post.find_by(id: post_id, post_type: Post.types[:regular])
return if post&.raw.blank?
DiscourseAi::Sentiment::PostClassification.new.classify!(post)
2023-02-22 18:46:53 -05:00
end
end
end