Skip to content

Commit

Permalink
add new report for scanned map remediation
Browse files Browse the repository at this point in the history
  • Loading branch information
peetucket committed Mar 5, 2024
1 parent c541874 commit b57ba7e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app/reports/geo_map_coordinates.rb
@@ -0,0 +1,35 @@
# frozen_string_literal: true

# see https://github.com/sul-dlss/dor-services-app/issues/4702

# Invoke via:
# bin/rails r -e production "GeoMapCoordinates.report"
class GeoMapCoordinates
JSON_PATH_TYPE = 'strict $.**.subject.subject.type'
JSON_PATH_VALUE = 'strict $.**.subject.subject.value'

# 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"
# }
# ],

SQL = <<~SQL.squish.freeze
SELECT external_identifier,
jsonb_path_query(structural, '$.isMemberOf') ->> 0 as collection_id
FROM "dros" WHERE
(jsonb_path_exists(description, '#{JSON_PATH_TYPE} ? (@ like_regex "(map coordinates)")') AND
jsonb_path_exists(description, '#{JSON_PATH_VALUE} ? (@ like_regex "^.+")'))
SQL

def self.report
puts "item_druid,collection_druid\n"

ActiveRecord::Base.connection.execute(SQL).each do |row|
[row['external_identifier'], row['collection_id']].join(',')
end
end
end

0 comments on commit b57ba7e

Please sign in to comment.