Skip to content

Commit

Permalink
show number of registered dois in stats portal
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 1, 2019
1 parent 051de01 commit 25f96cf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/prefixes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions app/controllers/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 25f96cf

Please sign in to comment.