Class: Gitlab::Seeder
- Inherits:
-
Object
show all
- Extended by:
- ActionView::Helpers::NumberHelper
- Defined in:
- lib/gitlab/seeder.rb
Defined Under Namespace
Modules: NamespaceSeed, ProjectSeed, UserSeed
Constant Summary
collapse
- MASS_INSERT_PREFIX =
'mass_insert'
- MASS_INSERT_PROJECT_START =
"#{MASS_INSERT_PREFIX}_project_"
- MASS_INSERT_GROUP_START =
"#{MASS_INSERT_PREFIX}_group_"
- MASS_INSERT_USER_START =
"#{MASS_INSERT_PREFIX}_user_"
- REPORTED_USER_START =
'reported_user_'
- ESTIMATED_INSERT_PER_MINUTE =
250_000
- MASS_INSERT_ENV =
'MASS_INSERT'
Class Method Summary
collapse
Class Method Details
.estimated_time_message(size) ⇒ Object
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/gitlab/seeder.rb', line 72
def self.estimated_time_message(size)
estimated_minutes = (size.to_f / ESTIMATED_INSERT_PER_MINUTE).round
humanized_minutes = 'minute'.pluralize(estimated_minutes)
if estimated_minutes == 0
"Rough estimated time: less than a minute ⏰"
else
"Rough estimated time: #{estimated_minutes} #{humanized_minutes} ⏰"
end
end
|
.log_message(message) ⇒ Object
48
49
50
|
# File 'lib/gitlab/seeder.rb', line 48
def self.log_message(message)
puts "#{Time.current}: #{message}"
end
|
.quiet ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/gitlab/seeder.rb', line 83
def self.quiet
Namespace.include(NamespaceSeed)
Project.include(ProjectSeed)
User.include(UserSeed)
old_perform_deliveries = ActionMailer::Base.perform_deliveries
ActionMailer::Base.perform_deliveries = false
SeedFu.quiet = true
without_database_logging do
without_statement_timeout do
without_new_note_notifications do
if Rails.env.development?
Gitlab::SafeRequestStore.ensure_request_store do
sidekiq_strict_mode = Sidekiq::Config::DEFAULTS[:on_complex_arguments]
disable_request_limits = ENV['GITALY_DISABLE_REQUEST_LIMITS']
ENV['GITALY_DISABLE_REQUEST_LIMITS'] = 'true'
Sidekiq.strict_args!(false)
yield
ensure
ENV['GITALY_DISABLE_REQUEST_LIMITS'] = disable_request_limits
Sidekiq.strict_args!(sidekiq_strict_mode)
end
else
yield
end
end
end
end
puts Rainbow("\nOK").green
ensure
SeedFu.quiet = false
ActionMailer::Base.perform_deliveries = old_perform_deliveries
end
|
.with_mass_insert(size, model) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/gitlab/seeder.rb', line 52
def self.with_mass_insert(size, model)
humanized_model_name = model.is_a?(String) ? model : model.model_name.human.pluralize(size)
if !ENV[MASS_INSERT_ENV] && !ENV['CI']
puts "\nSkipping mass insertion for #{humanized_model_name}."
puts "Consider running the seed with #{MASS_INSERT_ENV}=1"
return
end
humanized_size = number_with_delimiter(size)
estimative = estimated_time_message(size)
puts "\nCreating #{humanized_size} #{humanized_model_name}."
puts estimative
yield
puts "\n#{number_with_delimiter(size)} #{humanized_model_name} created!"
end
|
.without_database_logging ⇒ Object
.without_gitaly_timeout ⇒ Object
.without_new_note_notifications ⇒ Object
.without_statement_timeout ⇒ Object