mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 04:52:43 +08:00
5a55c9062a
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.
36 lines
776 B
Ruby
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
|