2021-02-05 07:09:31 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-17 06:23:06 -04:00
|
|
|
namespace :gitlab do
|
|
|
|
namespace :seed do
|
|
|
|
desc "GitLab | Seed | Seeds issues"
|
2019-07-12 16:02:45 -04:00
|
|
|
task :issues, [:project_full_path, :backfill_weeks, :average_issues_per_week] => :environment do |t, args|
|
|
|
|
args.with_defaults(backfill_weeks: 5, average_issues_per_week: 2)
|
|
|
|
|
2019-04-17 06:23:06 -04:00
|
|
|
projects =
|
|
|
|
if args.project_full_path
|
|
|
|
project = Project.find_by_full_path(args.project_full_path)
|
|
|
|
|
|
|
|
unless project
|
|
|
|
error_message = "Project '#{args.project_full_path}' does not exist!"
|
|
|
|
potential_projects = Project.search(args.project_full_path)
|
|
|
|
|
|
|
|
if potential_projects.present?
|
|
|
|
error_message += " Did you mean '#{potential_projects.first.full_path}'?"
|
|
|
|
end
|
|
|
|
|
|
|
|
puts error_message.color(:red)
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
|
|
|
[project]
|
|
|
|
else
|
2019-11-15 07:06:12 -05:00
|
|
|
Project.not_mass_generated.find_each
|
2019-04-17 06:23:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
projects.each do |project|
|
|
|
|
puts "\nSeeding issues for the '#{project.full_path}' project"
|
|
|
|
seeder = Quality::Seeders::Issues.new(project: project)
|
2019-07-12 16:02:45 -04:00
|
|
|
issues_created = seeder.seed(backfill_weeks: args.backfill_weeks.to_i,
|
|
|
|
average_issues_per_week: args.average_issues_per_week.to_i)
|
2019-04-17 06:23:06 -04:00
|
|
|
puts "\n#{issues_created} issues created!"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|