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.



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

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

Instance Method Details

#last_request_idObject



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

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

#store(method, url) ⇒ Object



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

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

#sweepObject



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

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