lib/chronicle/etl/job_log.rb in chronicle-etl-0.5.5 vs lib/chronicle/etl/job_log.rb in chronicle-etl-0.6.1
- old
+ new
@@ -7,17 +7,17 @@
# we found is (to use as a cursor for the next time)
class JobLog
extend Forwardable
attr_accessor :job,
- :job_id,
- :last_id,
- :highest_timestamp,
- :num_records_processed,
- :started_at,
- :finished_at,
- :success
+ :job_id,
+ :last_id,
+ :highest_timestamp,
+ :num_records_processed,
+ :started_at,
+ :finished_at,
+ :success
def_delegators :@job, :save_log?
# Create a new JobLog for a given Job
def initialize
@@ -26,15 +26,15 @@
yield self if block_given?
end
# Log the result of a single transformation in a job
# @param transformer [Chronicle::ETL::Tranformer] The transformer that ran
- def log_transformation(transformer)
- @last_id = transformer.id if transformer.id
+ def log_transformation(_transformer)
+ # @last_id = transformer.id if transformer.id
# Save the highest timestamp that we've encountered so far
- @highest_timestamp = [transformer.timestamp, @highest_timestamp].compact.max if transformer.timestamp
+ # @highest_timestamp = [transformer.timestamp, @highest_timestamp].compact.max if transformer.timestamp
# TODO: a transformer might yield nil. We might also want certain transformers to explode
# records into multiple new ones. Therefore, this this variable will need more subtle behaviour
@num_records_processed += 1
end
@@ -52,17 +52,17 @@
def error
@finished_at = Time.now
end
- def job= job
+ def job=(job)
@job = job
@job_id = job.id
end
def duration
- return unless @finished_at
+ return unless @finished_at && @started_at
@finished_at - @started_at
end
# Take a JobLog's instance variables and turn them into a hash representation
@@ -76,17 +76,15 @@
finished_at: @finished_at,
success: @success
}
end
- private
-
# Create a new JobLog and set its instance variables from a serialized hash
- def self.build_from_serialized attrs
+ def self.build_from_serialized(attrs)
attrs.delete(:id)
new do |job_log|
attrs.each do |key, value|
- setter = "#{key.to_s}=".to_sym
+ setter = :"#{key}="
job_log.send(setter, value)
end
end
end
end