Sha256: 459ed2a9aae9931336dc6d0bfcea037a08c1cd2f6d811c6da7dd5a36f84d2d21
Contents?: true
Size: 823 Bytes
Versions: 17
Compression:
Stored size: 823 Bytes
Contents
# frozen_string_literal: true module Hyrax # TODO: - Analytics do we still need this? # 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 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
17 entries across 17 versions & 1 rubygems