Sha256: 5fbb0ba0d2f72a49df97dcb00c91ae06b4c7149c52bc88c692a050f6a92dba05
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
require 'stratify/logger' module Stratify class Archiver attr_reader :collector def initialize(collector) @collector = collector end def run collect_activities ensure record_collection_statistics end protected def collect_activities collector.activities.each do |activity| document_activity_source(activity) persist_activity(activity) end end def document_activity_source(activity) activity.source = collector.source end def persist_activity(activity) # Since we run the collectors frequently, it is very common to encounter # objects that we have already imported. If this activity is a duplicate # of an existing object, then we skip importing this activity. return if activity.duplicate? unless activity.save Stratify.logger.error("Failed to persist activity: #{activity}.\nValidation errors: #{activity.errors}") end end def record_collection_statistics collector.update_attribute :last_ran_at, Time.now end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
stratify-base-0.1.3 | lib/stratify/archiver.rb |
stratify-base-0.1.2 | lib/stratify/archiver.rb |
stratify-base-0.1.0 | lib/stratify/archiver.rb |