Sha256: bbb41851aeaa683f564875dfe04c3b4ae5bc49b1e4c941d33859e124f460ccf0

Contents?: true

Size: 756 Bytes

Versions: 58

Compression:

Stored size: 756 Bytes

Contents

# class WorkUsage 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
module Hyrax
  class WorkUsage < StatsUsagePresenter
    def initialize(id)
      self.model = Hyrax::WorkRelation.new.find(id)
    end

    alias work model
    delegate :to_s, to: :model

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

    # Package data for visualization using JQuery Flot
    def to_flot
      [
        { label: "Pageviews", data: pageviews }
      ]
    end

    private

      def pageviews
        to_flots WorkViewStat.statistics(model, created, user_id)
      end
  end
end

Version data entries

58 entries across 58 versions & 2 rubygems

Version Path
hyrax-2.9.6 app/presenters/hyrax/work_usage.rb
hyrax-2.9.5 app/presenters/hyrax/work_usage.rb
hyrax-2.9.4 app/presenters/hyrax/work_usage.rb
hyrax-2.9.3 app/presenters/hyrax/work_usage.rb
hyrax-2.9.2 app/presenters/hyrax/work_usage.rb
hyrax-2.9.1 app/presenters/hyrax/work_usage.rb
hyrax-2.9.0 app/presenters/hyrax/work_usage.rb
hyrax-2.8.0 app/presenters/hyrax/work_usage.rb
hyrax-2.7.2 app/presenters/hyrax/work_usage.rb
hyrax-2.7.1 app/presenters/hyrax/work_usage.rb
hyrax-2.7.0 app/presenters/hyrax/work_usage.rb
hyrax-2.6.0 app/presenters/hyrax/work_usage.rb
hyrax-3.0.0.pre.rc1 app/presenters/hyrax/work_usage.rb
hyrax-3.0.0.pre.beta3 app/presenters/hyrax/work_usage.rb
hyrax-2.5.1 app/presenters/hyrax/work_usage.rb
hyrax-2.5.0 app/presenters/hyrax/work_usage.rb
hyrax-3.0.0.pre.beta2 app/presenters/hyrax/work_usage.rb
hyrax-2.4.1 app/presenters/hyrax/work_usage.rb
hyrax-3.0.0.pre.beta1 app/presenters/hyrax/work_usage.rb
hyrax-2.4.0 app/presenters/hyrax/work_usage.rb