Sha256: 35674ab2f6475b556d1ebc52b42a296225e19e9a19587b7ca447989d80d108e0

Contents?: true

Size: 673 Bytes

Versions: 4

Compression:

Stored size: 673 Bytes

Contents

require_relative '../all_jobs_shared'

class DateDiffJob < Remi::Job

  param(:measure) { :days }

  source :source_data do
    fields(
      {
        :date1 => { type: :date, format: '%Y-%m-%d' },
        :date2 => { type: :date, format: '%Y-%m-%d' }
      }
    )
  end

  target :target_data

  transform :main do
    Remi::SourceToTargetMap.apply(source_data.df, target_data.df) do
      map source(:date1, :date2) .target(:difference)
        .transform(->(row) {
          row[:date1] = Date.strptime(row[:date1])
          row[:date2] = Date.strptime(row[:date2])
        })
        .transform(Remi::Transform::DateDiff.new(job.params[:measure]))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
remi-0.3.3 jobs/transforms/date_diff_job.rb
remi-0.3.2 jobs/transforms/date_diff_job.rb
remi-0.3.1 jobs/transforms/date_diff_job.rb
remi-0.3.0 jobs/transforms/date_diff_job.rb