Class: Gricer::ActiveRecord::Request

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Gricer::ActiveModel::Request, Gricer::ActiveModel::Statistics, LimitStrings
Defined in:
app/models/gricer/active_record/request.rb

Overview

ActiveRecord Model for Request Statistics

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LimitStrings

included

Methods included from Gricer::ActiveModel::Statistics

included, #model_type

Methods included from Gricer::ActiveModel::Request

#agent_header=, included, #ip_address=, #params=, #referer=, #request=

Instance Attribute Details

#actionString

The current value of the action requested.

Returns:

  • (String)

    the current value of action



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def action
  @action
end

#agentGricer::Agent

The current value of the associated agent.

Returns:

  • (Gricer::Agent)

    the current value of agent



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def agent
  @agent
end

#body_sizeString

The current size of the body returned.

Returns:

  • (String)

    the current value of body_size



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def body_size
  @body_size
end

#content_typeString

The current value of the content type returned.

Returns:

  • (String)

    the current value of content_type



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def content_type
  @content_type
end

#controllerString

The current value of the controller requested.

Returns:

  • (String)

    the current value of controller



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def controller
  @controller
end

#formatString

The current value of the format requested.

Returns:

  • (String)

    the current value of format



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def format
  @format
end

#hostString

The current value of the host requested.

Returns:

  • (String)

    the current value of host



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def host
  @host
end

#is_first_in_sessionBoolean

The current value of the first in session flag. This is true if it is the first request within a Gricer::Session.

Returns:

  • (Boolean)

    the current value of is_first_in_session



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def is_first_in_session
  @is_first_in_session
end

#javascriptBoolean

The current value of the javascript capability of the requesting agent.

This feature needs the usage of TrackHelper#gricer_track_tag.

Returns:

  • (Boolean)

    the current value of javascript



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def javascript
  @javascript
end

#localeString

The current value of the locale responded

Returns:

  • (String)

    the current value of locale



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def locale
  @locale
end

#locale_majorString

The current value of the locale responded (major locale only)

Returns:

  • (String)

    the current value of locale_major



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def locale_major
  @locale_major
end

#locale_minorString

The current value of the locale responded (major locale only)

Returns:

  • (String)

    the current value of locale_minor



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def locale_minor
  @locale_minor
end

#methodString

The current value of the method requested.

Returns:

  • (String)

    the current value of method



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def method
  @method
end

#param_idString

The current value of the http GET/POST id parameter requested.

Returns:

  • (String)

    the current value of param_id



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def param_id
  @param_id
end

#pathString

The current value of the path requested.

Returns:

  • (String)

    the current value of path



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def path
  @path
end

#protocolString

The current value of the protocol requested.

Returns:

  • (String)

    the current value of protocol



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def protocol
  @protocol
end

#real_timeString

The current value of the real time elapsed processing this request.

Returns:

  • (String)

    the current value of real_time



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def real_time
  @real_time
end

#referer_hostString

The current value of the host of the referering page.

Returns:

  • (String)

    the current value of referer_host



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def referer_host
  @referer_host
end

#referer_paramsString

The current value of the params of the referering page.

Returns:

  • (String)

    the current value of referer_params



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def referer_params
  @referer_params
end

#referer_pathString

The current value of the path of the referering page.

Returns:

  • (String)

    the current value of referer_path



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def referer_path
  @referer_path
end

#referer_protocolString

The current value of the protocol of the referering page.

Returns:

  • (String)

    the current value of referer_protocol



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def referer_protocol
  @referer_protocol
end

#search_engineString

The current value of the search engine name refering to get to this request.

Returns:

  • (String)

    the current value of search_engine



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def search_engine
  @search_engine
end

#search_queryString

The current value of the search query refering to get to this request.

Returns:

  • (String)

    the current value of search_query



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def search_query
  @search_query
end

#sessionGricer::Session

The current value of the associated session.

Returns:

  • (Gricer::Session)

    the current value of session



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def session
  @session
end

#status_codeInteger

The current value of the HTTP status returned.

Returns:

  • (Integer)

    the current value of status_code



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def status_code
  @status_code
end

#system_timeString

The current value of the system time elapsed processing this request.

Returns:

  • (String)

    the current value of system_time



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def system_time
  @system_time
end

#total_timeString

The current value of the total time elapsed processing this request.

Returns:

  • (String)

    the current value of total_time



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def total_time
  @total_time
end

#user_idInteger

The current id of the user logged in.

Returns:

  • (Integer)

    the current value of user_id

See Also:



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def user_id
  @user_id
end

#user_timeString

The current value of the user time elapsed processing this request.

Returns:

  • (String)

    the current value of user_time



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def user_time
  @user_time
end

#window_heightInteger

The current value of the height in pixels of the requesting agent’s window.

This feature needs the usage of TrackHelper#gricer_track_tag.

Returns:

  • (Integer)

    the current value of window_height



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def window_height
  @window_height
end

#window_widthInteger

The current value of the width in pixels of the requesting agent’s window.

This feature needs the usage of TrackHelper#gricer_track_tag.

Returns:

  • (Integer)

    the current value of window_width



107
108
109
# File 'app/models/gricer/active_record/request.rb', line 107

def window_width
  @window_width
end

Class Method Details

.browsersActiveRecord::Relation

Filter out anything that is not a Browser or MobileBrowser

Returns:

  • (ActiveRecord::Relation)


120
121
122
123
# File 'app/models/gricer/active_record/request.rb', line 120

def self.browsers
  includes("agent")
  .where("\"#{Agent.table_name}\".\"agent_class_id\" IN (?)", [0x1000, 0x2000])
end

.first_by_id(id) ⇒ Object



125
126
127
# File 'app/models/gricer/active_record/request.rb', line 125

def self.first_by_id(id)
  where(id: id).first
end

Instance Method Details

#init_sessionGricer::Session

Init the corrosponding Gricer::Session (called before create)

Returns:

  • (Gricer::Session)


132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'app/models/gricer/active_record/request.rb', line 132

def init_session
  if session
    if session.updated_at < Time.now - ::Gricer.config.max_session_duration
      self.session = Session.create previous_session: session, ip_address: @ip_address, agent: agent, requested_locale: @request_locale
    else
      self.session.touch
    end
  else
    self.is_first_in_session = true
    self.session = Session.create ip_address: @ip_address, agent: agent, requested_locale: @request_locale
    self.session.touch
  end
      
  session
end