Sha256: c051ac3179ecf530de3f9ad15f111f1fb4f899f7aa5cc4957d6e0aff706c3cf1

Contents?: true

Size: 800 Bytes

Versions: 56

Compression:

Stored size: 800 Bytes

Contents

class FileDownloadStat < Hyrax::Statistic
  self.cache_column = :downloads
  self.event_type = :totalEvents

  class << self
    # Hyrax::Download is sent to Hyrax::Analytics.profile as #hyrax__download
    # see Legato::ProfileMethods.method_name_from_klass
    def ga_statistics(start_date, file)
      profile = Hyrax::Analytics.profile
      unless profile
        Rails.logger.error("Google Analytics profile has not been established. Unable to fetch statistics.")
        return []
      end
      profile.hyrax__download(sort: 'date',
                              start_date: start_date,
                              end_date: Date.yesterday)
             .for_file(file.id)
    end

    # this is called by the parent class
    def filter(file)
      { file_id: file.id }
    end
  end
end

Version data entries

56 entries across 56 versions & 2 rubygems

Version Path
hyrax-2.9.6 app/models/file_download_stat.rb
hyrax-2.9.5 app/models/file_download_stat.rb
hyrax-2.9.4 app/models/file_download_stat.rb
hyrax-2.9.3 app/models/file_download_stat.rb
hyrax-2.9.2 app/models/file_download_stat.rb
hyrax-2.9.1 app/models/file_download_stat.rb
hyrax-2.9.0 app/models/file_download_stat.rb
hyrax-2.8.0 app/models/file_download_stat.rb
hyrax-2.7.2 app/models/file_download_stat.rb
hyrax-2.7.1 app/models/file_download_stat.rb
hyrax-2.7.0 app/models/file_download_stat.rb
hyrax-2.6.0 app/models/file_download_stat.rb
hyrax-2.5.1 app/models/file_download_stat.rb
hyrax-2.5.0 app/models/file_download_stat.rb
hyrax-3.0.0.pre.beta2 app/models/file_download_stat.rb
hyrax-2.4.1 app/models/file_download_stat.rb
hyrax-3.0.0.pre.beta1 app/models/file_download_stat.rb
hyrax-2.4.0 app/models/file_download_stat.rb
hyrax-2.3.3 app/models/file_download_stat.rb
hyrax-2.3.2 app/models/file_download_stat.rb