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

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

Overview

Gather information about the depositors who have contributed to the repository

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



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

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.



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

def end_dt
  @end_dt
end

#start_dtObject

Returns the value of attribute start_dt.



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

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



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

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

Instance Method Details

#depositorsObject



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

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