Skip to content

Commit

Permalink
show views and downloads over time in works endpoint. #390
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Feb 16, 2020
1 parent c939711 commit 14a4f97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/serializers/work_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class WorkSerializer
set_id :identifier
cache_options enabled: true, cache_length: 24.hours

attributes :doi, :identifier, :url, :author, :title, :container_title, :description, :resource_type_subtype, :data_center_id, :member_id, :resource_type_id, :version, :license, :schema_version, :results, :related_identifiers, :citation_count, :view_count, :download_count, :published, :registered, :checked, :updated, :media, :xml
attributes :doi, :identifier, :url, :author, :title, :container_title, :description, :resource_type_subtype, :data_center_id, :member_id, :resource_type_id, :version, :license, :schema_version, :results, :related_identifiers, :citation_count, :view_count, :views_over_time, :download_count, :downloads_over_time, :published, :registered, :checked, :updated, :media, :xml

belongs_to :client, key: "data-center", record_type: "data-centers", serializer: :DataCenter
belongs_to :provider, key: :member, record_type: :members, serializer: :Member
Expand Down
4 changes: 4 additions & 0 deletions spec/requests/works_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
expect(json.dig('data', 'attributes', 'title')).to eq("Data from: A new malaria agent in African hominids.")
expect(json.dig('data', 'attributes', 'citation-count')).to eq(1)
expect(json.dig('data', 'attributes', 'view-count')).to eq(0)
expect(json.dig('data', 'attributes', 'views-over-time')).to eq([])
expect(json.dig('data', 'attributes', 'download-count')).to eq(0)
expect(json.dig('data', 'attributes', 'downloads-over-time')).to eq([])
end

it "has citations list" do
Expand All @@ -63,7 +65,9 @@
expect(work.dig('attributes', 'title')).to eq("Data from: A new malaria agent in African hominids.")
expect(work.dig('attributes', 'citation-count')).to eq(1)
expect(work.dig('attributes', 'view-count')).to eq(0)
expect(work.dig('attributes', 'views-over-time')).to eq([])
expect(work.dig('attributes', 'download-count')).to eq(0)
expect(work.dig('attributes', 'downloads-over-time')).to eq([])
end
end

Expand Down

0 comments on commit 14a4f97

Please sign in to comment.