diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index 5a12c7abd..c28b41134 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -135,7 +135,6 @@ def index respond_to do |format| format.json do - @dois = results options = {} options[:meta] = { total: total, @@ -161,11 +160,11 @@ def index options[:links] = { self: request.original_url, - next: @dois.size < page[:size] ? nil : request.base_url + "/dois?" + { + next: results.size < page[:size] ? nil : request.base_url + "/dois?" + { query: params[:query], "provider-id" => params[:provider_id], "client-id" => params[:client_id], - "page[cursor]" => page[:cursor].present? ? Array.wrap(@dois.to_a.last[:sort]).first : nil, + "page[cursor]" => page[:cursor].present? ? Array.wrap(results.to_a.last[:sort]).first : nil, "page[number]" => page[:cursor].blank? && page[:number].present? ? page[:number] + 1 : nil, "page[size]" => page[:size] }.compact.to_query }.compact @@ -176,7 +175,7 @@ def index } logger.info "[Benchmark] render " + Benchmark.ms { - render json: DoiSerializer.new(@dois, options).serialized_json, status: :ok + render json: DoiSerializer.new(results, options).serialized_json, status: :ok }.to_s + " ms" end format.citation do @@ -393,7 +392,7 @@ def get_dois head :no_content and return unless client_prefix.present? dois = Doi.get_dois(prefix: client_prefix.prefix, username: current_user.uid.upcase, password: current_user.password) - if dois.length > 0 + if dois.length > 0 render json: { dois: dois }.to_json, status: :ok else head :no_content