Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report map coordinates #4705

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions app/reports/subject_map_coordinates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

# Report all map coordinates values in subjects
# Invoke via:
# bin/rails r -e production "SubjectMapCoordinates.report"
class SubjectMapCoordinates
# Finds an object like this: https://argo.stanford.edu/view/druid:bb051ch9980
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying @peetucket's good documentation in his PR. :)

# "description": {
# "subject": [
# {
# "value": "E 13掳59'00\"--E 34掳28'00\"/S 22掳07'00\"--S 35掳39'00\"",
# "type": "map coordinates"
# }
# ],

SUBJECT_PATH = JsonPath.new('$..subject[?(@.type == "map coordinates")].value')

def self.report
puts "item_druid|collection_druid|coordinates\n"

Dro.where("jsonb_path_exists(description, '$.**.subject.type ? (@ == \"map coordinates\")')").find_each do |dro|
druid = dro.external_identifier
collection = dro.structural['isMemberOf'].join(' ')
coordinates = SUBJECT_PATH.on(dro.description.to_json).join('|')

puts "#{druid}|#{collection}|#{coordinates}\n"
end
end
end