Module: Gitlab::GithubImport::StageMethods

Instance Method Summary collapse

Instance Method Details

#find_project(id) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


24
25
26
27
28
# File 'app/workers/concerns/gitlab/github_import/stage_methods.rb', line 24

def find_project(id)
  # If the project has been marked as failed we want to bail out
  # automatically.
  Project.joins_import_state.where(import_state: { status: :started }).find_by(id: id)
end

#perform(project_id) ⇒ Object

project_id - The ID of the GitLab project to import the data into.


7
8
9
10
11
12
13
# File 'app/workers/concerns/gitlab/github_import/stage_methods.rb', line 7

def perform(project_id)
  return unless (project = find_project(project_id))

  client = GithubImport.new_client_for(project)

  try_import(client, project)
end

#try_import(client, project) ⇒ Object

client - An instance of Gitlab::GithubImport::Client. project - An instance of Project.


17
18
19
20
21
# File 'app/workers/concerns/gitlab/github_import/stage_methods.rb', line 17

def try_import(client, project)
  import(client, project)
rescue RateLimitError
  self.class.perform_in(client.rate_limit_resets_in, project.id)
end