Class: Insight::Database::RequestTable
- Inherits:
-
Table
- Object
- Table
- Insight::Database::RequestTable
show all
- Defined in:
- lib/insight/database.rb
Instance Method Summary
collapse
Methods inherited from Table
#create_keys_clause, #create_sql, #db, #execute, #fields_sql, #insert, #keys, #length, #select, #to_a
Methods included from Logging
logger
Constructor Details
Returns a new instance of RequestTable.
133
134
135
|
# File 'lib/insight/database.rb', line 133
def initialize()
super("requests", "method", "url", "date")
end
|
Instance Method Details
#last_request_id ⇒ Object
142
143
144
|
# File 'lib/insight/database.rb', line 142
def last_request_id
execute("select max(id) from #@table_name").first.first
end
|
#store(method, url) ⇒ Object
137
138
139
140
|
# File 'lib/insight/database.rb', line 137
def store(method, url)
result = insert("'#{method}', '#{url}', #{Time.now.to_i}")
db.last_insert_row_id
end
|
#sweep ⇒ Object
146
147
148
|
# File 'lib/insight/database.rb', line 146
def sweep
execute("delete from #@table_name where date < #{Time.now.to_i - (60 * 60 * 12)}")
end
|