From f6804f613550a72ff3633b291ec9373dc0e575d1 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Wed, 21 Aug 2019 08:59:01 +0200 Subject: [PATCH] show doi_count for researchers --- app/controllers/concerns/countable.rb | 4 +++- app/controllers/researchers_controller.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/concerns/countable.rb b/app/controllers/concerns/countable.rb index a92af0df0..bbef66d76 100644 --- a/app/controllers/concerns/countable.rb +++ b/app/controllers/concerns/countable.rb @@ -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 diff --git a/app/controllers/researchers_controller.rb b/app/controllers/researchers_controller.rb index f462b3785..05130af6d 100644 --- a/app/controllers/researchers_controller.rb +++ b/app/controllers/researchers_controller.rb @@ -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