Skip to content

Commit

Permalink
version parent may not exist rather than a nil id #770
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Nov 2, 2021
1 parent dc1f984 commit 0fcb489
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/tasks/seek_upgrades.rake
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace :seek do
puts "... Setting version visibility..."
disable_authorization_checks do
[DataFile::Version, Document::Version, Model::Version, Node::Version, Presentation::Version, Sop::Version, Workflow::Version].each do |klass|
scope = klass.where(visibility: nil).where.not(parent:nil)
scope = klass.where(visibility: nil)
count = scope.count
if count == 0
puts " No #{klass.name} with unset visibility found, skipping"
Expand All @@ -137,6 +137,7 @@ namespace :seek do
check_doi = klass.attribute_method?(:doi)
# Go through all versions and set the "latest" versions to publicly visible
scope.find_each do |version|
next if version.parent.nil?
if version.latest_version? || check_doi && version.doi.present?
version.update_column(:visibility, Seek::ExplicitVersioning::VISIBILITY_INV[:public])
else
Expand Down

0 comments on commit 0fcb489

Please sign in to comment.