Skip to content

Commit

Permalink
ab performance measuring ES vs. DB. #386
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jan 17, 2020
1 parent dfd24cc commit 1a4bac1
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,25 @@ def show
protected

def set_doi
@doi = nil
bm = Benchmark.ms {
options = filter_doi_by_role(current_user)
response = Doi.find_by_id(params[:id], options)
@doi = response.results.first
}

fail ActiveRecord::RecordNotFound unless @doi.present?

logger = LogStashLogger.new(type: :stdout)
logger.warn method: "GET", path: "/works/#{@doi.doi}", message: "Request /works/#{@doi.doi}", duration: bm

@doi = nil

if rand(2) == 0
bm = Benchmark.ms {
@doi = Doi.where(doi: params[:id], aasm_state: "findable").first
}
fail ActiveRecord::RecordNotFound unless @doi.present?
logger.warn method: "GET", path: "/works/#{@doi.doi}", message: "Request DB /works/#{@doi.doi}", duration: bm
else
bm = Benchmark.ms {
options = filter_doi_by_role(current_user)
response = Doi.find_by_id(params[:id], options)
@doi = response.results.first
}
fail ActiveRecord::RecordNotFound unless @doi.present?
logger.warn method: "GET", path: "/works/#{@doi.doi}", message: "Request ES /works/#{@doi.doi}", duration: bm
end
end

def set_include
Expand Down

0 comments on commit 1a4bac1

Please sign in to comment.