mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 05:33:37 +08:00
6442bbf46c
This is to help generate random channels and chat
messages for local dev. This was removed in 12a18d4d55
presumably because it was not worth refactoring at the
time.
I've only added these tasks:
- `rake chat:message:populate\[113,20\]` (channel_id, count)
- Generates the count of messages for a channel ID provided,
otherwise uses a random channel and 200 count.
- `rake chat:category_channel:populate`
- Creates a chat channel for a random category.
- `rake chat🧵populate\[132,5\]` (channel_id, message_count)
- Creates a thread with N messages in the specified channel,
and enables threading in that channel if necessary
27 lines
873 B
Ruby
27 lines
873 B
Ruby
# frozen_string_literal: true
|
|
|
|
if Discourse.allow_dev_populate?
|
|
desc "Generates sample messages in channels"
|
|
task "chat:message:populate", %i[channel_id count] => ["db:load_config"] do |_, args|
|
|
DiscourseDev::Message.populate!(
|
|
ignore_current_count: true,
|
|
channel_id: args[:channel_id],
|
|
count: args[:count],
|
|
)
|
|
end
|
|
|
|
desc "Generates random channels from categories"
|
|
task "chat:category_channel:populate" => ["db:load_config"] do |_, args|
|
|
DiscourseDev::CategoryChannel.populate!(ignore_current_count: true)
|
|
end
|
|
|
|
desc "Creates a thread with sample messages in a channel"
|
|
task "chat:thread:populate", %i[channel_id message_count] => ["db:load_config"] do |_, args|
|
|
DiscourseDev::Thread.populate!(
|
|
ignore_current_count: true,
|
|
channel_id: args[:channel_id],
|
|
message_count: args[:message_count],
|
|
)
|
|
end
|
|
end
|