hekenga 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/hekenga/migration.rb +9 -7
- data/lib/hekenga/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58c5fc1783be650fcaeecf3dee14fc806d6243fa
|
4
|
+
data.tar.gz: 3a5718418b2509d2b3f720cc29557c8455be2aba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01033bc170ffd1f5c83e5271eb682461e1adf53792a62336fe11d9382d82801492818eb94fc677c9a2ab5d16b9e9393198d88a5ecb5eb1ffe56637d471fb6553
|
7
|
+
data.tar.gz: ecd32414846a4e0f28f92b24550bf5838ebfd2768105651e31bef2b0a5113154c20ae0bacf1b857cf0c8712e36f6bef3815d4a6bfad2dcd3415096d565b4c9a6
|
data/lib/hekenga/migration.rb
CHANGED
@@ -69,7 +69,6 @@ module Hekenga
|
|
69
69
|
end
|
70
70
|
def perform_task!(task_idx = 0, scope = nil)
|
71
71
|
task = @tasks[task_idx] or return
|
72
|
-
@active_task = task
|
73
72
|
@active_idx = task_idx
|
74
73
|
case task
|
75
74
|
when Hekenga::SimpleTask
|
@@ -306,6 +305,9 @@ module Hekenga
|
|
306
305
|
@context.instance_exec(record, &block)
|
307
306
|
end
|
308
307
|
end
|
308
|
+
def deep_clone(record)
|
309
|
+
record.as_document.deep_dup
|
310
|
+
end
|
309
311
|
def process_batch(task, records)
|
310
312
|
@skipped = []
|
311
313
|
to_persist = []
|
@@ -317,7 +319,7 @@ module Hekenga
|
|
317
319
|
log_skipped(task, filtered[false]) if filtered[false]
|
318
320
|
return unless filtered[true]
|
319
321
|
filtered[true].map.with_index do |record, idx|
|
320
|
-
original_record =
|
322
|
+
original_record = deep_clone(record)
|
321
323
|
begin
|
322
324
|
task.up!(@context, record)
|
323
325
|
rescue => e
|
@@ -325,7 +327,7 @@ module Hekenga
|
|
325
327
|
@skipped = filtered[true][idx+1..-1]
|
326
328
|
return
|
327
329
|
end
|
328
|
-
if validate_record(record)
|
330
|
+
if validate_record(task, record)
|
329
331
|
to_persist.push(record)
|
330
332
|
fallbacks.push(original_record)
|
331
333
|
else
|
@@ -422,7 +424,7 @@ module Hekenga
|
|
422
424
|
}, Hekenga::Failure::Write)
|
423
425
|
log_cancel!
|
424
426
|
end
|
425
|
-
def failed_validation!(record)
|
427
|
+
def failed_validation!(task, record)
|
426
428
|
log.add_failure({
|
427
429
|
doc_id: record.id,
|
428
430
|
errs: record.errors.full_messages,
|
@@ -430,18 +432,18 @@ module Hekenga
|
|
430
432
|
}, Hekenga::Failure::Validation)
|
431
433
|
log.set(error: true)
|
432
434
|
log.incr_and_return(processed: 1, unvalid: 1)
|
433
|
-
if
|
435
|
+
if task.invalid_strategy == :cancel
|
434
436
|
log_cancel!
|
435
437
|
else
|
436
438
|
check_for_completion
|
437
439
|
end
|
438
440
|
end
|
439
|
-
def validate_record(record)
|
441
|
+
def validate_record(task, record)
|
440
442
|
# TODO - ability to skip validation
|
441
443
|
if record.valid?
|
442
444
|
true
|
443
445
|
else
|
444
|
-
failed_validation!(record)
|
446
|
+
failed_validation!(task, record)
|
445
447
|
false
|
446
448
|
end
|
447
449
|
end
|
data/lib/hekenga/version.rb
CHANGED