diff --git a/app/controllers/clients_controller.rb b/app/controllers/clients_controller.rb index f13e2293d..04ec67567 100644 --- a/app/controllers/clients_controller.rb +++ b/app/controllers/clients_controller.rb @@ -158,9 +158,8 @@ def totals page = { size: 0, number: 1 } state = current_user.present? && current_user.is_admin_or_staff? && params[:state].present? ? params[:state] : "registered,findable" response = Doi.query(nil, provider_id: params[:provider_id], state: state, page: page, totals_agg: true) - total = response.results.total - - registrant = total > 0 ? clients_totals(response.response.aggregations.clients_totals.buckets) : nil + registrant = clients_totals(response.response.aggregations.clients_totals.buckets) + render json: registrant, status: :ok end diff --git a/app/controllers/prefixes_controller.rb b/app/controllers/prefixes_controller.rb index 9b1e2eaaf..ec5316901 100644 --- a/app/controllers/prefixes_controller.rb +++ b/app/controllers/prefixes_controller.rb @@ -138,9 +138,8 @@ def update def totals page = { size: 0, number: 1} response = Doi.query(nil, client_id: params[:client_id], state: "findable,registered", page: page, totals_agg: true) - total = response.results.total - - registrant = total > 0 ? prefixes_totals(response.response.aggregations.prefixes_totals.buckets) : nil + registrant = prefixes_totals(response.response.aggregations.prefixes_totals.buckets) + render json: registrant, status: :ok end diff --git a/app/controllers/providers_controller.rb b/app/controllers/providers_controller.rb index 175e0a33f..5fe9b3926 100644 --- a/app/controllers/providers_controller.rb +++ b/app/controllers/providers_controller.rb @@ -280,8 +280,7 @@ def totals state = current_user.present? && current_user.is_admin_or_staff? && params[:state].present? ? params[:state] : "registered,findable" response = Doi.query(nil, state: state, page: page, totals_agg: true) - total = response.results.total - registrant = total > 0 ? providers_totals(response.response.aggregations.providers_totals.buckets) : nil + registrant = providers_totals(response.response.aggregations.providers_totals.buckets) render json: registrant, status: :ok end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 96ea30b30..619ef28b4 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -186,9 +186,8 @@ def totals state = current_user.present? && current_user.is_admin_or_staff? && params[:state].present? ? params[:state] : "registered,findable" response = Doi.query(nil, provider_id: params[:provider_id], state: state, page: page, totals_agg: true) - total = response.results.total - - registrant = total > 0 ? clients_totals(response.response.aggregations.clients_totals.buckets) : nil + registrant = clients_totals(response.response.aggregations.clients_totals.buckets) + render json: registrant, status: :ok end