Class: Hyrax::WorkUsage

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

Instance Attribute Summary

Attributes inherited from StatsUsagePresenter

#id, #model

Instance Method Summary collapse

Methods inherited from StatsUsagePresenter

#created

Constructor Details

#initialize(id) ⇒ WorkUsage

Returns a new instance of WorkUsage.



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

def initialize(id)
  self.model = Hyrax::WorkRelation.new.find(id)
end

Instance Method Details

#to_flotObject

Package data for visualization using JQuery Flot



18
19
20
21
22
# File 'app/presenters/hyrax/work_usage.rb', line 18

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

#total_pageviewsObject



13
14
15
# File 'app/presenters/hyrax/work_usage.rb', line 13

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