diff --git a/app/controllers/clients_controller.rb b/app/controllers/clients_controller.rb index 5be3063c8..be38da997 100644 --- a/app/controllers/clients_controller.rb +++ b/app/controllers/clients_controller.rb @@ -1,3 +1,5 @@ +require 'benchmark' + class ClientsController < ApplicationController include Countable diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index 33f517b5a..51106247d 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -37,6 +37,8 @@ def index else nil end + response = nil + if params[:id].present? logger.info "[Benchmark] find_by_id " + Benchmark.ms { response = Doi.find_by_id(params[:id]) @@ -90,6 +92,7 @@ def index total = sample_dois.length total_pages = 1 else + results = nil logger.info "[Benchmark] results " + Benchmark.ms { results = response.results.results }.to_s + " ms" diff --git a/app/controllers/prefixes_controller.rb b/app/controllers/prefixes_controller.rb index cc1a241c4..fb56fcffe 100644 --- a/app/controllers/prefixes_controller.rb +++ b/app/controllers/prefixes_controller.rb @@ -1,5 +1,6 @@ +require 'benchmark' + class PrefixesController < ApplicationController - before_action :set_prefix, only: [:show, :update, :destroy] before_action :authenticate_user! before_action :set_include @@ -137,14 +138,22 @@ def update end def totals + logger = Logger.new(STDOUT) + page = { size: 0, number: 1} - response = Doi.query("", client_id: params[:client_id],page: page, totals_agg: true) + response = nil + logger.info "[Benchmark] prefixes totals " + Benchmark.ms { + response = Doi.query("", client_id: params[:client_id],page: page, totals_agg: true) + }.to_s + " ms" total = response.results.total - registrant = total > 0 ? prefixes_totals(response.response.aggregations.prefixes_totals.buckets) : nil - - render json: registrant, status: :ok - + registrant = nil + logger.info "[Benchmark] prefixes prefixes_totals " + Benchmark.ms { + registrant = total > 0 ? prefixes_totals(response.response.aggregations.prefixes_totals.buckets) : nil + }.to_s + " ms" + logger.info "[Benchmark] clients render " + Benchmark.ms { + render json: registrant, status: :ok + }.to_s + " ms" end def destroy diff --git a/app/controllers/providers_controller.rb b/app/controllers/providers_controller.rb index 6d65314cd..4dbd2b00a 100644 --- a/app/controllers/providers_controller.rb +++ b/app/controllers/providers_controller.rb @@ -1,3 +1,5 @@ +require 'benchmark' + class ProvidersController < ApplicationController include Countable