Class: MergeRequestDiffCommit
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- MergeRequestDiffCommit
- Includes:
- BulkInsertSafe, CachedCommit, ShaAttribute
- Defined in:
- app/models/merge_request_diff_commit.rb
Constant Summary
Constants included from BulkInsertSafe
BulkInsertSafe::ALLOWED_CALLBACKS, BulkInsertSafe::DEFAULT_BATCH_SIZE, BulkInsertSafe::MethodNotAllowedError, BulkInsertSafe::PrimaryKeySetError
Class Method Summary collapse
-
.create_bulk(merge_request_diff_id, commits) ⇒ Object
Deprecated; use `bulk_insert!` from `BulkInsertSafe` mixin instead.
Methods included from CachedCommit
Methods inherited from ApplicationRecord
at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order
Class Method Details
.create_bulk(merge_request_diff_id, commits) ⇒ Object
Deprecated; use `bulk_insert!` from `BulkInsertSafe` mixin instead. cf. gitlab.com/gitlab-org/gitlab/issues/207989 for progress
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/merge_request_diff_commit.rb', line 15 def self.create_bulk(merge_request_diff_id, commits) rows = commits.map.with_index do |commit, index| # See #parent_ids. commit_hash = commit.to_hash.except(:parent_ids) sha = commit_hash.delete(:id) commit_hash.merge( merge_request_diff_id: merge_request_diff_id, relative_order: index, sha: Gitlab::Database::ShaAttribute.serialize(sha), # rubocop:disable Cop/ActiveRecordSerialize authored_date: Gitlab::Database.(commit_hash[:authored_date]), committed_date: Gitlab::Database.(commit_hash[:committed_date]) ) end Gitlab::Database.bulk_insert(self.table_name, rows) # rubocop:disable Gitlab/BulkInsert end |