@@ -70,12 +70,12 @@ def _insert(
70
70
71
71
72
72
def insert_action_event (
73
- recording_timestamp : int , event_timestamp : int , event_data : dict [str , Any ]
73
+ recording_timestamp : float , event_timestamp : int , event_data : dict [str , Any ]
74
74
) -> None :
75
75
"""Insert an action event into the database.
76
76
77
77
Args:
78
- recording_timestamp (int ): The timestamp of the recording.
78
+ recording_timestamp (float ): The timestamp of the recording.
79
79
event_timestamp (int): The timestamp of the event.
80
80
event_data (dict): The data of the event.
81
81
"""
@@ -88,12 +88,12 @@ def insert_action_event(
88
88
89
89
90
90
def insert_screenshot (
91
- recording_timestamp : int , event_timestamp : int , event_data : dict [str , Any ]
91
+ recording_timestamp : float , event_timestamp : int , event_data : dict [str , Any ]
92
92
) -> None :
93
93
"""Insert a screenshot into the database.
94
94
95
95
Args:
96
- recording_timestamp (int ): The timestamp of the recording.
96
+ recording_timestamp (float ): The timestamp of the recording.
97
97
event_timestamp (int): The timestamp of the event.
98
98
event_data (dict): The data of the event.
99
99
"""
@@ -106,14 +106,14 @@ def insert_screenshot(
106
106
107
107
108
108
def insert_window_event (
109
- recording_timestamp : int ,
109
+ recording_timestamp : float ,
110
110
event_timestamp : int ,
111
111
event_data : dict [str , Any ],
112
112
) -> None :
113
113
"""Insert a window event into the database.
114
114
115
115
Args:
116
- recording_timestamp (int ): The timestamp of the recording.
116
+ recording_timestamp (float ): The timestamp of the recording.
117
117
event_timestamp (int): The timestamp of the event.
118
118
event_data (dict): The data of the event.
119
119
"""
@@ -126,15 +126,15 @@ def insert_window_event(
126
126
127
127
128
128
def insert_perf_stat (
129
- recording_timestamp : int ,
129
+ recording_timestamp : float ,
130
130
event_type : str ,
131
131
start_time : float ,
132
132
end_time : float ,
133
133
) -> None :
134
134
"""Insert an event performance stat into the database.
135
135
136
136
Args:
137
- recording_timestamp (int ): The timestamp of the recording.
137
+ recording_timestamp (float ): The timestamp of the recording.
138
138
event_type (str): The type of the event.
139
139
start_time (float): The start time of the event.
140
140
end_time (float): The end time of the event.
@@ -148,11 +148,11 @@ def insert_perf_stat(
148
148
_insert (event_perf_stat , PerformanceStat , performance_stats )
149
149
150
150
151
- def get_perf_stats (recording_timestamp : int ) -> list [PerformanceStat ]:
151
+ def get_perf_stats (recording_timestamp : float ) -> list [PerformanceStat ]:
152
152
"""Get performance stats for a given recording.
153
153
154
154
Args:
155
- recording_timestamp (int ): The timestamp of the recording.
155
+ recording_timestamp (float ): The timestamp of the recording.
156
156
157
157
Returns:
158
158
list[PerformanceStat]: A list of performance stats for the recording.
@@ -166,7 +166,7 @@ def get_perf_stats(recording_timestamp: int) -> list[PerformanceStat]:
166
166
167
167
168
168
def insert_memory_stat (
169
- recording_timestamp : int , memory_usage_bytes : int , timestamp : int
169
+ recording_timestamp : float , memory_usage_bytes : int , timestamp : int
170
170
) -> None :
171
171
"""Insert memory stat into db."""
172
172
memory_stat = {
@@ -177,7 +177,7 @@ def insert_memory_stat(
177
177
_insert (memory_stat , MemoryStat , memory_stats )
178
178
179
179
180
- def get_memory_stats (recording_timestamp : int ) -> None :
180
+ def get_memory_stats (recording_timestamp : float ) -> None :
181
181
"""Return memory stats for a given recording."""
182
182
return (
183
183
db .query (MemoryStat )
@@ -196,7 +196,7 @@ def insert_recording(recording_data: Recording) -> Recording:
196
196
return db_obj
197
197
198
198
199
- def delete_recording (recording_timestamp : int ) -> None :
199
+ def delete_recording (recording_timestamp : float ) -> None :
200
200
"""Remove the recording from the db."""
201
201
db .query (Recording ).filter (Recording .timestamp == recording_timestamp ).delete ()
202
202
db .commit ()
@@ -241,12 +241,12 @@ def get_recording(timestamp: int) -> Recording:
241
241
return db .query (Recording ).filter (Recording .timestamp == timestamp ).first ()
242
242
243
243
244
- def _get (table : BaseModel , recording_timestamp : int ) -> list [BaseModel ]:
244
+ def _get (table : BaseModel , recording_timestamp : float ) -> list [BaseModel ]:
245
245
"""Retrieve records from the database table based on the recording timestamp.
246
246
247
247
Args:
248
248
table (BaseModel): The database table to query.
249
- recording_timestamp (int ): The recording timestamp to filter the records.
249
+ recording_timestamp (float ): The recording timestamp to filter the records.
250
250
251
251
Returns:
252
252
list[BaseModel]: A list of records retrieved from the database table,
@@ -420,3 +420,33 @@ def new_session() -> None:
420
420
if db :
421
421
db .close ()
422
422
db = Session ()
423
+
424
+
425
+ def update_video_start_time (
426
+ recording_timestamp : float , video_start_time : float
427
+ ) -> None :
428
+ """Update the video start time of a specific recording.
429
+
430
+ Args:
431
+ recording_timestamp (float): The timestamp of the recording to update.
432
+ video_start_time (float): The new video start time to set.
433
+ """
434
+ # Find the recording by its timestamp
435
+ recording = (
436
+ db .query (Recording ).filter (Recording .timestamp == recording_timestamp ).first ()
437
+ )
438
+
439
+ if not recording :
440
+ logger .error (f"No recording found with timestamp { recording_timestamp } ." )
441
+ return
442
+
443
+ # Update the video start time
444
+ recording .video_start_time = video_start_time
445
+
446
+ # Commit the changes to the database
447
+ db .commit ()
448
+
449
+ logger .info (
450
+ f"Updated video start time for recording { recording_timestamp } to"
451
+ f" { video_start_time } ."
452
+ )
0 commit comments