diff --git a/app/reports/invalid_edtf_structured_dates.rb b/app/reports/invalid_edtf_structured_dates.rb index fe78e135d..9c998139b 100644 --- a/app/reports/invalid_edtf_structured_dates.rb +++ b/app/reports/invalid_edtf_structured_dates.rb @@ -46,7 +46,7 @@ class InvalidEdtfStructuredDates def self.report puts "item_druid,catalogRecordId,collection_druid,invalid_values,reason\n" - RepositoryObject.dros.where("jsonb_path_exists(head_version.description, '$.**.date.**.encoding.code ? (@ == \"edtf\")')").find_each do |dro| + RepositoryObject.dros.where(head_version: "jsonb_path_exists(description, '$.**.date.**.encoding.code ? (@ == \"edtf\")')").find_each do |dro| new(dro:).report end end @@ -110,6 +110,6 @@ def collection_id end def catalog_record_id - dro.identification['catalogLinks'].find { |link| link['catalog'] == 'folio' }&.fetch('catalogRecordId') + dro.head_version.identification['catalogLinks'].find { |link| link['catalog'] == 'folio' }&.fetch('catalogRecordId') end end diff --git a/app/reports/invalid_form_uris.rb b/app/reports/invalid_form_uris.rb index 50d6c7d1e..d7c4e1726 100644 --- a/app/reports/invalid_form_uris.rb +++ b/app/reports/invalid_form_uris.rb @@ -14,7 +14,7 @@ class InvalidFormUris ro.head_version_id = rov.id AND ro.object_type = 'dro' AND (jsonb_path_exists(rov.description, '#{JSON_PATH} ? (@ like_regex "^(?!https?://).*$")') OR - AND jsonb_path_exists(rov.description, '#{JSON_PATH} ? (@ like_regex "^.*\.html$")')) + jsonb_path_exists(rov.description, '#{JSON_PATH} ? (@ like_regex "^.*\.html$")')) SQL def self.report diff --git a/app/reports/invalid_location_uris.rb b/app/reports/invalid_location_uris.rb index ddd0d1d26..cb2e88fa0 100644 --- a/app/reports/invalid_location_uris.rb +++ b/app/reports/invalid_location_uris.rb @@ -21,7 +21,7 @@ class InvalidLocationUris jsonb_path_query(rov.identification, '$.catalogLinks[*] ? (@.catalog == "folio").catalogRecordId') ->> 0 as catalogRecordId, jsonb_path_query(rov.structural, '$.isMemberOf') ->> 0 as collection_id FROM repository_objects AS ro, - repository_object_versions AS rov + repository_object_versions AS rov, jsonb_path_query_array(rov.description, '#{JSON_PATH} ? (@.uri like_regex #{REGEX})') AS event_location WHERE ro.head_version_id = rov.id diff --git a/app/reports/property_existence_dros.rb b/app/reports/property_existence_dros.rb index 08160b7b6..191e4b3e8 100644 --- a/app/reports/property_existence_dros.rb +++ b/app/reports/property_existence_dros.rb @@ -37,7 +37,7 @@ def self.rows(sql_query) sql_result_rows.map do |row| collection_druid = row['collection_id'] - collection_name = RepositoryObject.collections.find_by(external_identifier: collection_druid)&.label + collection_name = RepositoryObject.collections.find_by(external_identifier: collection_druid)&.head_version&.label [ row['item_druid'], diff --git a/app/reports/property_multiple_events.rb b/app/reports/property_multiple_events.rb index d367e0f49..73d33a9b3 100644 --- a/app/reports/property_multiple_events.rb +++ b/app/reports/property_multiple_events.rb @@ -36,7 +36,7 @@ def self.result_rows(sql) .group_by { |row| row['external_identifier'] } .map do |_id, rows| collection_druid = rows.first['collection_id'] - collection_name = RepositoryObject.collections.find_by(external_identifier: collection_druid)&.label + collection_name = RepositoryObject.collections.find_by(external_identifier: collection_druid)&.head_version&.label [ rows.first['purl'],