Roman Rizzi ce6a2eca21
FEATURE: Backfill posts sentiment. (#982)
* FEATURE: Backfill posts sentiment.

It adds a scheduled job to backfill posts' sentiment, similar to our existing rake task, but with two settings to control the batch size and posts' max-age.

* Make sure model_name order is consistent.
2024-12-03 10:27:03 -03:00

12 lines
384 B
Ruby

# frozen_string_literal: true
desc "Backfill sentiment for all posts"
task "ai:sentiment:backfill", [:start_post] => [:environment] do |_, args|
DiscourseAi::Sentiment::PostClassification
.backfill_query(from_post_id: args[:start_post].to_i)
.find_in_batches do |batch|
print "."
DiscourseAi::Sentiment::PostClassification.new.bulk_classify!(batch)
end
end