mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-03-08 02:12:14 +00:00
This change adds a simpler class for sentiment classification, replacing the soon-to-be removed `Classificator` hierarchy. Additionally, it adds a method for classifying concurrently, speeding up the backfill rake task.
16 lines
409 B
Ruby
16 lines
409 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ::Jobs
|
|
class PostSentimentAnalysis < ::Jobs::Base
|
|
def execute(args)
|
|
return unless SiteSetting.ai_sentiment_enabled
|
|
return if (post_id = args[:post_id]).blank?
|
|
|
|
post = Post.find_by(id: post_id, post_type: Post.types[:regular])
|
|
return if post&.raw.blank?
|
|
|
|
DiscourseAi::Sentiment::PostClassification.new.classify!(post)
|
|
end
|
|
end
|
|
end
|