Create script to generate dummy data, for perf investigation
This commit is contained in:
parent
1179957a32
commit
6221581cf0
2
Gemfile
2
Gemfile
|
@ -111,7 +111,6 @@ end
|
|||
group :test do
|
||||
gem 'capybara', '~> 3.22'
|
||||
gem 'climate_control', '~> 0.2'
|
||||
gem 'faker', '~> 1.9'
|
||||
gem 'microformats', '~> 4.1'
|
||||
gem 'rails-controller-testing', '~> 1.0'
|
||||
gem 'rspec-sidekiq', '~> 3.0'
|
||||
|
@ -126,6 +125,7 @@ group :development do
|
|||
gem 'better_errors', '~> 2.5'
|
||||
gem 'binding_of_caller', '~> 0.7'
|
||||
gem 'bullet', '~> 6.0'
|
||||
gem 'faker', '~> 2.15'
|
||||
gem 'listen'
|
||||
gem 'letter_opener', '~> 1.7'
|
||||
gem 'letter_opener_web', '~> 1.3'
|
||||
|
|
|
@ -227,8 +227,8 @@ GEM
|
|||
tzinfo
|
||||
excon (0.78.1)
|
||||
fabrication (2.21.1)
|
||||
faker (1.9.6)
|
||||
i18n (>= 0.7)
|
||||
faker (2.15.1)
|
||||
i18n (>= 1.6, < 2)
|
||||
faraday (1.3.0)
|
||||
faraday-net_http (~> 1.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
|
@ -296,7 +296,7 @@ GEM
|
|||
httplog (1.4.3)
|
||||
rack (>= 1.0)
|
||||
rainbow (>= 2.0.0)
|
||||
i18n (1.8.7)
|
||||
i18n (1.8.8)
|
||||
concurrent-ruby (~> 1.0)
|
||||
i18n-tasks (0.9.33)
|
||||
activesupport (>= 4.0.2)
|
||||
|
@ -703,7 +703,7 @@ DEPENDENCIES
|
|||
dotenv-rails (~> 2.7)
|
||||
elastic-apm (~> 3.13)
|
||||
fabrication (~> 2.20)
|
||||
faker (~> 1.9)
|
||||
faker (~> 2.15)
|
||||
fast_blank (~> 1.0)
|
||||
fastimage
|
||||
fog-core (<= 2.1.0)
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
desc 'Import dummy data into the database, to create a more realistic development experience'
|
||||
task dummy_data: :environment do
|
||||
raise 'Only run this in development' unless Rails.env.development?
|
||||
|
||||
domain = ENV['LOCAL_DOMAIN'] || Rails.configuration.x.local_domain
|
||||
|
||||
admin = Account.find_by!(username: 'admin')
|
||||
|
||||
accounts = 1.upto(1_000).map do |num|
|
||||
username = "#{Faker::Internet.username(separators: %w[_])}#{num}"
|
||||
password = Faker::Internet.password
|
||||
|
||||
Account.create!(username: username).tap do |account|
|
||||
account.create_user!({
|
||||
email: "#{username}@#{domain}",
|
||||
password: password,
|
||||
password_confirmation: password,
|
||||
agreement: true,
|
||||
approved: true
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
accounts.each do |acct|
|
||||
FollowService.new.call(admin, acct)
|
||||
end
|
||||
|
||||
statuses = (accounts + [admin]).map do |account|
|
||||
PostStatusService.new.call(account, text: Faker::Lorem.paragraph(sentence_count: 20))
|
||||
end
|
||||
|
||||
accounts.sample(200).zip(statuses.sample(200)).each do |account, status|
|
||||
ReblogService.new.call(account, status)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue