From 0fcb489542549c422036edebf4999ab434d8d45b Mon Sep 17 00:00:00 2001 From: Stuart Owen Date: Tue, 2 Nov 2021 13:33:02 +0000 Subject: [PATCH] version parent may not exist rather than a nil id #770 --- lib/tasks/seek_upgrades.rake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tasks/seek_upgrades.rake b/lib/tasks/seek_upgrades.rake index a38ca29ad3..dcbde83d59 100644 --- a/lib/tasks/seek_upgrades.rake +++ b/lib/tasks/seek_upgrades.rake @@ -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" @@ -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