diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /app/models/bulk_imports/entity.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'app/models/bulk_imports/entity.rb')
-rw-r--r-- | app/models/bulk_imports/entity.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/models/bulk_imports/entity.rb b/app/models/bulk_imports/entity.rb index 34030e079c7..a4d0b7485ba 100644 --- a/app/models/bulk_imports/entity.rb +++ b/app/models/bulk_imports/entity.rb @@ -30,6 +30,11 @@ class BulkImports::Entity < ApplicationRecord class_name: 'BulkImports::Tracker', foreign_key: :bulk_import_entity_id + has_many :failures, + class_name: 'BulkImports::Failure', + inverse_of: :entity, + foreign_key: :bulk_import_entity_id + validates :project, absence: true, if: :group validates :group, absence: true, if: :project validates :source_type, :source_full_path, :destination_name, @@ -52,6 +57,7 @@ class BulkImports::Entity < ApplicationRecord event :finish do transition started: :finished + transition failed: :failed end event :fail_op do @@ -59,6 +65,25 @@ class BulkImports::Entity < ApplicationRecord end end + def update_tracker_for(relation:, has_next_page:, next_page: nil) + attributes = { + relation: relation, + has_next_page: has_next_page, + next_page: next_page, + bulk_import_entity_id: id + } + + trackers.upsert(attributes, unique_by: %i[bulk_import_entity_id relation]) + end + + def has_next_page?(relation) + trackers.find_by(relation: relation)&.has_next_page + end + + def next_page_for(relation) + trackers.find_by(relation: relation)&.next_page + end + private def validate_parent_is_a_group |