2020-10-15 11:08:45 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-10-21 17:09:00 -04:00
|
|
|
# The BulkImport model links all models required for a bulk import of groups and
|
|
|
|
# projects to a GitLab instance. It associates the import with the responsible
|
|
|
|
# user.
|
2020-10-15 11:08:45 -04:00
|
|
|
class BulkImport < ApplicationRecord
|
2021-06-25 08:07:44 -04:00
|
|
|
MINIMUM_GITLAB_MAJOR_VERSION = 14
|
|
|
|
|
2020-10-15 11:08:45 -04:00
|
|
|
belongs_to :user, optional: false
|
|
|
|
|
|
|
|
has_one :configuration, class_name: 'BulkImports::Configuration'
|
|
|
|
has_many :entities, class_name: 'BulkImports::Entity'
|
|
|
|
|
|
|
|
validates :source_type, :status, presence: true
|
|
|
|
|
|
|
|
enum source_type: { gitlab: 0 }
|
|
|
|
|
|
|
|
state_machine :status, initial: :created do
|
|
|
|
state :created, value: 0
|
2020-10-23 11:08:42 -04:00
|
|
|
state :started, value: 1
|
|
|
|
state :finished, value: 2
|
|
|
|
state :failed, value: -1
|
|
|
|
|
|
|
|
event :start do
|
|
|
|
transition created: :started
|
|
|
|
end
|
|
|
|
|
|
|
|
event :finish do
|
|
|
|
transition started: :finished
|
|
|
|
end
|
|
|
|
|
|
|
|
event :fail_op do
|
|
|
|
transition any => :failed
|
|
|
|
end
|
2020-10-15 11:08:45 -04:00
|
|
|
end
|
2021-07-05 08:08:33 -04:00
|
|
|
|
|
|
|
def self.all_human_statuses
|
|
|
|
state_machine.states.map(&:human_name)
|
|
|
|
end
|
2020-10-15 11:08:45 -04:00
|
|
|
end
|