diff options
Diffstat (limited to 'db/fixtures/development/04_labels.rb')
-rw-r--r-- | db/fixtures/development/04_labels.rb | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/db/fixtures/development/04_labels.rb b/db/fixtures/development/04_labels.rb index f7d87b2b318..4d352858d50 100644 --- a/db/fixtures/development/04_labels.rb +++ b/db/fixtures/development/04_labels.rb @@ -10,47 +10,38 @@ class Gitlab::Seeder::GroupLabels end class Gitlab::Seeder::ProjectLabels - MASS_LABELS_COUNT = 400 # per project + include ActionView::Helpers::NumberHelper - def initialize(project) - @project = project - end + PROJECT_LIMIT = 500_000 + MASS_LABELS_COUNT = 50 # per project def seed! - Project.select(:id).find_in_batches(batch_size: 100) do |projects| - rows = projects.flat_map do |project| - MASS_LABELS_COUNT.times.map do - label_title = FFaker::Product.brand - - { - title: label_title, - color: "##{Digest::MD5.hexdigest(label_title)[0..5]}", - project_id: project.id, - type: 'ProjectLabel' - } + relation = Project.select(:id).limit(PROJECT_LIMIT) + total_labels = relation.count * MASS_LABELS_COUNT + + Gitlab::Seeder.with_mass_insert(total_labels, Label) do + relation.find_in_batches(batch_size: 500) do |projects| + rows = projects.flat_map do |project| + MASS_LABELS_COUNT.times.map do + label_title = FFaker::Product.brand + + { + title: label_title, + color: "##{Digest::MD5.hexdigest(label_title)[0..5]}", + project_id: project.id, + type: 'ProjectLabel' + } + end end - end - - puts "*** ROWS BEING INSERTED ***" - p rows.size - - print rows.size * '.' - Gitlab::Database.bulk_insert('labels', rows) - puts "*** LABELS COUNT ***" - print Label.count + Gitlab::Database.bulk_insert('labels', rows) + print '.' + end end - - puts "#{number_with_delimiter(MASS_LABELS_COUNT)} project labels created for each project!" end end Gitlab::Seeder.quiet do - # puts "\nGenerating group labels" - # group_labels = Gitlab::Seeder::GroupLabels.new - # group_labels.seed! - - puts "\nGenerating project labels" project_labels = Gitlab::Seeder::ProjectLabels.new project_labels.seed! end |