2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-31 08:32:21 +08:00
|
|
|
## These tasks are destructive and are for clearing out all the
|
2019-07-18 02:41:13 +08:00
|
|
|
# content and users from your site.
|
2018-03-31 08:32:21 +08:00
|
|
|
desc "Remove all topics in a category"
|
2018-09-10 19:52:14 +08:00
|
|
|
task "destroy:topics", [:category, :parent_category] => :environment do |t, args|
|
2018-03-31 08:32:21 +08:00
|
|
|
category = args[:category]
|
2018-09-10 19:52:14 +08:00
|
|
|
parent_category = args[:parent_category]
|
|
|
|
descriptive_slug = parent_category ? "#{parent_category}/#{category}" : category
|
|
|
|
puts "Going to delete all topics in the #{descriptive_slug} category"
|
2019-07-19 09:15:01 +08:00
|
|
|
DestroyTask.new.destroy_topics(category, parent_category)
|
2018-03-31 08:32:21 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Remove all topics in all categories"
|
|
|
|
task "destroy:topics_all_categories" => :environment do
|
|
|
|
puts "Going to delete all topics in all categories..."
|
2019-07-19 09:15:01 +08:00
|
|
|
DestroyTask.new.destroy_topics_all_categories
|
2018-03-31 08:32:21 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Remove all private messages"
|
|
|
|
task "destroy:private_messages" => :environment do
|
|
|
|
puts "Going to delete all private messages..."
|
2019-07-19 09:15:01 +08:00
|
|
|
DestroyTask.new.destroy_private_messages
|
2018-03-31 08:32:21 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Destroy all groups"
|
|
|
|
task "destroy:groups" => :environment do
|
|
|
|
puts "Going to delete all non-default groups..."
|
2019-07-19 09:15:01 +08:00
|
|
|
DestroyTask.new.destroy_groups
|
2018-03-31 08:32:21 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Destroy all non-admin users"
|
|
|
|
task "destroy:users" => :environment do
|
|
|
|
puts "Going to delete all non-admin users..."
|
2019-07-19 09:15:01 +08:00
|
|
|
DestroyTask.new.destroy_users
|
2018-03-31 08:32:21 +08:00
|
|
|
end
|
|
|
|
|
2018-04-27 00:46:32 +08:00
|
|
|
desc "Destroy site stats"
|
2018-03-31 08:32:21 +08:00
|
|
|
task "destroy:stats" => :environment do
|
|
|
|
puts "Going to delete all site stats..."
|
2019-07-19 09:15:01 +08:00
|
|
|
DestroyTask.new.destroy_stats
|
2019-07-18 02:41:13 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# Example: rake destroy:categories[28,29,44,85]
|
|
|
|
# Run rake categories:list for a list of category ids
|
|
|
|
desc "Destroy a comma separated list of category ids."
|
|
|
|
task "destroy:categories" => :environment do |t, args|
|
|
|
|
destroy_task = DestroyTask.new
|
|
|
|
categories = args.extras
|
|
|
|
puts "Going to delete these categories: #{categories}"
|
|
|
|
categories.each do |id|
|
|
|
|
destroy_task.destroy_category(id, true)
|
|
|
|
end
|
2018-03-31 08:32:21 +08:00
|
|
|
end
|