Class: Hyrax::Statistics::Depositors::Summary

Inherits:
Object
  • Object
show all
Includes:
Blacklight::SearchHelper
Defined in:
app/services/hyrax/statistics/depositors/summary.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_date, end_date) ⇒ Summary

Returns a new instance of Summary.

Parameters:

  • start_date (Time)

    optionally specify the start date to gather the stats from

  • end_date (Time)

    optionally specify the end date to gather the stats from


19
20
21
22
# File 'app/services/hyrax/statistics/depositors/summary.rb', line 19

def initialize(start_date, end_date)
  @start_dt = start_date
  @end_dt = end_date
end

Instance Attribute Details

#end_dtObject

Returns the value of attribute end_dt


24
25
26
# File 'app/services/hyrax/statistics/depositors/summary.rb', line 24

def end_dt
  @end_dt
end

#start_dtObject

Returns the value of attribute start_dt


24
25
26
# File 'app/services/hyrax/statistics/depositors/summary.rb', line 24

def start_dt
  @start_dt
end

Class Method Details

.depositors(start_date:, end_date:) ⇒ Array<Hash>

Returns With keys of: :key, :deposits, and :user.

Parameters:

  • start_date (Time)

    optionally specify the start date to gather the stats from

  • end_date (Time)

    optionally specify the end date to gather the stats from

Returns:

  • (Array<Hash>)

    With keys of: :key, :deposits, and :user


13
14
15
# File 'app/services/hyrax/statistics/depositors/summary.rb', line 13

def self.depositors(start_date:, end_date:)
  new(start_date, end_date).depositors
end

Instance Method Details

#depositorsObject


26
27
28
29
30
31
32
33
# File 'app/services/hyrax/statistics/depositors/summary.rb', line 26

def depositors
  # step through the array by twos to get each pair
  results.map do |key, deposits|
    user = ::User.find_by_user_key(key)
    raise "Unable to find user '#{key}'\nResults was: #{results.inspect}" unless user
    { key: key, deposits: deposits, user: user }
  end
end