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



26
27
28
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 26

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

#date_filter_stringObject



38
39
40
41
42
43
44
45
46
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 38

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



18
19
20
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 18

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

#end_dateObject



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

def end_date
  @end_date ||= Time.zone.parse(stats_filters[:end_date]).end_of_day if stats_filters[:end_date].present?
end

#recent_usersObject



22
23
24
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 22

def recent_users
  @recent_users ||= stats.recent_users
end

#start_dateObject



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

def start_date
  @start_date ||= Time.zone.parse(stats_filters[:start_date]).beginning_of_day if stats_filters[:start_date].present?
end

#top_formatsObject



30
31
32
# File 'app/presenters/hyrax/admin_stats_presenter.rb', line 30

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

#works_countObject



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

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