Skip to content

Commit

Permalink
report on map coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
lwrubel committed Mar 6, 2024
1 parent c541874 commit 78e4e4a
Showing 1 changed file with 29 additions and 0 deletions.
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
# "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

0 comments on commit 78e4e4a

Please sign in to comment.