Sha256: 4f969a375ea3200c35c002e864c870e5304b8cb0069c30037ed263da10d954e9

Contents?: true

Size: 800 Bytes

Versions: 8

Compression:

Stored size: 800 Bytes

Contents

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

  class << self
    # Sufia::Download is sent to Sufia::Analytics.profile as #sufia__download
    # see Legato::ProfileMethods.method_name_from_klass
    def ga_statistics(start_date, file)
      profile = Sufia::Analytics.profile
      unless profile
        Rails.logger.error("Google Analytics profile has not been established. Unable to fetch statistics.")
        return []
      end
      profile.sufia__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

8 entries across 8 versions & 1 rubygems

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