Class: JiraImportState
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- JiraImportState
- Defined in:
- app/models/jira_import_state.rb
Constant Summary collapse
- ERROR_MESSAGE_SIZE =
1000 characters limit
1000
- STATUSES =
{ initial: 0, scheduled: 1, started: 2, failed: 3, finished: 4 }.freeze
Constants inherited from ApplicationRecord
Constants included from ResetOnUnionError
ResetOnUnionError::MAX_RESET_PERIOD
Instance Method Summary collapse
- #in_progress? ⇒ Boolean
- #mark_as_failed(error_message) ⇒ Object
- #non_initial? ⇒ Boolean
- #store_issue_counts ⇒ Object
Methods included from AfterCommitQueue
#run_after_commit, #run_after_commit_or_now
Methods inherited from ApplicationRecord
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
Methods included from SensitiveSerializableHash
Instance Method Details
#in_progress? ⇒ Boolean
89 90 91 |
# File 'app/models/jira_import_state.rb', line 89 def in_progress? scheduled? || started? end |
#mark_as_failed(error_message) ⇒ Object
113 114 115 116 117 118 119 |
# File 'app/models/jira_import_state.rb', line 113 def mark_as_failed() = Gitlab::UrlSanitizer.sanitize() do_fail(error_message: ) rescue ActiveRecord::ActiveRecordError => e Gitlab::AppLogger.error("Error setting import status to failed: #{e.}. Original error: #{}") end |
#non_initial? ⇒ Boolean
93 94 95 |
# File 'app/models/jira_import_state.rb', line 93 def non_initial? !initial? end |
#store_issue_counts ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'app/models/jira_import_state.rb', line 97 def store_issue_counts import_label_id = Gitlab::JiraImport.get_import_label_id(project.id) failed_to_import_count = Gitlab::JiraImport.issue_failures(project.id) successfully_imported_count = project.issues.with_label_ids(import_label_id).count total_issue_count = successfully_imported_count + failed_to_import_count update( { failed_to_import_count: failed_to_import_count, imported_issues_count: successfully_imported_count, total_issue_count: total_issue_count } ) end |