discourse/lib/discourse_dev/reviewable_flagged_post.rb
Osama Sayegh 5a55c9062a
DEV: Add reviewables:populate rake task (#30540)
Adds a new reviewables:populate rake task that works in a similar fashion to the existing *:populate rake tasks. The rake task creates pending reviewable of all core types, with possibility for plugins to extend the task to populate their own reviewable types.
2025-01-03 10:05:04 +08:00

36 lines
776 B
Ruby

# frozen_string_literal: true
require "discourse_dev/reviewable"
require "faker"
module DiscourseDev
class ReviewableFlaggedPost < Reviewable
def populate!
types = PostActionType.notify_flag_types.keys
posts = @posts.sample(types.size + 1)
users = @users.sample(types.size + 3)
types.each do |type|
post = posts.pop
user = users.pop
reason = nil
reason = Faker::Lorem.paragraph if type == :notify_moderators
PostActionCreator.create(user, post, type, reason:)
end
posts.pop.tap do |post|
type = types.excluding(:notify_moderators).sample
3.times do
user = users.pop
PostActionCreator.create(user, post, type)
end
end
end
end
end