Skip to content

Commit

Permalink
support sparse fieldsets
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 2, 2019
1 parent e065523 commit f7ceb60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,17 @@ def index
}

bmr = Benchmark.ms {
render json: DoiSerializer.new(results, options).serialized_json, status: :ok
logger.info params[:fields]
# support sparse fieldsets
if params[:fields]
f = params.to_unsafe_h.dig(:fields)
f = { dois: "doi" } unless f.is_a?(Hash)
f.each { |k, v| f[k] = v.split(",") }

render json: DoiSerializer.new(results, options.merge(fields: f)).serialized_json, status: :ok
else
render json: DoiSerializer.new(results, options).serialized_json, status: :ok
end
}

if bmr > 3000
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
- "9301:9300"
environment:
discovery.type: single-node
ES_JAVA_OPTS: -Xms1g -Xmx1g
ES_JAVA_OPTS: -Xms512m -Xmx512m
ELASTIC_PASSWORD: changeme
xpack.security.enabled: "false"
http.cors.enabled: "true"
Expand Down

0 comments on commit f7ceb60

Please sign in to comment.