2023-02-22 18:46:53 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module ::Jobs
|
2023-02-23 13:50:10 -05:00
|
|
|
class PostSentimentAnalysis < ::Jobs::Base
|
2023-02-22 18:46:53 -05:00
|
|
|
def execute(args)
|
|
|
|
return unless SiteSetting.ai_sentiment_enabled
|
2023-02-23 13:50:10 -05:00
|
|
|
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?
|
|
|
|
|
2024-11-28 13:38:23 -05:00
|
|
|
DiscourseAi::Sentiment::PostClassification.new.classify!(post)
|
2023-02-22 18:46:53 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|