Sha256: deac2f27317116f566e692b5cf2a99a97eca3b9cf5efc92e31058fd0e61bb414
Contents?: true
Size: 933 Bytes
Versions: 19
Compression:
Stored size: 933 Bytes
Contents
# frozen_string_literal: true module Hyrax ## # Called by the stats controller, it finds cached file pageview data, # and prepares it for visualization in /app/views/stats/file.html.erb class FileUsage < StatsUsagePresenter def initialize(id) self.model = ::FileSet.find(id) end alias file model def total_downloads downloads.reduce(0) { |total, result| total + result[1].to_i } end 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 }, { label: "Downloads", data: downloads } ] end private def downloads to_flots(FileDownloadStat.statistics(model, created, user_id)) end def pageviews to_flots(FileViewStat.statistics(model, created, user_id)) end end end
Version data entries
19 entries across 19 versions & 1 rubygems