Sha256: 4619214bad9f5da37f3bf693152ed628657f9873660532f2bc49669bcd0e4cfe

Contents?: true

Size: 804 Bytes

Versions: 6

Compression:

Stored size: 804 Bytes

Contents

module Spotlight
  ##
  # Exhibit mixin to provide analytics data
  module ExhibitAnalytics
    def analytics(start_date = 1.month, path = nil)
      return OpenStruct.new unless analytics_provider && analytics_provider.enabled?

      @analytics ||= {}
      @analytics[start_date] ||= begin
        analytics_provider.exhibit_data(path || self, start_date: start_date.ago)
      end
    end

    def page_analytics(start_date = 1.month, path = nil)
      return [] unless analytics_provider && analytics_provider.enabled?

      @page_analytics ||= {}
      @page_analytics[start_date] ||= begin
        analytics_provider.page_data(path || self, start_date: start_date.ago)
      end
    end

    private

    def analytics_provider
      Spotlight::Engine.config.analytics_provider
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blacklight-spotlight-2.4.1 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-2.4.0 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-2.3.3 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-2.3.2 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-2.3.1 app/models/concerns/spotlight/exhibit_analytics.rb
blacklight-spotlight-2.3.0 app/models/concerns/spotlight/exhibit_analytics.rb