Class: Hyrax::WorkUsage
- Inherits:
-
StatsUsagePresenter
- Object
- StatsUsagePresenter
- Hyrax::WorkUsage
- Defined in:
- app/presenters/hyrax/work_usage.rb
Overview
Follows the model established by FileUsage.
Called by the stats controller, it finds cached work pageview data, and prepares it for visualization in /app/views/stats/work.html.erb
Instance Attribute Summary
Attributes inherited from StatsUsagePresenter
Instance Method Summary collapse
-
#initialize(id) ⇒ WorkUsage
constructor
A new instance of WorkUsage.
-
#to_flot ⇒ Object
Package data for visualization using JQuery Flot.
- #total_pageviews ⇒ Object
Methods inherited from StatsUsagePresenter
Constructor Details
#initialize(id) ⇒ WorkUsage
Returns a new instance of WorkUsage.
9 10 11 |
# File 'app/presenters/hyrax/work_usage.rb', line 9 def initialize(id) self.model = Hyrax::WorkRelation.new.find(id) end |
Instance Method Details
#to_flot ⇒ Object
Package data for visualization using JQuery Flot
21 22 23 24 25 |
# File 'app/presenters/hyrax/work_usage.rb', line 21 def to_flot [ { label: "Pageviews", data: pageviews } ] end |
#total_pageviews ⇒ Object
16 17 18 |
# File 'app/presenters/hyrax/work_usage.rb', line 16 def total_pageviews pageviews.reduce(0) { |total, result| total + result[1].to_i } end |