mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-31 19:17:48 +00:00
Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com> Co-authored-by: Sojan <sojan@pepalo.com> Co-authored-by: tds-1 <tanmay@qoala.id> Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
31 lines
848 B
Ruby
31 lines
848 B
Ruby
require_relative '../test_data'
|
|
|
|
namespace :data do
|
|
desc 'Generate large, distributed test data'
|
|
task generate_distributed_data: :environment do
|
|
if Rails.env.production?
|
|
puts 'Generating large amounts of data in production can have serious performance implications.'
|
|
puts 'Exiting to avoid impacting a live environment.'
|
|
exit
|
|
end
|
|
|
|
# Configure logger
|
|
Rails.logger = ActiveSupport::Logger.new($stdout)
|
|
Rails.logger.formatter = proc do |severity, datetime, _progname, msg|
|
|
"#{datetime.strftime('%Y-%m-%d %H:%M:%S.%L')} #{severity}: #{msg}\n"
|
|
end
|
|
|
|
begin
|
|
TestData::DatabaseOptimizer.setup
|
|
TestData.generate
|
|
ensure
|
|
TestData::DatabaseOptimizer.restore
|
|
end
|
|
end
|
|
|
|
desc 'Clean up existing test data'
|
|
task cleanup_test_data: :environment do
|
|
TestData.cleanup
|
|
end
|
|
end
|