Class: TimeBuffer::SessionHandler
- Inherits:
-
Object
- Object
- TimeBuffer::SessionHandler
- Defined in:
- lib/time_buffer/session_handler.rb
Instance Method Summary collapse
-
#initialize(start_time:, end_time:) ⇒ SessionHandler
constructor
A new instance of SessionHandler.
- #insert_time_session(app_data) ⇒ Object
Constructor Details
#initialize(start_time:, end_time:) ⇒ SessionHandler
Returns a new instance of SessionHandler.
7 8 9 10 |
# File 'lib/time_buffer/session_handler.rb', line 7 def initialize(start_time:, end_time:) @start_time = start_time @end_time = end_time end |
Instance Method Details
#insert_time_session(app_data) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/time_buffer/session_handler.rb', line 12 def insert_time_session(app_data) application_id = TimeBuffer::DatabaseConnector.new.execute( "SELECT id FROM applications WHERE bundle_id = ?", [app_data.bundle_id] ).first&.first puts "application ID: #{application_id}" TimeBuffer::DatabaseConnector.new.execute( "INSERT INTO time_sessions (application_id, start_time, end_time, metadata) VALUES (?, ?, ?, ?);", [application_id, start_time.strftime("%Y-%m-%d %H:%M:%S"), end_time.strftime("%Y-%m-%d %H:%M:%S"), app_data..to_json] ) end |