Skip to content

Commit

Permalink
remove duplication. #386
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jan 16, 2020
1 parent 2012e81 commit 28b194c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def index
else { updated: { order: 'desc' }}
end

logger = Logger.new(STDOUT)

page = page_from_params(params)

sample_group_field = case params[:sample_group]
Expand Down Expand Up @@ -51,7 +53,6 @@ def index
end

begin
logger = Logger.new(STDOUT)
logger.warn "[Benchmark] Elasticsearch request " + response.took.to_s + " ms"

total = response.results.total
Expand All @@ -70,7 +71,6 @@ def index
clients = total > 0 ? facet_by_client(response.response.aggregations.clients.buckets) : nil
affiliations = total > 0 ? facet_by_affiliation(response.response.aggregations.affiliations.buckets) : nil
}
logger = Logger.new(STDOUT)
logger.warn "[Benchmark Warning] aggregations " + bma.to_s + " ms"

@dois = response.results
Expand Down Expand Up @@ -113,7 +113,6 @@ def index
bmr = Benchmark.ms {
render json: WorkSerializer.new(@dois, options).serialized_json, status: :ok
}
logger = Logger.new(STDOUT)
logger.warn "[Benchmark] render " + bmr.to_s + " ms"
rescue Elasticsearch::Transport::Transport::Errors::BadRequest => exception
message = JSON.parse(exception.message[6..-1]).to_h.dig("error", "root_cause", 0, "reason")
Expand Down

0 comments on commit 28b194c

Please sign in to comment.