Skip to content

Commit

Permalink
Merge pull request #810 from MITLibraries/gdt-218-publishers-field
Browse files Browse the repository at this point in the history
Add publishers field to record type
  • Loading branch information
jazairi committed Apr 4, 2024
2 parents 1ea2408 + 5010917 commit 76b2b9b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/graphql/types/record_type.rb
Expand Up @@ -131,6 +131,12 @@ def matched_phrases
end
end

class PublishersType < Types::BaseObject
field :name, String, description: 'The name of the publisher'
field :date, String, description: 'The date of the publication'
field :location, String, description: 'Where the publisher is located'
end

class RecordType < Types::BaseObject
field :identifier, ID, null: false, deprecation_reason: 'Use `timdex_record_id`'
field :timdex_record_id, ID, null: false, description: 'TIMDEX unique identifier for the item'
Expand Down Expand Up @@ -158,8 +164,8 @@ class RecordType < Types::BaseObject
field :call_numbers, [String], null: true, description: 'Identification number used to classify and locate item'
field :citation, String, null: true, description: 'Citation for item'
field :edition, String, null: true, description: 'Edition information for item'
field :imprint, [String], null: true, deprecation_reason: 'Use `publicationInformation`'
field :publication_information, [String], description: 'Imprint information for item'
field :imprint, [String], null: true, deprecation_reason: 'Use `publishers`'
field :publication_information, [String], deprecation_reason: 'Use `publishers`'
field :physical_description, String, null: true, description: 'Physical description of item'
field :publication_frequency, [String], null: true,
description: 'Publication frequency of item (used for serials)'
Expand Down Expand Up @@ -188,6 +194,7 @@ class RecordType < Types::BaseObject
field :provider, String,
null: true,
description: 'The host institution for a resource. Currently only used for geospatial records'
field :publishers, [Types::PublishersType], null: true, description: 'Publishers that are associated with the item'

def in_bibliography
@object['related_items']&.map { |i| i['uri'] if i['relationship'] == 'IsCitedBy' }&.compact
Expand All @@ -205,6 +212,10 @@ def publication_date
@object['dates']&.map { |date| date['value'] if date['kind'] == 'Publication date' }&.compact&.first
end

def publication_information
@object['publishers']&.map { |publisher| publisher.values.join('; ') }
end

def file_formats
@object['file_formats'].uniq
end
Expand Down

0 comments on commit 76b2b9b

Please sign in to comment.