Class: Hyrax::AdminStatsPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/hyrax/admin_stats_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stats_filters, limit) ⇒ AdminStatsPresenter

Returns a new instance of AdminStatsPresenter.



5
6
7
8
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 5

def initialize(stats_filters, limit)
  @stats_filters = stats_filters
  @limit = limit
end

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit.



3
4
5
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 3

def limit
  @limit
end

#stats_filtersObject (readonly)

Returns the value of attribute stats_filters.



3
4
5
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 3

def stats_filters
  @stats_filters
end

Instance Method Details

#active_usersObject



38
39
40
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 38

def active_users
  @active_users ||= Hyrax::Statistics::Works::ByDepositor.query(limit: limit)
end

#date_filter_stringObject



52
53
54
55
56
57
58
59
60
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 52

def date_filter_string
  if start_date.blank?
    "unfiltered"
  elsif end_date.blank?
    "#{start_date.to_date.to_formatted_s(:standard)} to #{Date.current.to_formatted_s(:standard)}"
  else
    "#{start_date.to_date.to_formatted_s(:standard)} to #{end_date.to_date.to_formatted_s(:standard)}"
  end
end

#depositorsObject



28
29
30
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 28

def depositors
  @depositors ||= Hyrax::Statistics::Depositors::Summary.depositors(start_date: start_date, end_date: end_date)
end

#end_dateObject



14
15
16
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 14

def end_date
  @end_date ||= extract_date_from_stats_filters(key: :end_date, as_of: :end_of_day)
end

#recent_usersObject



33
34
35
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 33

def recent_users
  @recent_users ||= Hyrax::Statistics::SystemStats.recent_users(limit: limit, start_date: start_date, end_date: end_date)
end

#start_dateObject



10
11
12
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 10

def start_date
  @start_date ||= extract_date_from_stats_filters(key: :start_date, as_of: :beginning_of_day)
end

#top_formatsObject



43
44
45
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 43

def top_formats
  @top_formats ||= Hyrax::Statistics::FileSets::ByFormat.query(limit: limit)
end

#works_countObject



48
49
50
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 48

def works_count
  @works_count ||= Hyrax::Statistics::Works::Count.by_permission(start_date: start_date, end_date: end_date)
end