Sha256: 217893ed1356fa9624eaafa868ba3628025312396d06fc00ccfee67431cb6f7d
Contents?: true
Size: 959 Bytes
Versions: 2
Compression:
Stored size: 959 Bytes
Contents
# frozen_string_literal: true class Backup class MoveLogs attr_reader :config def initialize(config, db_helper, dry_run_reporter=nil) @config = config @dry_run_reporter = dry_run_reporter @db_helper = db_helper end def run return run_dry if @config.dry_run @db_helper.connect_db(@config.database_url) Log.order(:id).in_batches(of: @config.limit.to_i).map do |logs_batch| process_logs_batch(logs_batch) end end def process_logs_batch(logs_batch) log_hashes = logs_batch.as_json @db_helper.connect_db(@config.destination_db_url) log_hashes.each do |log_hash| new_log = Log.new(log_hash) new_log.save! end @db_helper.connect_db(@config.database_url) logs_batch.each(&:destroy) GC.start end def run_dry ids = Log.order(:id).map(&:id) @dry_run_reporter.add_to_report(:logs, *ids) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
travis-backup-0.3.0 | lib/backup/move_logs.rb |
travis-backup-0.2.1 | lib/backup/move_logs.rb |