Skip to content

Commit

Permalink
Merge pull request #308 from sul-dlss/seeding-timestamp-statements
Browse files Browse the repository at this point in the history
add timestamps to log and puts statements for seeding and M2C
  • Loading branch information
jmartin-sul committed Nov 10, 2017
2 parents d110dc9 + 81ef743 commit d80ccec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Layout/SpaceInsideBrackets:
Metrics/AbcSize:
Exclude:
- 'app/services/preserved_object_handler.rb' # 2 methods but they seem readable
- 'lib/audit/moab_to_catalog.rb' # #seed_from_disk is decidedly readable

Metrics/BlockLength:
Exclude:
Expand Down Expand Up @@ -94,6 +95,10 @@ Rails/FilePath:
Rails/HasAndBelongsToMany:
Enabled: false

Rails/Output:
Exclude:
- 'lib/audit/moab_to_catalog.rb' # yes, we want to use puts statements

Rails/SkipsModelValidations:
Exclude:
- 'app/services/preserved_object_handler.rb' # we're using touch on purpose
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require_relative 'lib/audit/moab_to_catalog'
desc 'populate the catalog with the contents of the online storage roots'
task seed_catalog: :environment do
m2c = MoabToCatalog.new
puts "Seeding the database from all storage roots..."
puts "#{Time.now.utc.iso8601} Seeding the database from all storage roots..."
m2c.seed_from_disk
puts "Done"
puts "#{Time.now.utc.iso8601} Done"
end
12 changes: 12 additions & 0 deletions lib/audit/moab_to_catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,26 @@ def self.seed_catalog(storage_dir)
# Shameless green. In order to run several seed "jobs" in parallel, we would have to refactor.
def seed_from_disk
Settings.moab.storage_roots.each do |storage_root|
start_msg = "#{Time.now.utc.iso8601} Seeding starting for #{storage_root}"
puts start_msg
Rails.logger.info start_msg
self.class.seed_catalog("#{storage_root[1]}/#{Settings.moab.storage_trunk}")
end_msg = "#{Time.now.utc.iso8601} Seeding ended for #{storage_root}"
puts end_msg
Rails.logger.info end_msg
end
end

# Shameless green. Code duplication with seed_from_disk
def check_existence_from_disk
Settings.moab.storage_roots.each do |storage_root|
start_msg = "#{Time.now.utc.iso8601} Check_existence starting for #{storage_root}"
puts start_msg
Rails.logger.info start_msg
self.class.check_existence("#{storage_root[1]}/#{Settings.moab.storage_trunk}")
end_msg = "#{Time.now.utc.iso8601} Check_existence ended for #{storage_root}"
puts end_msg
Rails.logger.info end_msg
end
end
end

0 comments on commit d80ccec

Please sign in to comment.