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 ResetOnUnionError
ResetOnUnionError::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
#parent_ids, #referenced_by, #to_hash
Methods inherited from ApplicationRecord
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, 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 SensitiveSerializableHash
Class Method Details
.bulk_insert(rows, **args) ⇒ Object
create MergeRequestContextCommit by given commit sha and it’s diff file record
28 29 30 |
# File 'app/models/merge_request_context_commit.rb', line 28 def self.bulk_insert(rows, **args) 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
22 23 24 25 |
# File 'app/models/merge_request_context_commit.rb', line 22 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
32 33 34 35 36 37 38 39 40 |
# File 'app/models/merge_request_context_commit.rb', line 32 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 |