Skip to content

Commit

Permalink
show doi_count for researchers
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Aug 21, 2019
1 parent 7e08011 commit f6804f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/concerns/countable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ module Countable
extend ActiveSupport::Concern

included do
def doi_count(client_id: nil, provider_id: nil, consortium_id: nil)
def doi_count(client_id: nil, provider_id: nil, consortium_id: nil, researcher_id: nil)
if client_id
response = Doi.query(nil, client_id: client_id, page: { number: 1, size: 0 })
elsif provider_id
response = Doi.query(nil, provider_id: provider_id, page: { number: 1, size: 0 })
elsif consortium_id
response = Doi.query(nil, consortium_id: consortium_id, page: { number: 1, size: 0 })
elsif researcher_id
response = Doi.query(nil, researcher_id: researcher_id, page: { number: 1, size: 0 })
else
response = Doi.query(nil, page: { number: 1, size: 0 })
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/researchers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def index

def show
options = {}
options[:meta] = { dois: doi_count(researcher_id: params[:id]) }
options[:is_collection] = false
render json: ResearcherSerializer.new(@researcher, options).serialized_json, status: :ok
end
Expand Down

0 comments on commit f6804f6

Please sign in to comment.