Module: Gitlab::GithubImport::BulkImporting
- Defined in:
- lib/gitlab/github_import/bulk_importing.rb
Instance Method Summary collapse
-
#build_database_rows(enum) ⇒ Object
Builds and returns an Array of objects to bulk insert into the database.
-
#bulk_insert(model, rows, batch_size: 100) ⇒ Object
Bulk inserts the given rows into the database.
Instance Method Details
#build_database_rows(enum) ⇒ Object
Builds and returns an Array of objects to bulk insert into the database.
enum - An Enumerable that returns the objects to turn into database
rows.
11 12 13 14 15 |
# File 'lib/gitlab/github_import/bulk_importing.rb', line 11 def build_database_rows(enum) enum.each_with_object([]) do |(object, _), rows| rows << build(object) unless already_imported?(object) end end |
#bulk_insert(model, rows, batch_size: 100) ⇒ Object
Bulk inserts the given rows into the database.
18 19 20 21 22 |
# File 'lib/gitlab/github_import/bulk_importing.rb', line 18 def bulk_insert(model, rows, batch_size: 100) rows.each_slice(batch_size) do |slice| Gitlab::Database.bulk_insert(model.table_name, slice) # rubocop:disable Gitlab/BulkInsert end end |