diff options
Diffstat (limited to 'lib/gitlab/jira_import/labels_importer.rb')
-rw-r--r-- | lib/gitlab/jira_import/labels_importer.rb | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/gitlab/jira_import/labels_importer.rb b/lib/gitlab/jira_import/labels_importer.rb index 142a2da5be9..35c434e48a4 100644 --- a/lib/gitlab/jira_import/labels_importer.rb +++ b/lib/gitlab/jira_import/labels_importer.rb @@ -11,28 +11,19 @@ module Gitlab end def execute - create_import_label(project) + cache_import_label(project) import_jira_labels end private - def create_import_label(project) - label = Labels::CreateService.new(build_label_attrs(project)).execute(project: project) - raise Projects::ImportService::Error, _('Failed to create import label for jira import.') unless label + def cache_import_label(project) + label = project.jira_imports.by_jira_project_key(jira_project_key).last.label + raise Projects::ImportService::Error, _('Failed to find import label for jira import.') unless label JiraImport.cache_import_label_id(project.id, label.id) end - def build_label_attrs(project) - import_start_time = project&.import_state&.last_update_started_at || Time.now - title = "jira-import-#{import_start_time.strftime('%Y-%m-%d-%H-%M-%S')}" - description = "Label for issues that were imported from jira on #{import_start_time.strftime('%Y-%m-%d %H:%M:%S')}" - color = "#{Label.color_for(title)}" - - { title: title, description: description, color: color } - end - def import_jira_labels # todo: import jira labels, see https://gitlab.com/gitlab-org/gitlab/-/issues/212651 job_waiter |