Skip to content

Commit

Permalink
Adds a report for version mismatches.
Browse files Browse the repository at this point in the history
refs #5074
  • Loading branch information
justinlittman committed Jun 7, 2024
1 parent 3156cb5 commit c7853ce
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app/reports/preservation_versions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

# Compare SDR versions against Preservation versions
# https://github.com/sul-dlss/dor-services-app/issues/5074
# Invoke via:
# bin/rails r -e production "PreservationVersions.report"
class PreservationVersions
def self.report
output_file = 'preservation_versions_report.csv'

CSV.open(output_file, 'w') do |csv|
csv << %w[druid version preservation_version]
num_objs = RepositoryObject.count
RepositoryObject.joins(:head_version).call(:external_identifier, :version).each_with_index do |data, index|
druid, version = data
puts "#{index + 1} of #{num_objs} : #{druid}"
begin
preservation_version = Preservation::Client.objects.current_version(druid)
rescue Preservation::Client::NotFoundError
preservation_version = nil
end
csv << [druid, version, preservation_version] if preservation_version != version
end
end
end
end

0 comments on commit c7853ce

Please sign in to comment.