2020-03-26 08:07:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module JiraImport
|
|
|
|
class BaseImporter
|
2020-04-30 11:09:46 -04:00
|
|
|
attr_reader :project, :client, :formatter, :jira_project_key, :running_import
|
2020-03-26 08:07:48 -04:00
|
|
|
|
|
|
|
def initialize(project)
|
2020-06-02 08:08:33 -04:00
|
|
|
Gitlab::JiraImport.validate_project_settings!(project)
|
2020-03-26 08:07:48 -04:00
|
|
|
|
2020-04-30 11:09:46 -04:00
|
|
|
@running_import = project.latest_jira_import
|
|
|
|
@jira_project_key = running_import&.jira_project_key
|
2020-04-21 11:21:10 -04:00
|
|
|
|
2020-03-26 08:07:48 -04:00
|
|
|
raise Projects::ImportService::Error, _('Unable to find Jira project to import data from.') unless @jira_project_key
|
|
|
|
|
|
|
|
@project = project
|
2021-06-18 11:10:16 -04:00
|
|
|
@client = project.jira_integration.client
|
2020-03-26 08:07:48 -04:00
|
|
|
@formatter = Gitlab::ImportFormatter.new
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def imported_items_cache_key
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def mark_as_imported(id)
|
|
|
|
Gitlab::Cache::Import::Caching.set_add(imported_items_cache_key, id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def already_imported?(id)
|
|
|
|
Gitlab::Cache::Import::Caching.set_includes?(imported_items_cache_key, id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|