From 524a80877e2ab33cddfe77b09850b5caab5c3998 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Mon, 17 Feb 2020 23:53:57 +0100 Subject: [PATCH] citations over time. #418 --- app/controllers/dois_controller.rb | 4 +++- app/serializers/doi_serializer.rb | 2 +- spec/requests/dois_spec.rb | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index 78af07b06..f15154f29 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -617,6 +617,8 @@ def safe_params { downloadsOverTime: [:yearMonth, :total] }, :viewsOverTime, { viewsOverTime: [:yearMonth, :total] }, + :citationsOverTime, + { citationsOverTime: [:year, :total] }, :citationCount, :downloadCount, :partCount, @@ -699,7 +701,7 @@ def safe_params :created, :registered, :updated, :published, :lastLandingPage, :version, :lastLandingPageStatus, :lastLandingPageStatusCheck, :lastLandingPageStatusResult, :lastLandingPageContentType, :contentUrl, - :viewsOverTime, :downloadsOverTime, :citationCount, :downloadCount, + :viewsOverTime, :downloadsOverTime, :citationsOverTime, :citationCount, :downloadCount, :partCount, :partOfCount, :referenceCount, :versionCount, :versionOfCount, :viewCount) end diff --git a/app/serializers/doi_serializer.rb b/app/serializers/doi_serializer.rb index f5e4684b2..2faa00467 100644 --- a/app/serializers/doi_serializer.rb +++ b/app/serializers/doi_serializer.rb @@ -6,7 +6,7 @@ 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, :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, if: Proc.new { |object, params| params && params[:detail] } belongs_to :client, record_type: :clients diff --git a/spec/requests/dois_spec.rb b/spec/requests/dois_spec.rb index 83bc9a2c4..c8620cbcb 100644 --- a/spec/requests/dois_spec.rb +++ b/spec/requests/dois_spec.rb @@ -269,6 +269,7 @@ 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', 'citationCount')).to eq(1) + expect(json.dig('data', 'attributes', 'citationsOverTime')).to eq([{"total"=>1, "year"=>"2020"}]) expect(json.dig('data', 'relationships', 'citationEvents', 'data')).to eq([{"id" => citation_event.uuid, "type"=>"events"}]) expect(json.dig('included').length).to eq(2) expect(json.dig('included', 0, 'attributes', 'relationTypeId')).to eq("is-referenced-by") @@ -284,7 +285,6 @@ it "repository shows summary count" do get "/repositories/#{client.uid}", nil, headers - puts last_response.body expect(last_response.status).to eq(200) expect(json.dig('data', 'attributes', 'name')).to eq(client.name) expect(json.dig('meta', 'citations')).to eq([{"count"=>1, "id"=>"2011", "title"=>"2011"}]) @@ -553,6 +553,7 @@ "published" => nil, "viewsOverTime" => {}, "downloadsOverTime" => {}, + "citationsOverTime" => {}, "viewCount" => 0, "downloadCount" => 0, "citationCount" => 0,