Skip to content

Commit

Permalink
Fix SQL syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-collier committed Apr 24, 2024
1 parent 153de65 commit 3bde485
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/reports/invalid_edtf_structured_dates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/reports/invalid_form_uris.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/reports/invalid_location_uris.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/reports/property_existence_dros.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion app/reports/property_multiple_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down

0 comments on commit 3bde485

Please sign in to comment.