Module: Gitlab::GithubImport::ObjectImporter
- Extended by:
- ActiveSupport::Concern
- Included in:
- ImportDiffNoteWorker, ImportIssueWorker, ImportLfsObjectWorker, ImportNoteWorker, ImportPullRequestMergedByWorker, ImportPullRequestReviewWorker, ImportPullRequestWorker
- Defined in:
- app/workers/concerns/gitlab/github_import/object_importer.rb
Overview
ObjectImporter defines the base behaviour for every Sidekiq worker that imports a single resource such as a note or pull request.
Instance Method Summary collapse
-
#import(project, client, hash) ⇒ Object
project - An instance of `Project` to import the data into.
-
#importer_class ⇒ Object
Returns the class to use for importing the object.
- #object_type ⇒ Object
-
#representation_class ⇒ Object
Returns the representation class to use for the object.
Instance Method Details
#import(project, client, hash) ⇒ Object
project - An instance of `Project` to import the data into. client - An instance of `Gitlab::GithubImport::Client` hash - A Hash containing the details of the object to import.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/workers/concerns/gitlab/github_import/object_importer.rb', line 25 def import(project, client, hash) object = representation_class.from_json_hash(hash) # To better express in the logs what object is being imported. self.github_identifiers = object.github_identifiers info(project.id, message: 'starting importer') importer_class.new(object, project, client).execute Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :imported) info(project.id, message: 'importer finished') rescue NoMethodError => e # This exception will be more useful in development when a new # Representation is created but the developer forgot to add a # `:github_identifiers` field. Gitlab::Import::ImportFailureService.track( project_id: project.id, error_source: importer_class.name, exception: e, fail_import: true ) raise(e) rescue StandardError => e Gitlab::Import::ImportFailureService.track( project_id: project.id, error_source: importer_class.name, exception: e ) end |
#importer_class ⇒ Object
Returns the class to use for importing the object.
68 69 70 |
# File 'app/workers/concerns/gitlab/github_import/object_importer.rb', line 68 def importer_class raise NotImplementedError end |
#object_type ⇒ Object
57 58 59 |
# File 'app/workers/concerns/gitlab/github_import/object_importer.rb', line 57 def object_type raise NotImplementedError end |
#representation_class ⇒ Object
Returns the representation class to use for the object. This class must define the class method `from_json_hash`.
63 64 65 |
# File 'app/workers/concerns/gitlab/github_import/object_importer.rb', line 63 def representation_class raise NotImplementedError end |