Module: Kiba::Extend::Mixins::IterativeCleanup::Jobs::BaseJobCleaned

Defined in:
lib/kiba/extend/mixins/iterative_cleanup/jobs/base_job_cleaned.rb

Overview

Since:

  • 4.0.0

Class Method Summary collapse

Class Method Details

.get_lookups(mod) ⇒ Object

Since:

  • 4.0.0



22
23
24
25
26
# File 'lib/kiba/extend/mixins/iterative_cleanup/jobs/base_job_cleaned.rb', line 22

def get_lookups(mod)
  base = []
  base << mod.corrections_job_key if mod.cleanup_done?
  base.select { |job| Kiba::Extend::Job.output?(job) }
end

.get_xforms(mod) ⇒ Object

Since:

  • 4.0.0



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/kiba/extend/mixins/iterative_cleanup/jobs/base_job_cleaned.rb', line 28

def get_xforms(mod)
  base = []
  if mod.respond_to?(:base_job_cleaned_pre_xforms)
    base << mod.base_job_cleaned_pre_xforms
  end
  base << xforms(mod)
  if mod.respond_to?(:base_job_cleaned_post_xforms)
    base << mod.base_job_cleaned_post_xforms
  end
  base
end

.job(mod:) ⇒ Object

Since:

  • 4.0.0



11
12
13
14
15
16
17
18
19
20
# File 'lib/kiba/extend/mixins/iterative_cleanup/jobs/base_job_cleaned.rb', line 11

def job(mod:)
  Kiba::Extend::Jobs::Job.new(
    files: {
      source: mod.base_job,
      destination: mod.base_job_cleaned_job_key,
      lookup: get_lookups(mod)
    },
    transformer: get_xforms(mod)
  )
end

.xforms(mod) ⇒ Object

Since:

  • 4.0.0



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/kiba/extend/mixins/iterative_cleanup/jobs/base_job_cleaned.rb', line 40

def xforms(mod)
  bind = binding

  Kiba.job_segment do
    job = bind.receiver
    lookups = job.send(:get_lookups, mod)

    transform Append::NilFields,
      fields: mod.worksheet_add_fields

    if mod.cleanup_done? && lookups.any?(mod.corrections_job_key)
      transform Fingerprint::MergeCorrected,
        lookup: method(mod.corrections_job_key).call,
        keycolumn: mod.orig_values_identifier,
        todofield: :corrected
    end

    transform Fingerprint::Add,
      target: :clean_fingerprint,
      fields: mod.fingerprint_fields
  end
end