Class: BulkImports::Tracker

Inherits:
ApplicationRecord show all
Includes:
AfterCommitQueue
Defined in:
app/models/bulk_imports/tracker.rb

Constant Summary collapse

DEFAULT_PAGE_SIZE =
500

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Instance Method Summary collapse

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, nullable_column?, 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 ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Instance Method Details

#checksumsObject



108
109
110
111
112
113
# File 'app/models/bulk_imports/tracker.rb', line 108

def checksums
  return unless file_extraction_pipeline?

  # Return cached counters until they expire
  { importing_relation => cached_checksums || persisted_checksums }
end

#checksums_empty?Boolean

Returns:

  • (Boolean)


115
116
117
118
119
120
121
# File 'app/models/bulk_imports/tracker.rb', line 115

def checksums_empty?
  return true unless checksums

  sums = checksums[importing_relation]

  sums[:source] == 0 && sums[:fetched] == 0 && sums[:imported] == 0
end

#importing_relationObject



123
124
125
# File 'app/models/bulk_imports/tracker.rb', line 123

def importing_relation
  pipeline_class.relation.to_sym
end

#pipeline_classObject



41
42
43
44
45
46
47
# File 'app/models/bulk_imports/tracker.rb', line 41

def pipeline_class
  unless entity.pipeline_exists?(pipeline_name)
    raise BulkImports::Error, "'#{pipeline_name}' is not a valid BulkImport Pipeline"
  end

  pipeline_name.constantize
end

#propagate_cancelObject



127
128
129
# File 'app/models/bulk_imports/tracker.rb', line 127

def propagate_cancel
  batches.each(&:cancel)
end