2023-02-22 20:46:53 -03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module ::Jobs
|
2023-02-23 15:50:10 -03:00
|
|
|
class PostSentimentAnalysis < ::Jobs::Base
|
2023-02-22 20:46:53 -03:00
|
|
|
def execute(args)
|
|
|
|
return unless SiteSetting.ai_sentiment_enabled
|
2023-02-23 15:50:10 -03:00
|
|
|
return if (post_id = args[:post_id]).blank?
|
2023-02-22 20:46:53 -03:00
|
|
|
|
|
|
|
post = Post.find_by(id: post_id, post_type: Post.types[:regular])
|
|
|
|
return if post&.raw.blank?
|
|
|
|
|
2023-03-14 16:03:50 -03:00
|
|
|
DiscourseAi::PostClassificator.new(
|
|
|
|
DiscourseAi::Sentiment::SentimentClassification.new,
|
2023-02-24 13:25:02 -03:00
|
|
|
).classify!(post)
|
2023-02-22 20:46:53 -03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|