diff --git a/app/controllers/concerns/facetable.rb b/app/controllers/concerns/facetable.rb index 44aa921e3..1d47dd1d8 100644 --- a/app/controllers/concerns/facetable.rb +++ b/app/controllers/concerns/facetable.rb @@ -98,10 +98,7 @@ def facet_by_provider(arr) end def providers_totals(arr) - # generate hash with id and name for each provider in facet - - ids = arr.map { |hsh| hsh["key"] }.join(",") - providers = Provider.find_by_ids(ids, size: 1000).records.pluck(:symbol, :name).to_h + providers = Provider.all.pluck(:symbol, :name).to_h arr.map do |hsh| { "id" => hsh["key"], @@ -117,16 +114,15 @@ def providers_totals(arr) end def prefixes_totals(arr) - # generate hash with id and name for each provider in facet - arr.map do |hsh| { "id" => hsh["key"], "title" => hsh["key"], "count" => hsh["doc_count"], "temporal" => { - "this_month" => facet_anual(hsh.this_month.buckets), - "this_year" => facet_anual(hsh.this_year.buckets), - "last_year" => facet_anual(hsh.last_year.buckets)}, + "this_month" => facet_anual(hsh.this_month.buckets), + "this_year" => facet_anual(hsh.this_year.buckets), + "last_year" => facet_anual(hsh.last_year.buckets) + }, "states" => facet_by_key(hsh.states.buckets) } end @@ -136,15 +132,9 @@ def prefixes_totals(arr) def clients_totals(arr) logger = Logger.new(STDOUT) - # generate hash with id and name for each client in facet - ids = nil - logger.info "[Benchmark] clients_totals ids " + Benchmark.ms { - ids = arr.map { |hsh| hsh["key"] }.join(",") - }.to_s + " ms" - clients = nil logger.info "[Benchmark] clients_totals find_by_ids " + Benchmark.ms { - clients = Client.find_by_ids(ids, size: 2000).records.pluck(:symbol, :name).to_h + clients = Client.all.pluck(:symbol, :name).to_h }.to_s + " ms" logger.info "[Benchmark] clients_totals map " + Benchmark.ms { diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index 27cd79298..5348232ce 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -46,32 +46,30 @@ def index elsif params[:ids].present? response = Doi.find_by_ids(params[:ids], page: page, sort: sort) else - logger.info "[Benchmark] query " + Benchmark.ms { - response = Doi.query(params[:query], - state: params[:state], - created: params[:created], - registered: params[:registered], - provider_id: params[:provider_id], - client_id: params[:client_id], - prefix: params[:prefix], - person_id: params[:person_id], - resource_type_id: params[:resource_type_id], - schema_version: params[:schema_version], - subject: params[:subject], - link_check_status: params[:link_check_status], - link_check_has_schema_org: params[:link_check_has_schema_org], - link_check_body_has_pid: params[:link_check_body_has_pid], - link_check_found_schema_org_id: params[:link_check_found_schema_org_id], - link_check_found_dc_identifier: params[:link_check_found_dc_identifier], - link_check_found_citation_doi: params[:link_check_found_citation_doi], - link_check_redirect_count_gte: params[:link_check_redirect_count_gte], - sample_group: sample_group_field, - sample_size: params[:sample], - source: params[:source], - page: page, - sort: sort, - random: params[:random]) - }.to_s + " ms" + response = Doi.query(params[:query], + state: params[:state], + created: params[:created], + registered: params[:registered], + provider_id: params[:provider_id], + client_id: params[:client_id], + prefix: params[:prefix], + person_id: params[:person_id], + resource_type_id: params[:resource_type_id], + schema_version: params[:schema_version], + subject: params[:subject], + link_check_status: params[:link_check_status], + link_check_has_schema_org: params[:link_check_has_schema_org], + link_check_body_has_pid: params[:link_check_body_has_pid], + link_check_found_schema_org_id: params[:link_check_found_schema_org_id], + link_check_found_dc_identifier: params[:link_check_found_dc_identifier], + link_check_found_citation_doi: params[:link_check_found_citation_doi], + link_check_redirect_count_gte: params[:link_check_redirect_count_gte], + sample_group: sample_group_field, + sample_size: params[:sample], + source: params[:source], + page: page, + sort: sort, + random: params[:random]) end begin