diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index 17ec0c480..ff590fffc 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -497,7 +497,8 @@ def set_include if params[:include].present? @include = params[:include].split(",").map { |i| i.downcase.underscore.to_sym } - @include = @include & [:client, :media, :references, :citations, :parts, :part_of, :versions, :version_of] + # @include = @include & [:client, :media, :references, :citations, :parts, :part_of, :versions, :version_of] + @include = @include & [:client, :media] else @include = [] end diff --git a/app/serializers/doi_serializer.rb b/app/serializers/doi_serializer.rb index 5c626dd4f..c416a4541 100644 --- a/app/serializers/doi_serializer.rb +++ b/app/serializers/doi_serializer.rb @@ -6,17 +6,18 @@ class DoiSerializer set_id :uid # don't cache dois, as works are cached using the doi model - attributes :doi, :prefix, :suffix, :identifiers, :creators, :titles, :publisher, :container, :publication_year, :subjects, :contributors, :dates, :language, :types, :related_identifiers, :sizes, :formats, :version, :rights_list, :descriptions, :geo_locations, :funding_references, :xml, :url, :content_url, :metadata_version, :schema_version, :source, :is_active, :state, :reason, :landing_page, :view_count, :views_over_time, :download_count, :downloads_over_time, :reference_count, :citation_count, :citations_over_time, :part_count, :part_of_count, :version_count, :version_of_count, :created, :registered, :published, :updated + attributes :doi, :prefix, :suffix, :identifiers, :creators, :titles, :publisher, :container, :publication_year, :subjects, :contributors, :dates, :language, :types, :related_identifiers, :sizes, :formats, :version, :rights_list, :descriptions, :geo_locations, :funding_references, :xml, :url, :content_url, :metadata_version, :schema_version, :source, :is_active, :state, :reason, :landing_page, :view_count, :views_over_time, :download_count, :downloads_over_time, :reference_count, :citation_count, :citations_over_time, :created, :registered, :published, :updated attributes :prefix, :suffix, :views_over_time, :downloads_over_time, :citations_over_time, if: Proc.new { |object, params| params && params[:detail] } - + # :part_count, :part_of_count, :version_count, :version_of_count, + belongs_to :client, record_type: :clients - has_many :media, record_type: :media, id_method_name: :uid, if: Proc.new { |object, params| params && params[:detail] && !params[:is_collection]} - has_many :references, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_references, if: Proc.new { |object, params| params && params[:detail] } - has_many :citations, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_citations, if: Proc.new { |object, params| params && params[:detail] } - has_many :parts, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_parts, if: Proc.new { |object, params| params && params[:detail] } - has_many :part_of, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_part_of, if: Proc.new { |object, params| params && params[:detail] } - has_many :versions, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_versions, if: Proc.new { |object, params| params && params[:detail] } - has_many :version_of, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_version_of, if: Proc.new { |object, params| params && params[:detail] } + # has_many :media, record_type: :media, id_method_name: :uid, if: Proc.new { |object, params| params && params[:detail] && !params[:is_collection]} + # has_many :references, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_references, if: Proc.new { |object, params| params && params[:detail] } + # has_many :citations, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_citations, if: Proc.new { |object, params| params && params[:detail] } + # has_many :parts, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_parts, if: Proc.new { |object, params| params && params[:detail] } + # has_many :part_of, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_part_of, if: Proc.new { |object, params| params && params[:detail] } + # has_many :versions, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_versions, if: Proc.new { |object, params| params && params[:detail] } + # has_many :version_of, record_type: :dois, serializer: DoiSerializer, object_method_name: :indexed_version_of, if: Proc.new { |object, params| params && params[:detail] } attribute :xml, if: Proc.new { |object, params| params && params[:detail] } do |object| begin diff --git a/spec/requests/dois_spec.rb b/spec/requests/dois_spec.rb index 9241f396c..bb96115ff 100644 --- a/spec/requests/dois_spec.rb +++ b/spec/requests/dois_spec.rb @@ -178,7 +178,7 @@ expect(result.dig('attributes', 'doi')).to eq(doi.doi.downcase) expect(result.dig('attributes', 'titles')).to eq(doi.titles) - expect(result.dig('relationships','citations', 'data')).to be_empty + # expect(result.dig('relationships','citations', 'data')).to be_empty end end @@ -336,9 +336,9 @@ expect(json.dig('data', 'attributes', 'doi')).to eq(doi.doi.downcase) expect(json.dig('data', 'attributes', 'titles')).to eq(doi.titles) expect(json.dig('data', 'attributes', 'referenceCount')).to eq(1) - expect(json.dig('data', 'relationships', 'references', 'data')).to eq([{"id"=>target_doi.doi.downcase, "type"=>"dois"}]) - expect(json.dig('included').length).to eq(1) - expect(json.dig('included', 0, 'attributes', 'doi')).to eq(target_doi.doi.downcase) + # expect(json.dig('data', 'relationships', 'references', 'data')).to eq([{"id"=>target_doi.doi.downcase, "type"=>"dois"}]) + # expect(json.dig('included').length).to eq(1) + # expect(json.dig('included', 0, 'attributes', 'doi')).to eq(target_doi.doi.downcase) end end @@ -362,9 +362,9 @@ expect(json.dig('data', 'attributes', 'titles')).to eq(doi.titles) expect(json.dig('data', 'attributes', 'citationCount')).to eq(1) expect(json.dig('data', 'attributes', 'citationsOverTime')).to eq([{"total"=>1, "year"=>"2020"}]) - expect(json.dig('data', 'relationships', 'citations', 'data')).to eq([{"id"=>source_doi.doi.downcase, "type"=>"dois"}]) - expect(json.dig('included').length).to eq(1) - expect(json.dig('included', 0, 'attributes', 'doi')).to eq(source_doi.doi.downcase) + # expect(json.dig('data', 'relationships', 'citations', 'data')).to eq([{"id"=>source_doi.doi.downcase, "type"=>"dois"}]) + # expect(json.dig('included').length).to eq(1) + # expect(json.dig('included', 0, 'attributes', 'doi')).to eq(source_doi.doi.downcase) end it "has citations meta" do @@ -393,10 +393,10 @@ expect(json.dig('data', 'attributes', 'url')).to eq(doi.url) expect(json.dig('data', 'attributes', 'doi')).to eq(doi.doi.downcase) expect(json.dig('data', 'attributes', 'titles')).to eq(doi.titles) - expect(json.dig('data', 'attributes', 'partCount')).to eq(1) - expect(json.dig('data', 'relationships', 'parts', 'data')).to eq([{"id"=>target_doi.doi.downcase, "type"=>"dois"}]) - expect(json.dig('included').length).to eq(1) - expect(json.dig('included', 0, 'attributes', 'doi')).to eq(target_doi.doi.downcase) + # expect(json.dig('data', 'attributes', 'partCount')).to eq(1) + # expect(json.dig('data', 'relationships', 'parts', 'data')).to eq([{"id"=>target_doi.doi.downcase, "type"=>"dois"}]) + # expect(json.dig('included').length).to eq(1) + # expect(json.dig('included', 0, 'attributes', 'doi')).to eq(target_doi.doi.downcase) end end @@ -418,10 +418,10 @@ expect(json.dig('data', 'attributes', 'url')).to eq(doi.url) expect(json.dig('data', 'attributes', 'doi')).to eq(doi.doi.downcase) expect(json.dig('data', 'attributes', 'titles')).to eq(doi.titles) - expect(json.dig('data', 'attributes', 'versionCount')).to eq(1) - expect(json.dig('data', 'relationships', 'versions', 'data')).to eq([{"id"=>target_doi.doi.downcase, "type"=>"dois"}]) - expect(json.dig('included').length).to eq(1) - expect(json.dig('included', 0, 'attributes', 'doi')).to eq(target_doi.doi.downcase) + # expect(json.dig('data', 'attributes', 'versionCount')).to eq(1) + # expect(json.dig('data', 'relationships', 'versions', 'data')).to eq([{"id"=>target_doi.doi.downcase, "type"=>"dois"}]) + # expect(json.dig('included').length).to eq(1) + # expect(json.dig('included', 0, 'attributes', 'doi')).to eq(target_doi.doi.downcase) end end