Sha256: 048f37971c2bb349a15dacd4c197742faf082f078d55254ae7b6b4fa1812b2c4

Contents?: true

Size: 906 Bytes

Versions: 58

Compression:

Stored size: 906 Bytes

Contents

# Called by the stats controller, it finds cached file pageview data,
# and prepares it for visualization in /app/views/stats/file.html.erb
module Hyrax
  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

58 entries across 58 versions & 2 rubygems

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