mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 03:32:40 +08:00
DEV: Populate all subtypes of ReviewableQueuedPost (#30663)
Follow-up to 5a55c9062a
There are many scenarios that can result in creating a `ReviewableQueuedPost` record, however in the original commit we only added once scenario to the populate rake task. This commit adds the remaining scenarios to the rake task.
This commit is contained in:
parent
b1e40d04b9
commit
2c48c9aea7
|
@ -6,21 +6,57 @@ require "faker"
|
||||||
module DiscourseDev
|
module DiscourseDev
|
||||||
class ReviewableQueuedPost < Reviewable
|
class ReviewableQueuedPost < Reviewable
|
||||||
def populate!
|
def populate!
|
||||||
2.times do
|
:new_topics_unless_allowed_groups.tap do |reason|
|
||||||
|
manager =
|
||||||
|
NewPostManager.new(
|
||||||
|
@users.sample,
|
||||||
|
custom_payload_for_reason(reason).merge(
|
||||||
|
title: Faker::Lorem.sentence,
|
||||||
|
raw: Faker::DiscourseMarkdown.sandwich(sentences: 3),
|
||||||
|
tags: nil,
|
||||||
|
typing_duration_msecs: Faker::Number.between(from: 2_000, to: 5_000),
|
||||||
|
composer_open_duration_msecs: Faker::Number.between(from: 5_500, to: 10_000),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
manager.enqueue(reason, creator_opts: { skip_validations: true })
|
||||||
|
end
|
||||||
|
|
||||||
|
%i[
|
||||||
|
email_auth_res_enqueue
|
||||||
|
email_spam
|
||||||
|
post_count
|
||||||
|
group
|
||||||
|
fast_typer
|
||||||
|
auto_silence_regex
|
||||||
|
staged
|
||||||
|
category
|
||||||
|
contains_media
|
||||||
|
].each do |reason|
|
||||||
topic = @topics.sample
|
topic = @topics.sample
|
||||||
manager =
|
manager =
|
||||||
NewPostManager.new(
|
NewPostManager.new(
|
||||||
@users.sample,
|
@users.sample,
|
||||||
{
|
custom_payload_for_reason(reason).merge(
|
||||||
topic_id: topic.id,
|
topic_id: topic.id,
|
||||||
raw: Faker::DiscourseMarkdown.sandwich(sentences: 3),
|
raw: Faker::DiscourseMarkdown.sandwich(sentences: 3),
|
||||||
tags: nil,
|
tags: nil,
|
||||||
typing_duration_msecs: Faker::Number.between(from: 2_000, to: 5_000),
|
typing_duration_msecs: Faker::Number.between(from: 2_000, to: 5_000),
|
||||||
composer_open_duration_msecs: Faker::Number.between(from: 5_500, to: 10_000),
|
composer_open_duration_msecs: Faker::Number.between(from: 5_500, to: 10_000),
|
||||||
reply_to_post_number: topic.posts.sample.post_number,
|
reply_to_post_number: topic.posts.sample.post_number,
|
||||||
},
|
),
|
||||||
)
|
)
|
||||||
manager.enqueue(:watched_word, creator_opts: { skip_validations: true })
|
manager.enqueue(reason, creator_opts: { skip_validations: true })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def custom_payload_for_reason(reason)
|
||||||
|
case reason
|
||||||
|
when :email_auth_res_enqueue, :email_spam
|
||||||
|
{ via_email: true, raw_email: Faker::Lorem.paragraph }
|
||||||
|
else
|
||||||
|
{}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user