Sha256: 6d3da6327765bd46cc9898e87a95f19483337d74d237a7f49f4e06b2e9659d98

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

# A visit to the site
# 
# Page views belong to a tracking cookie, from which it derives its
# campaign code, and whether or not it is a "new visit" for the given
# campaign code.
#
# === Also stored from the request:
#
# [request_path] The full request path
# [user_agent]   The request user agent
# [referer]      The request referer if it exists
# [remote_ip]    The originating ip address of the request
# [session]      The session id of the request
#
class PageView < ActiveRecord::Base
  include E9Rails::ActiveRecord::Scopes::Times
  include E9::ActiveRecord::TimeScopes

  belongs_to :tracking_cookie

  belongs_to :campaign, :inverse_of => :page_views
  has_one :user, :through => :tracking_cookie

  scope :by_users, lambda {|*users| 
    joins(:tracking_cookie) & TrackingCookie.for_users(users)
  }

  scope :new_visits,    lambda {|v=true| where(:new_visit => v) }
  scope :repeat_visits, lambda { new_visits(false) }

  delegate :name, :code, :to => :campaign, :prefix => true, :allow_nil => true
  delegate :contact, :to => :user, :allow_nil => true
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
e9_crm-0.1.34 app/models/page_view.rb
e9_crm-0.1.33 app/models/page_view.rb
e9_crm-0.1.32 app/models/page_view.rb
e9_crm-0.1.31 app/models/page_view.rb
e9_crm-0.1.30 app/models/page_view.rb
e9_crm-0.1.29 app/models/page_view.rb
e9_crm-0.1.28 app/models/page_view.rb
e9_crm-0.1.27 app/models/page_view.rb