From 538eda4cfcf829caab2af4f55a938f5ea3963597 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sat, 25 Jan 2020 10:14:32 +0100 Subject: [PATCH] disable breaking changes for #395 --- app/models/doi.rb | 32 +++++++++++++++---------------- app/serializers/doi_serializer.rb | 20 +++++++++---------- spec/requests/dois_spec.rb | 4 ++-- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/models/doi.rb b/app/models/doi.rb index 7869d556e..74d8a4c56 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -72,8 +72,8 @@ class Doi < ActiveRecord::Base belongs_to :client, foreign_key: :datacentre has_many :media, -> { order "created DESC" }, foreign_key: :dataset, dependent: :destroy has_many :metadata, -> { order "created DESC" }, foreign_key: :dataset, dependent: :destroy - has_many :views, -> { where relation_type_id: "unique-dataset-investigations-regular" }, class_name: "Event", primary_key: :doi, foreign_key: :doi_id, dependent: :destroy - has_many :downloads, -> { where relation_type_id: "unique-dataset-requests-regular" }, class_name: "Event", primary_key: :doi, foreign_key: :doi_id, dependent: :destroy + # has_many :views, -> { where relation_type_id: "unique-dataset-investigations-regular" }, class_name: "Event", primary_key: :doi, foreign_key: :doi_id, dependent: :destroy + # has_many :downloads, -> { where relation_type_id: "unique-dataset-requests-regular" }, class_name: "Event", primary_key: :doi, foreign_key: :doi_id, dependent: :destroy delegate :provider, to: :client, allow_nil: true delegate :consortium_id, to: :provider, allow_nil: true @@ -403,10 +403,10 @@ class Doi < ActiveRecord::Base consortium_organizations: { type: :object } } indexes :resource_type, type: :object - indexes :view_ids, type: :keyword - indexes :views, type: :object - indexes :download_ids, type: :keyword - indexes :downloads, type: :object + # indexes :view_ids, type: :keyword + # indexes :views, type: :object + # indexes :download_ids, type: :keyword + # indexes :downloads, type: :object end end @@ -428,8 +428,8 @@ def as_indexed_json(options={}) "consortium_id" => consortium_id, "resource_type_id" => resource_type_id, "media_ids" => media_ids, - "view_ids" => view_ids, - "download_ids" => download_ids, + # "view_ids" => view_ids, + # "download_ids" => download_ids, "prefix" => prefix, "suffix" => suffix, "types" => types, @@ -465,8 +465,8 @@ def as_indexed_json(options={}) "provider" => provider.try(:as_indexed_json), "resource_type" => resource_type.try(:as_indexed_json), "media" => media.map { |m| m.try(:as_indexed_json) }, - "views" => views.map { |m| m.try(:as_indexed_json) }, - "downloads" => downloads.map { |m| m.try(:as_indexed_json) } + # "views" => views.map { |m| m.try(:as_indexed_json) }, + # "downloads" => downloads.map { |m| m.try(:as_indexed_json) } } end @@ -858,13 +858,13 @@ def media_ids media.pluck(:id).map { |m| Base32::URL.encode(m, split: 4, length: 16) }.compact end - def view_ids - views.pluck(:doi_id) - end + # def view_ids + # views.pluck(:doi_id) + # end - def download_ids - downloads.pluck(:doi_id) - end + # def download_ids + # downloads.pluck(:doi_id) + # end def xml_encoded diff --git a/app/serializers/doi_serializer.rb b/app/serializers/doi_serializer.rb index 330cf01af..55b8572c4 100644 --- a/app/serializers/doi_serializer.rb +++ b/app/serializers/doi_serializer.rb @@ -7,13 +7,13 @@ 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, :created, :registered, :published, :updated, :citations, :views, :downloads + 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, :created, :registered, :published, :updated, :citations attributes :prefix, :suffix, if: Proc.new { |object, params| params && params[:detail] } 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 :views, record_type: :events, if: Proc.new { |object, params| params && params[:events]} - has_many :downloads, record_type: :events, if: Proc.new { |object, params| params && params[:events]} + # has_many :views, record_type: :events, if: Proc.new { |object, params| params && params[:events]} + # has_many :downloads, record_type: :events, if: Proc.new { |object, params| params && params[:events]} attribute :xml, if: Proc.new { |object, params| params && params[:detail] } do |object| begin @@ -89,15 +89,15 @@ class DoiSerializer object.landing_page end - attribute :citations, if: Proc.new { |object, params| params && params[:mix_in] == "metrics" } do |object| + attribute :citations, if: Proc.new { |object, params| params && params[:mix_in] == "metrics" } do |object| doi_citations(object.uid) end - attribute :views, if: Proc.new { |object, params| params && params[:mix_in] == "metrics" } do |object| - doi_views(object.uid) - end + # attribute :views, if: Proc.new { |object, params| params && params[:mix_in] == "metrics" } do |object| + # doi_views(object.uid) + # end - attribute :downloads, if: Proc.new { |object, params| params && params[:mix_in] == "metrics" } do |object| - doi_downloads(object.uid) - end + # attribute :downloads, if: Proc.new { |object, params| params && params[:mix_in] == "metrics" } do |object| + # doi_downloads(object.uid) + # end end diff --git a/spec/requests/dois_spec.rb b/spec/requests/dois_spec.rb index 1428ac40b..859aaaaed 100644 --- a/spec/requests/dois_spec.rb +++ b/spec/requests/dois_spec.rb @@ -141,8 +141,8 @@ expect(json.dig('data', 0, 'attributes', 'doi')).to eq(doi.doi.downcase) expect(json.dig('data', 0, 'attributes', 'titles')).to eq(doi.titles) expect(json.dig('data',0,'attributes','citations')).to eq(3) - expect(json.dig('data',0,'attributes','views')).to be > 0 - expect(json.dig('data',0,'attributes','downloads')).to eq(0) + # expect(json.dig('data',0,'attributes','views')).to be > 0 + # expect(json.dig('data',0,'attributes','downloads')).to eq(0) end end end