diff --git a/app/controllers/clients_controller.rb b/app/controllers/clients_controller.rb index 41d1ae1bf..444c536cb 100644 --- a/app/controllers/clients_controller.rb +++ b/app/controllers/clients_controller.rb @@ -135,7 +135,7 @@ def totals page = { size: 0, number: 1} response = nil bmt = Benchmark.ms { - response = Doi.query(nil, provider_id: params[:provider_id], state: params[:state], page: page, totals_agg: true) + response = Doi.query(nil, provider_id: params[:provider_id], state: "findable,registered", page: page, totals_agg: true) } if bmt > 10000 logger.warn "[Benchmark Warning] clients totals " + bmt.to_s + " ms" diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index 5a4b8b3ce..9307788b8 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -41,6 +41,9 @@ def index response = nil + # only show findable DOIs to anonymous users + params[:state] = "findable" if current_user.nil? + if params[:id].present? logger.info "[Benchmark] find_by_id " + Benchmark.ms { response = Doi.find_by_id(params[:id]) @@ -71,8 +74,7 @@ def index source: params[:source], page: page, sort: sort, - random: params[:random], - current_user: current_user) + random: params[:random]) end begin diff --git a/app/controllers/prefixes_controller.rb b/app/controllers/prefixes_controller.rb index b5fdc65a6..aa6a96e2e 100644 --- a/app/controllers/prefixes_controller.rb +++ b/app/controllers/prefixes_controller.rb @@ -143,7 +143,7 @@ def totals page = { size: 0, number: 1} response = nil logger.info "[Benchmark] prefixes totals " + Benchmark.ms { - response = Doi.query("", client_id: params[:client_id], state: params[:state], page: page, totals_agg: true) + response = Doi.query(nil, client_id: params[:client_id], state: "findable,registered", page: page, totals_agg: true) }.to_s + " ms" total = response.results.total diff --git a/app/controllers/providers_controller.rb b/app/controllers/providers_controller.rb index 45ad6c777..230f2f16c 100644 --- a/app/controllers/providers_controller.rb +++ b/app/controllers/providers_controller.rb @@ -185,10 +185,10 @@ def update def totals logger = Logger.new(STDOUT) - page = { size: 0, number: 1} + page = { size: 0, number: 1 } response = nil bmt = Benchmark.ms { - response = Doi.query("", state: params[:state], page: page, totals_agg: true) + response = Doi.query(nil, state: "findable,registered", page: page, totals_agg: true) } if bmt > 10000 @@ -197,6 +197,8 @@ def totals logger.info "[Benchmark] providers totals " + bmt.to_s + " ms" end + logger.info response.results.inspect + total = response.results.total registrant = nil diff --git a/app/controllers/works_controller.rb b/app/controllers/works_controller.rb index e131a1b35..6214b3a09 100644 --- a/app/controllers/works_controller.rb +++ b/app/controllers/works_controller.rb @@ -46,8 +46,7 @@ def index sample_size: params[:sample], page: page, sort: sort, - random: params[:sample].present? ? true : false, - current_user: current_user) + random: params[:sample].present? ? true : false) end begin diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index 3e23b5a7e..90a709711 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -171,12 +171,7 @@ def query(query, options={}) must << { terms: { "software.raw" => options[:software].split(",") }} if options[:software].present? must_not << { exists: { field: "deleted_at" }} unless options[:include_deleted] elsif self.name == "Doi" - # anonymous users should only see findable DOIs - if options[:current_user] - must << { terms: { aasm_state: options[:state].to_s.split(",") }} if options[:state].present? - else - must << { terms: { aasm_state: ["findable"] }} - end + must << { terms: { aasm_state: options[:state].to_s.split(",") }} if options[:state].present? must << { range: { registered: { gte: "#{options[:registered].split(",").min}||/y", lte: "#{options[:registered].split(",").max}||/y", format: "yyyy" }}} if options[:registered].present? end