Skip to content

Commit

Permalink
citations over time. #418
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Feb 17, 2020
1 parent 49b14f9 commit 524a808
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ def safe_params
{ downloadsOverTime: [:yearMonth, :total] },
:viewsOverTime,
{ viewsOverTime: [:yearMonth, :total] },
:citationsOverTime,
{ citationsOverTime: [:year, :total] },
:citationCount,
:downloadCount,
:partCount,
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/serializers/doi_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion spec/requests/dois_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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"}])
Expand Down Expand Up @@ -553,6 +553,7 @@
"published" => nil,
"viewsOverTime" => {},
"downloadsOverTime" => {},
"citationsOverTime" => {},
"viewCount" => 0,
"downloadCount" => 0,
"citationCount" => 0,
Expand Down

0 comments on commit 524a808

Please sign in to comment.