Class: Gitlab::JiraImport::HandleLabelsService

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/jira_import/handle_labels_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(project, jira_labels) ⇒ HandleLabelsService

Returns a new instance of HandleLabelsService.


6
7
8
9
# File 'lib/gitlab/jira_import/handle_labels_service.rb', line 6

def initialize(project, jira_labels)
  @project = project
  @jira_labels = jira_labels
end

Instance Method Details

#executeObject


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/jira_import/handle_labels_service.rb', line 11

def execute
  return if jira_labels.blank?

  existing_labels = LabelsFinder.new(nil, project: project, title: jira_labels)
    .execute(skip_authorization: true).select(:id, :name)
  new_labels = create_missing_labels(existing_labels)

  label_ids = existing_labels.map(&:id)
  label_ids += new_labels if new_labels.present?
  label_ids
end