-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a report for version mismatches.
refs #5074
- Loading branch information
1 parent
3156cb5
commit c7853ce
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |