Class: MergeRequestContextCommit
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- MergeRequestContextCommit
- Includes:
- CachedCommit, ShaAttribute
- Defined in:
- app/models/merge_request_context_commit.rb
Constant Summary
Constants inherited from ApplicationRecord
Constants included from HasCheckConstraints
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
Constants included from ResetOnColumnErrors
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary collapse
-
.bulk_insert(rows, **args) ⇒ Object
create MergeRequestContextCommit by given commit sha and it’s diff file record.
-
.delete_bulk(merge_request, commits) ⇒ Object
delete all MergeRequestContextCommit & MergeRequestContextCommitDiffFile for given merge_request & commit SHAs.
Instance Method Summary collapse
Methods included from CachedCommit
#extended_trailers, #parent_ids, #referenced_by, #to_hash
Methods inherited from ApplicationRecord
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
Methods included from Organizations::Sharding
Methods included from ResetOnColumnErrors
#reset_on_union_error, #reset_on_unknown_attribute_error
Methods included from Gitlab::SensitiveSerializableHash
Class Method Details
.bulk_insert(rows, **args) ⇒ Object
create MergeRequestContextCommit by given commit sha and it’s diff file record
30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/merge_request_context_commit.rb', line 30 def self.bulk_insert(rows, **args) # Remove the new extended_trailers attribute as this shouldn't be # inserted into the database. This will be removed once the old # format of the trailers attribute is deprecated. rows = rows.map do |row| row.except(:extended_trailers).to_hash end ApplicationRecord.legacy_bulk_insert('merge_request_context_commits', rows, **args) # rubocop:disable Gitlab/BulkInsert end |
.delete_bulk(merge_request, commits) ⇒ Object
delete all MergeRequestContextCommit & MergeRequestContextCommitDiffFile for given merge_request & commit SHAs
24 25 26 27 |
# File 'app/models/merge_request_context_commit.rb', line 24 def self.delete_bulk(merge_request, commits) commit_ids = commits.map(&:sha) merge_request.merge_request_context_commits.where(sha: commit_ids).delete_all end |
Instance Method Details
#to_commit ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/models/merge_request_context_commit.rb', line 41 def to_commit # Here we are storing the commit sha because to_hash removes the sha parameter and we lose # the reference, this happens because we are storing the ID in db and the Commit class replaces # id with sha and removes it, so in our case it will be some incremented integer which is not # what we want commit_hash = attributes.except('id').to_hash commit_hash['id'] = sha Commit.from_hash(commit_hash, merge_request.target_project) end |