Class: Rack::Insight::Database::RequestTable

Inherits:
Table
  • Object
show all
Defined in:
lib/rack/insight/database.rb

Instance Method Summary collapse

Methods inherited from Table

#count, #create_keys_clause, #create_sql, #db, #execute, #fields_sql, #insert, #keys, #length, #select, #to_a

Methods included from Logging

logger, verbose, verbosity

Constructor Details

#initializeRequestTable

Returns a new instance of RequestTable.



165
166
167
# File 'lib/rack/insight/database.rb', line 165

def initialize()
  super("requests", "method", "url", "date")
end

Instance Method Details

#last_request_idObject



174
175
176
# File 'lib/rack/insight/database.rb', line 174

def last_request_id
  execute("select max(id) from #@table_name").first.first
end

#store(method, url) ⇒ Object



169
170
171
172
# File 'lib/rack/insight/database.rb', line 169

def store(method, url)
  result = insert("'#{method}', '#{url}', #{Time.now.to_i}")
  db.last_insert_row_id
end

#sweepObject



178
179
180
# File 'lib/rack/insight/database.rb', line 178

def sweep
  execute("delete from #@table_name where date < #{Time.now.to_i - (60 * 60 * 12)}")
end