Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/datacite/lupo
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 2, 2019
2 parents 1e6923c + 61134c2 commit 5b4460e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/controllers/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def totals
page = { size: 0, number: 1}
response = nil
bmt = Benchmark.ms {
response = Doi.query(nil, provider_id: params[:provider_id], state: "findable,registered", page: page, totals_agg: true)
state = current_user.present? && current_user.is_admin_or_staff? && params[:state].present? ? params[:state] : "registered,findable"
response = Doi.query(nil, provider_id: params[:provider_id], state: state, page: page, totals_agg: true)
}
if bmt > 10000
logger.warn "[Benchmark Warning] clients totals " + bmt.to_s + " ms"
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/concerns/facetable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def providers_totals(arr)
"this_month" => facet_anual(hsh.this_month.buckets),
"this_year" => facet_anual(hsh.this_year.buckets),
"last_year" => facet_anual(hsh.last_year.buckets)},
"two_years_ago" => facet_anual(hsh.two_years_ago.buckets),
"states" => facet_by_key(hsh.states.buckets)
}
end
Expand Down Expand Up @@ -309,7 +310,8 @@ def clients_totals(arr)
"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)
"last_year" => facet_anual(hsh.last_year.buckets),
"two_years_ago" => facet_anual(hsh.two_years_ago.buckets)
},
"states" => facet_by_key(hsh.states.buckets)
}
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ def totals
page = { size: 0, number: 1 }
response = nil
bmt = Benchmark.ms {
response = Doi.query(nil, state: "findable,registered", page: page, totals_agg: true)
state = current_user.present? && current_user.is_admin_or_staff? && params[:state].present? ? params[:state] : "registered,findable"
response = Doi.query(nil, state: state, page: page, totals_agg: true)
}

if bmt > 10000
Expand Down
3 changes: 2 additions & 1 deletion app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ def self.sub_aggregations
states: { terms: { field: 'aasm_state', size: 4, min_doc_count: 1 } },
this_month: { date_range: { field: 'created', ranges: { from: "now/M", to: "now/d" } } },
this_year: { date_range: { field: 'created', ranges: { from: "now/y", to: "now/d" } } },
last_year: { date_range: { field: 'created', ranges: { from: "now-1y/y", to: "now/y-1d" } } }
last_year: { date_range: { field: 'created', ranges: { from: "now-1y/y", to: "now/y-1d" } } },
two_years_ago: { date_range: { field: 'created', ranges: { from: "now-2y/y", to: "now-1y/y-1d" } } }
}
end

Expand Down

0 comments on commit 5b4460e

Please sign in to comment.