Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a large amount of dev data #16925

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/api/lib/tasks/dev.rake
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,43 @@ namespace :dev do
# Create notifications by running the `dev:notifications:data` task two times
Rake::Task['dev:notifications:data'].invoke(2)
end

desc 'Create more data'
task :create_more_data, [:repetitions] => :development_environment do |_t, args|
args.with_defaults(repetitions: 1)
repetitions = args.repetitions.to_i

require 'factory_bot'
include FactoryBot::Syntax::Methods

admin = User.default_admin
User.session = admin

# Create n project with n packages each
repetitions.times do |repetition|
new_project_name = "#{Faker::Lorem.words.join(':')}_#{repetition}"
new_project = create(:project, name: new_project_name, commit_user: admin)
repetitions.times do |repetition_package|
create(:package_with_file, name: "#{Faker::Lorem.words.join('_')}_#{repetition_package}", project: new_project, file_content: 'some content')
end
end

Rake::Task['dev:requests:multiple_actions_request'].invoke(repetitions)
Rake::Task['dev:requests:request_with_multiple_submit_actions_builds_and_diffs'].invoke(repetitions)

actions_count_for_small_request = 10
actions_count_for_medium_request = 100
actions_count_for_large_request = 1000
Rake::Task['dev:requests:request_with_multiple_submit_actions_builds_and_diffs'].invoke(10, actions_count_for_small_request)
Rake::Task['dev:requests:request_with_multiple_submit_actions_builds_and_diffs'].invoke(2, actions_count_for_medium_request)
Rake::Task['dev:requests:request_with_multiple_submit_actions_builds_and_diffs'].invoke(1, actions_count_for_large_request)

Rake::Task['dev:requests:request_with_delete_action'].invoke(repetitions)

# TODO: refactor the task, it is very slow compared to the others
Rake::Task['dev:notifications:data'].invoke(repetitions)

Rake::Task['dev:news:data'].invoke(repetitions)
end
end
end
2 changes: 0 additions & 2 deletions src/api/lib/tasks/dev/reports.rake
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ namespace :dev do
require 'factory_bot'
include FactoryBot::Syntax::Methods

puts 'Taking decisions regarding some reports'

# This automatically subscribes everyone to the cleared and favored decision events
EventSubscription.create!(eventtype: Event::ClearedDecision.name, channel: :web, receiver_role: :reporter, enabled: true)
EventSubscription.create!(eventtype: Event::FavoredDecision.name, channel: :web, receiver_role: :reporter, enabled: true)
Expand Down
Loading