# frozen_string_literal: truemoduleGitlabmoduleGithubImportmoduleBulkImporting# 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.defbuild_database_rows(enum)enum.each_with_object([])do|(object,_),rows|rows<<build(object)unlessalready_imported?(object)endend# Bulk inserts the given rows into the database.defbulk_insert(model,rows,batch_size: 100)rows.each_slice(batch_size)do|slice|Gitlab::Database.bulk_insert(model.table_name,slice)endendendendend