Class: BulkImports::Tracker

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

Constant Summary collapse

DEFAULT_PAGE_SIZE =
500
STALE_AFTER =
4.hours

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

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

#serializable_hash

Class Method Details

.stage_running?(entity_id, stage) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
# File 'app/models/bulk_imports/tracker.rb', line 36

def self.stage_running?(entity_id, stage)
  where(stage: stage, bulk_import_entity_id: entity_id)
    .with_status(:created, :enqueued, :started)
    .exists?
end

Instance Method Details

#pipeline_classObject



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

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

#stale?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'app/models/bulk_imports/tracker.rb', line 94

def stale?
  created_at < STALE_AFTER.ago
end