Class: Hyrax::FileUsage

Inherits:
StatsUsagePresenter show all
Defined in:
app/presenters/hyrax/file_usage.rb

Instance Attribute Summary

Attributes inherited from StatsUsagePresenter

#id, #model

Instance Method Summary collapse

Methods inherited from StatsUsagePresenter

#created

Constructor Details

#initialize(id) ⇒ FileUsage

Returns a new instance of FileUsage.



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

def initialize(id)
  self.model = ::FileSet.find(id)
end

Instance Method Details

#to_flotObject

Package data for visualization using JQuery Flot



20
21
22
23
24
25
# File 'app/presenters/hyrax/file_usage.rb', line 20

def to_flot
  [
    { label: "Pageviews",  data: pageviews },
    { label: "Downloads",  data: downloads }
  ]
end

#total_downloadsObject



11
12
13
# File 'app/presenters/hyrax/file_usage.rb', line 11

def total_downloads
  downloads.reduce(0) { |total, result| total + result[1].to_i }
end

#total_pageviewsObject



15
16
17
# File 'app/presenters/hyrax/file_usage.rb', line 15

def total_pageviews
  pageviews.reduce(0) { |total, result| total + result[1].to_i }
end