Sha256: dd2f4d22de3c7d5af7a24f6ccbe611feeeecf8de27765ba93cad7f94ff390eac

Contents?: true

Size: 1.2 KB

Versions: 21

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true
module Hyrax
  module Analytics
    module Google
      module Visits
        extend Legato::Model

        dimensions :user_type
        metrics :sessions

        def self.results_array(response)
          results = []
          response.to_a.each do |result|
            results.push([result.date.to_date, result.result.sessions.to_i])
          end
          Hyrax::Analytics::Results.new(results)
        end

        def self.new_visits(profile, start_date, end_date)
          x = Visits.results(profile,
            start_date: start_date,
            end_date: end_date).to_a
          x.first.sessions.to_i
        end

        def self.return_visits(profile, start_date, end_date)
          x = Visits.results(profile,
            start_date: start_date,
            end_date: end_date).to_a
          x.last.sessions.to_i
        end

        def self.total_visits(profile, start_date, end_date)
          x = Visits.results(profile,
            start_date: start_date,
            end_date: end_date).to_a
          new_visits = x.first.sessions.to_i
          returning_visits = x.last.sessions.to_i
          new_visits + returning_visits
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/services/hyrax/analytics/google/visits.rb
hyrax-5.0.4 app/services/hyrax/analytics/google/visits.rb
hyrax-5.0.3 app/services/hyrax/analytics/google/visits.rb
hyrax-5.0.2 app/services/hyrax/analytics/google/visits.rb
hyrax-5.0.1 app/services/hyrax/analytics/google/visits.rb
hyrax-5.0.0 app/services/hyrax/analytics/google/visits.rb
hyrax-5.0.0.rc3 app/services/hyrax/analytics/google/visits.rb
hyrax-5.0.0.rc2 app/services/hyrax/analytics/google/visits.rb
hyrax-5.0.0.rc1 app/services/hyrax/analytics/google/visits.rb
hyrax-3.6.0 app/services/hyrax/analytics/google/visits.rb
hyrax-4.0.0 app/services/hyrax/analytics/google/visits.rb
hyrax-4.0.0.rc3 app/services/hyrax/analytics/google/visits.rb
hyrax-4.0.0.rc2 app/services/hyrax/analytics/google/visits.rb
hyrax-4.0.0.rc1 app/services/hyrax/analytics/google/visits.rb
hyrax-3.5.0 app/services/hyrax/analytics/google/visits.rb
hyrax-4.0.0.beta2 app/services/hyrax/analytics/google/visits.rb
hyrax-3.4.2 app/services/hyrax/analytics/google/visits.rb
hyrax-4.0.0.beta1 app/services/hyrax/analytics/google/visits.rb
hyrax-3.4.1 app/services/hyrax/analytics/google/visits.rb
hyrax-3.4.0 app/services/hyrax/analytics/google/visits.rb