Skip to content

Commit 6c74c5c

Browse files
committed
not displaying usage in doi view
1 parent c2c1300 commit 6c74c5c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

app.rb

+2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@
180180
unless request.is_crawler?
181181
events = get_events('page[size]' => 1, 'page[number]' => @page, 'doi' => doi, 'sort' => 'relation_type_id')
182182
@work[:metrics] = reduce_aggs(events[:meta], { yop: @work.dig(:data, "attributes","published").to_i })
183+
@work[:metrics].merge!("unique-dataset-investigations-regular" => (events[:meta].fetch('doisUsageTypes', []).first.fetch("relationTypes",[]).find { |x| x['id'] == "unique-dataset-investigations-regular" }.fetch("sum",0)))
184+
@work[:metrics].merge!("unique-dataset-requests-regular" => (events[:meta].fetch('doisUsageTypes', []).first.fetch("relationTypes",[]).find { |x| x['id'] == "unique-dataset-requests-regular" }.fetch("sum",0)))
183185
@work[:metrics].merge!(citations: (events[:meta].fetch('uniqueCitations', []).find { |x| x['id'] == doi } || {}))
184186
@work[:metrics].merge!(citations_histogram: events[:meta].fetch('citationsHistogram', {}))
185187
@work[:metrics].merge!(views_histogram: events[:meta].fetch('viewsHistogram', {}))

views/works/item.haml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
- sources = Array.wrap(@works[:meta].to_h.fetch("sources", nil))
66
- new_params = params[:model] == "works" && params["id"] == attributes.fetch("doi", nil) ? params.merge(external_link: true) : params
77
- title = attributes["title"].to_s.gsub(/"/, '\"')
8-
- views = metrics.to_h.fetch("unique-dataset-investigations-regular", 0)
9-
- downloads = metrics.to_h.fetch("unique-dataset-requests-regular", 0)
8+
- views = metrics.to_h.fetch("unique-dataset-investigations-regular", 0).to_i
9+
- downloads = metrics.to_h.fetch("unique-dataset-requests-regular", 0).to_i
1010
- citations = metrics.to_h.dig(:citations, "count").to_i
1111
- references = metrics.to_h.dig(:references, "count").to_i
1212
- relations = metrics.to_h.dig(:relations, "count").to_i

0 commit comments

Comments
 (0)