Skip to content

Commit

Permalink
TDLR-2526 - final changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoodmon committed Jan 18, 2024
1 parent 024919d commit 6af75f4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 97 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ gem 'omniauth', '1.9.1'
gem 'omniauth-shibboleth'
gem 'whenever', require: false

gem 'tufts-curation', git: 'https://github.com/TuftsUniversity/tufts-curation', ref: '9c6bf20'
gem 'tufts-curation', git: 'https://github.com/TuftsUniversity/tufts-curation', ref: '1e887ee'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
95 changes: 0 additions & 95 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ task compute_handles2: :environment do
model = 'images/'
when "Pdf"
model = 'pdfs/'
when "Ead"
model = 'eads/'
when "Rcr"
model = 'rcrs/'
when "Audio"
Expand Down Expand Up @@ -208,8 +206,6 @@ task compute_handles: :environment do
model = 'images/'
when "Pdf"
model = 'pdfs/'
when "Ead"
model = 'eads/'
when "Rcr"
model = 'rcrs/'
when "Audio"
Expand Down Expand Up @@ -241,11 +237,6 @@ task collection_by_title: :environment do
begin
puts "PROCESSING PID : #{pid}"
obj = ActiveFedora::Base.find(pid)
if obj.class.to_s == "Ead"
puts "FOUND EAD NEXT"
next
end

col = Collection.find(title)
obj.member_of_collections = [col]
obj.save!
Expand All @@ -255,22 +246,6 @@ task collection_by_title: :environment do
end
end

desc "add to collection"
task add_to_collection_descriptions: :environment do
puts "Loading File"
CSV.foreach("/usr/local/hydra/epigaea/eads.txt", headers: false, header_converters: :symbol, encoding: "ISO8859-1:utf-8") do |row|
pid = row[0]
obj = ActiveFedora::Base.find(pid)
col = Collection.find("vd66vz89n")

obj.member_of_collections << col

obj.save!
rescue ActiveFedora::ObjectNotFoundError
puts "ERROR not found #{pid}"
end
end

desc "safely add to collection"
task safe_add_to_collection: :environment do
puts "Loading File"
Expand Down Expand Up @@ -320,36 +295,6 @@ task remove_from_collection: :environment do
end
end

desc "ead matching"
task ead_matching: :environment do
puts "Loading File"
CSV.foreach("/usr/local/hydra/epigaea/eads.txt", headers: false, header_converters: :symbol, encoding: "ISO8859-1:utf-8") do |row|
pid = row[0]
title = row[1]
obj = ActiveFedora::Base.find(pid)
cols = Collection.where(title_tesim: title)
col_desc = Collection.find('vd66vz89n')

if cols.empty?
puts "EAD #{pid} has no matching collection"
a = Collection.new(title: [title])
a.apply_depositor_metadata 'apruit01'
a.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
a.save!
a = a.reload
obj.member_of_collections = [a, col_desc]
else
puts "EAD #{pid} has a matching collection and can be added."
col = cols.first
obj.member_of_collections = [col, col_desc]
end

obj.save!
rescue ActiveFedora::ObjectNotFoundError
puts "ERROR not found #{pid}"
end
end

desc "sipity updates"
task sipity_updates: :environment do
puts "Loading File"
Expand Down Expand Up @@ -463,27 +408,6 @@ task f3_updates: :environment do
end
end

desc "iterate collections"
task iterate_and_fix_collections1: :environment do
colls = Collection.all
colls.each do |col|
ead_id = col.ead
ead_id = ead_id.to_a.first
substring = "DO"
ead_id = "" if ead_id.nil?
count = ead_id.scan(/(?=#{substring})/).count

if count > 1
ead_id = ead_id.sub(substring + ".", "")
puts "FIX #{ead_id}"
col.ead = [ead_id]
col.save
else
puts "OK"
end
end
end

desc "apply genres"
task apply_genre: :environment do
file = File.read('genre.json')
Expand All @@ -500,25 +424,6 @@ task apply_genre: :environment do
end
end

desc "iterate collections"
task iterate_and_fix_collections: :environment do
colls = Collection.all
colls.each do |col|
ead_id = col.ead
ead_id = ead_id.to_a.first
puts "class #{ead_id.class}"
eads = Ead.where(legacy_pid_tesim: ead_id)
eads = eads.to_a.first unless eads.to_a.empty?
if eads.instance_of? Ead
eads.member_of_collections = [col]
eads.save
puts "Add #{eads} with legacy_pid (#{ead_id}) to #{col.id}"
else
puts "SKIPPING"
end
end
end

desc "update_fileset_index"
task update_fileset_index: :environment do
puts "Loading File"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def self.modified_field
primary_date_tesim date_accepted_tesim date_available_tesim
date_copyrighted_tesim date_created_tesim date_issued_tesim
date_modified_tesim date_uploaded_tesim description_tesim
displays_in_tesim ead_tesim embargo_note_tesim end_date_tesim extent_tesim
displays_in_tesim embargo_note_tesim end_date_tesim extent_tesim
format_label_tesim funder_tesim genre_tesim geographic_name_tesim
has_part_tesim internal_note_tesim
is_part_of_tesim is_replaced_by_tesim language_tesim
Expand Down

0 comments on commit 6af75f4

Please sign in to comment.