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.
132
133
134
|
# File 'lib/insight/database.rb', line 132
def initialize()
super("requests", "method", "url", "date")
end
|
Instance Method Details
#last_request_id ⇒ Object
141
142
143
|
# File 'lib/insight/database.rb', line 141
def last_request_id
execute("select max(id) from #@table_name").first.first
end
|
#store(method, url) ⇒ Object
136
137
138
139
|
# File 'lib/insight/database.rb', line 136
def store(method, url)
result = insert("'#{method}', '#{url}', #{Time.now.to_i}")
db.last_insert_row_id
end
|
#sweep ⇒ Object
145
146
147
|
# File 'lib/insight/database.rb', line 145
def sweep
execute("delete from #@table_name where date < #{Time.now.to_i - (60 * 60 * 12)}")
end
|