Class: Gricer::ActiveRecord::Session
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gricer::ActiveRecord::Session
- Defined in:
- app/models/gricer/active_record/session.rb
Overview
ActiveRecord Model for Session Statistics
Instance Attribute Summary collapse
-
#agent ⇒ Gricer::Agent
The current value of the associated agent.
-
#city ⇒ String
The current value of the city from which the session was requested.
-
#country ⇒ String
The current value of the country from which the session was requested.
-
#domain ⇒ String
The current value of the domain (only major info) from which the session was requested.
-
#flash_major_version ⇒ String
The current value of the major version of flash installed on the requesting agent.
-
#flash_version ⇒ String
The current value of the version of flash installed on the requesting agent.
-
#ip_address_hash ⇒ String
The current value of the ip address in an anonyminized hash.
-
#java ⇒ Boolean
The current value of the java capability of the requesting agent.
-
#javascript ⇒ Boolean
The current value of the javascript capability of the requesting agent.
-
#latitude ⇒ Float
The current value of the latitude of the city/region from which the session was requested.
-
#longitude ⇒ Float
The current value of the longitude of the city/region from which the session was requested.
-
#postal_code ⇒ String
The current value of the region from which the session was requested.
-
#previous_session ⇒ Gricer::Session
The current value of the associated previous session.
-
#region ⇒ String
The current value of the region from which the session was requested.
-
#requested_locale ⇒ String
The current value of the locale requested.
-
#requested_locale_major ⇒ String
The current value of the locale requested (major locale only).
-
#requested_locale_minor ⇒ String
The current value of the locale requested (major locale only).
-
#screen_depth ⇒ Integer
The current value of the depth in bits of the screen the requesting agent’s window is on.
-
#screen_height ⇒ Integer
The current value of the height in pixels of the screen the requesting agent’s window is on.
-
#screen_width ⇒ Integer
The current value of the width in pixels of the screen the requesting agent’s window is on.
-
#silverlight_major_version ⇒ String
The current value of the major version of silverlight installed on the requesting agent.
-
#silverlight_version ⇒ String
The current value of the version of silverlight installed on the requesting agent.
Class Method Summary collapse
-
.avg_duration ⇒ Float
Get the average duration of sessions in seconds.
-
.browsers ⇒ ActiveRecord::Relation
Filter out anything that is not a Browser or MobileBrowser.
- .first_by_id(id) ⇒ Object
-
.new_visits ⇒ ActiveRecord::Relation
Filter out only new visits (which does not have a previous_session).
Methods included from LimitStrings
Methods included from Gricer::ActiveModel::Statistics
Methods included from Gricer::ActiveModel::Session
#duration, included, #ip_address=
Instance Attribute Details
#agent ⇒ Gricer::Agent
The current value of the associated agent.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def agent @agent end |
#city ⇒ String
The current value of the city from which the session was requested.
You need to configure a GeoIP in the Config instance.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def city @city end |
#country ⇒ String
The current value of the country from which the session was requested.
You need to configure a GeoIP in the Config instance.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def country @country end |
#domain ⇒ String
The current value of the domain (only major info) from which the session was requested.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def domain @domain end |
#flash_major_version ⇒ String
The current value of the major version of flash installed on the requesting agent.
This feature needs the usage of TrackHelper#gricer_track_tag.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def flash_major_version @flash_major_version end |
#flash_version ⇒ String
The current value of the version of flash installed on the requesting agent.
This feature needs the usage of TrackHelper#gricer_track_tag.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def flash_version @flash_version end |
#ip_address_hash ⇒ String
The current value of the ip address in an anonyminized hash
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def ip_address_hash @ip_address_hash end |
#java ⇒ Boolean
The current value of the java capability of the requesting agent.
This feature needs the usage of TrackHelper#gricer_track_tag.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def java @java end |
#javascript ⇒ Boolean
The current value of the javascript capability of the requesting agent.
This feature needs the usage of TrackHelper#gricer_track_tag.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def javascript @javascript end |
#latitude ⇒ Float
The current value of the latitude of the city/region from which the session was requested.
You need to configure a GeoIP in the Config instance.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def latitude @latitude end |
#longitude ⇒ Float
The current value of the longitude of the city/region from which the session was requested.
You need to configure a GeoIP in the Config instance.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def longitude @longitude end |
#postal_code ⇒ String
The current value of the region from which the session was requested.
You need to configure a GeoIP in the Config instance.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def postal_code @postal_code end |
#previous_session ⇒ Gricer::Session
The current value of the associated previous session.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def previous_session @previous_session end |
#region ⇒ String
The current value of the region from which the session was requested.
You need to configure a GeoIP in the Config instance.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def region @region end |
#requested_locale ⇒ String
The current value of the locale requested
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def requested_locale @requested_locale end |
#requested_locale_major ⇒ String
The current value of the locale requested (major locale only)
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def requested_locale_major @requested_locale_major end |
#requested_locale_minor ⇒ String
The current value of the locale requested (major locale only)
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def requested_locale_minor @requested_locale_minor end |
#screen_depth ⇒ Integer
The current value of the depth in bits of the screen the requesting agent’s window is on.
This feature needs the usage of TrackHelper#gricer_track_tag.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def screen_depth @screen_depth end |
#screen_height ⇒ Integer
The current value of the height in pixels of the screen the requesting agent’s window is on.
This feature needs the usage of TrackHelper#gricer_track_tag.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def screen_height @screen_height end |
#screen_width ⇒ Integer
The current value of the width in pixels of the screen the requesting agent’s window is on.
This feature needs the usage of TrackHelper#gricer_track_tag.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def screen_width @screen_width end |
#silverlight_major_version ⇒ String
The current value of the major version of silverlight installed on the requesting agent.
This feature needs the usage of TrackHelper#gricer_track_tag.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def silverlight_major_version @silverlight_major_version end |
#silverlight_version ⇒ String
The current value of the version of silverlight installed on the requesting agent.
This feature needs the usage of TrackHelper#gricer_track_tag.
101 102 103 |
# File 'app/models/gricer/active_record/session.rb', line 101 def silverlight_version @silverlight_version end |
Class Method Details
.avg_duration ⇒ Float
Get the average duration of sessions in seconds.
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'app/models/gricer/active_record/session.rb', line 131 def self.avg_duration if (c = self.count) > 0 #logger.debug ActiveRecord::Base.connection.class if ::ActiveRecord::Base.connection.class.to_s == 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter' self.sum("date_part('epoch', \"#{self.table_name}\".\"updated_at\") - date_part('epoch', \"#{self.table_name}\".\"created_at\")").to_f / c.to_f else self.sum("strftime('%s', \"#{self.table_name}\".\"updated_at\") - strftime('%s', \"#{self.table_name}\".\"created_at\")") / c.to_f end else 0 end end |
.browsers ⇒ ActiveRecord::Relation
Filter out anything that is not a Browser or MobileBrowser
119 120 121 122 |
# File 'app/models/gricer/active_record/session.rb', line 119 def self.browsers self.includes("agent") .where("\"#{Agent.table_name}\".\"agent_class_id\" IN (?)", [0x1000, 0x2000]) end |
.first_by_id(id) ⇒ Object
124 125 126 |
# File 'app/models/gricer/active_record/session.rb', line 124 def self.first_by_id(id) where(id: id).first end |
.new_visits ⇒ ActiveRecord::Relation
Filter out only new visits (which does not have a previous_session)
113 114 115 |
# File 'app/models/gricer/active_record/session.rb', line 113 def self.new_visits where("\"#{self.table_name}\".\"previous_session_id\" IS NULL") end |