Sha256: 521eed3f7b7f84cd968afe768f2dd75bcea18ee85e495f1bd5d17c9a15febc92

Contents?: true

Size: 767 Bytes

Versions: 8

Compression:

Stored size: 767 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 Sufia
  class WorkUsage < StatsUsagePresenter
    def initialize(id)
      self.model = CurationConcerns::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

8 entries across 8 versions & 1 rubygems

Version Path
sufia-7.4.1 app/presenters/sufia/work_usage.rb
sufia-7.4.0 app/presenters/sufia/work_usage.rb
sufia-7.3.1 app/presenters/sufia/work_usage.rb
sufia-7.3.0 app/presenters/sufia/work_usage.rb
sufia-7.3.0.rc3 app/presenters/sufia/work_usage.rb
sufia-7.3.0.rc2 app/presenters/sufia/work_usage.rb
sufia-7.3.0.rc1 app/presenters/sufia/work_usage.rb
sufia-7.2.0 app/presenters/sufia/work_usage.rb