Module: Sufia::Admin::DepositorStats
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/controllers/concerns/sufia/admin/depositor_stats.rb
Overview
Module to gather information about the deposits in the system
Instance Method Summary collapse
-
#depositors(deposit_stats) ⇒ Object
Gather information about the depositors in the system.
Instance Method Details
#depositors(deposit_stats) ⇒ Object
Gather information about the depositors in the system
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/concerns/sufia/admin/depositor_stats.rb', line 18 def depositors(deposit_stats) start_datetime = DateTime.parse(deposit_stats[:start_date]) unless deposit_stats[:start_date].blank? end_datetime = DateTime.parse(deposit_stats[:end_date]).end_of_day unless deposit_stats[:end_date].blank? query = ::GenericFile.build_date_query(start_datetime, end_datetime) unless start_datetime.blank? sb = DepositSearchBuilder.new([:include_depositor_facet], self) facet_results = repository.search(sb.merge(q: query).query) facets = facet_results["facet_counts"]["facet_fields"]["depositor_ssim"] depositors = [] # facet results come back in an array where the first item is the user and the second item is the count # [ abc123, 55, ccczzz, 205 ] # in the loop we are stepping through the array by twos to get the entire pair # The item at i is the key and the item at i+1 is the number of files (0...facets.length).step(2).each do |i| depositor = {} depositor[:key] = facets[i] depositor[:deposits] = facets[i + 1] depositor[:user] = User.find_by_user_key(depositor[:key]) depositors << depositor end depositors end |