Class: Hekenga::TaskSplitter
- Inherits:
-
Object
- Object
- Hekenga::TaskSplitter
- Defined in:
- lib/hekenga/task_splitter.rb
Instance Attribute Summary collapse
-
#executor_key ⇒ Object
readonly
Returns the value of attribute executor_key.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(record, executor_key) ⇒ TaskSplitter
constructor
A new instance of TaskSplitter.
Constructor Details
#initialize(record, executor_key) ⇒ TaskSplitter
Returns a new instance of TaskSplitter.
5 6 7 8 |
# File 'lib/hekenga/task_splitter.rb', line 5 def initialize(record, executor_key) @record = record @executor_key = executor_key end |
Instance Attribute Details
#executor_key ⇒ Object (readonly)
Returns the value of attribute executor_key.
3 4 5 |
# File 'lib/hekenga/task_splitter.rb', line 3 def executor_key @executor_key end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
3 4 5 |
# File 'lib/hekenga/task_splitter.rb', line 3 def record @record end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/hekenga/task_splitter.rb', line 10 def call return if record.failed_ids.blank? && record.invalid_ids.blank? Hekenga::DocumentTaskRecord.new.tap do |new_record| new_record.migration_key = record.migration_key new_record.task_idx = record.task_idx new_record.executor_key = executor_key new_record.ids = record.failed_ids | record.invalid_ids new_record.save! record.ids -= new_record.ids record.failed_ids = [] record.invalid_ids = [] record.id_count = record.ids.count record.stats = record.stats.merge('failed' => 0, 'invalid' => 0) record.save! end end |