debian-mirror-gitlab/db/fixtures/development/04_labels.rb

50 lines
1.4 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
class Gitlab::Seeder::GroupLabels
def initialize(group, label_per_group: 10)
@group = group
@label_per_group = label_per_group
end
def seed!
@label_per_group.times do
label_title = FFaker::Product.brand
Labels::CreateService
2022-07-16 23:28:13 +05:30
.new(title: label_title, color: "#{::Gitlab::Color.color_for(label_title)}")
2019-07-07 11:18:12 +05:30
.execute(group: @group)
print '.'
end
end
end
class Gitlab::Seeder::ProjectLabels
def initialize(project, label_per_project: 5)
@project = project
@label_per_project = label_per_project
end
def seed!
@label_per_project.times do
label_title = FFaker::Vehicle.model
Labels::CreateService
2022-07-16 23:28:13 +05:30
.new(title: label_title, color: "#{::Gitlab::Color.color_for(label_title)}")
2019-07-07 11:18:12 +05:30
.execute(project: @project)
print '.'
end
end
end
Gitlab::Seeder.quiet do
2022-06-21 17:19:12 +05:30
label_per_group = 10
puts "\nGenerating group labels: #{Group.not_mass_generated.count * label_per_group}"
Group.not_mass_generated.find_each do |group|
Gitlab::Seeder::GroupLabels.new(group, label_per_group: label_per_group).seed!
2019-07-07 11:18:12 +05:30
end
2022-06-21 17:19:12 +05:30
label_per_project = 5
puts "\nGenerating project labels: #{Project.not_mass_generated.count * label_per_project}"
2019-12-26 22:10:19 +05:30
Project.not_mass_generated.find_each do |project|
2022-06-21 17:19:12 +05:30
Gitlab::Seeder::ProjectLabels.new(project, label_per_project: label_per_project).seed!
2019-07-07 11:18:12 +05:30
end
end