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?
|
|
|
|
|
2023-03-14 15:03:50 -04:00
|
|
|
DiscourseAi::PostClassificator.new(
|
|
|
|
DiscourseAi::Sentiment::SentimentClassification.new,
|
2023-02-24 11:25:02 -05:00
|
|
|
).classify!(post)
|
2023-02-22 18:46:53 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|