Class: Gitlab::GithubImport::Importer::LabelLinksImporter
- Inherits:
-
Object
- Object
- Gitlab::GithubImport::Importer::LabelLinksImporter
- Defined in:
- lib/gitlab/github_import/importer/label_links_importer.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#issue ⇒ Object
readonly
Returns the value of attribute issue.
-
#label_finder ⇒ Object
readonly
Returns the value of attribute label_finder.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #create_labels ⇒ Object
- #execute ⇒ Object
- #find_target_id ⇒ Object
-
#initialize(issue, project, client) ⇒ LabelLinksImporter
constructor
issue - An instance of ‘Gitlab::GithubImport::Representation::Issue` project - An instance of `Project` client - An instance of `Gitlab::GithubImport::Client`.
Constructor Details
#initialize(issue, project, client) ⇒ LabelLinksImporter
issue - An instance of ‘Gitlab::GithubImport::Representation::Issue` project - An instance of `Project` client - An instance of `Gitlab::GithubImport::Client`
12 13 14 15 16 17 |
# File 'lib/gitlab/github_import/importer/label_links_importer.rb', line 12 def initialize(issue, project, client) @issue = issue @project = project @client = client @label_finder = LabelFinder.new(project) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/gitlab/github_import/importer/label_links_importer.rb', line 7 def client @client end |
#issue ⇒ Object (readonly)
Returns the value of attribute issue.
7 8 9 |
# File 'lib/gitlab/github_import/importer/label_links_importer.rb', line 7 def issue @issue end |
#label_finder ⇒ Object (readonly)
Returns the value of attribute label_finder.
7 8 9 |
# File 'lib/gitlab/github_import/importer/label_links_importer.rb', line 7 def label_finder @label_finder end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
7 8 9 |
# File 'lib/gitlab/github_import/importer/label_links_importer.rb', line 7 def project @project end |
Instance Method Details
#create_labels ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gitlab/github_import/importer/label_links_importer.rb', line 23 def create_labels time = Time.zone.now items = [] target_id = find_target_id return if target_id.blank? issue.label_names.each do |label_name| # Although unlikely it's technically possible for an issue to be # given a label that was created and assigned after we imported all # the project's labels. next unless (label_id = label_finder.id_for(label_name)) items << LabelLink.new( label_id: label_id, target_id: target_id, target_type: issue.issuable_type, created_at: time, updated_at: time ) end LabelLink.bulk_insert!(items) end |
#execute ⇒ Object
19 20 21 |
# File 'lib/gitlab/github_import/importer/label_links_importer.rb', line 19 def execute create_labels end |
#find_target_id ⇒ Object
48 49 50 |
# File 'lib/gitlab/github_import/importer/label_links_importer.rb', line 48 def find_target_id GithubImport::IssuableFinder.new(project, issue).database_id end |