Skip to content

Commit fff9b3d

Browse files
authored
Merge pull request #352 from aritra0342/main
fix: resolve AttributeError crash in ScreenshotCapture._get_statistic…
2 parents 1bdaee9 + d13818b commit fff9b3d

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

opencontext/context_capture/screenshot.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -481,27 +481,24 @@ def _get_statistics_impl(self) -> Dict[str, Any]:
481481
Returns:
482482
Dict[str, Any]: Statistics information
483483
"""
484-
active_contexts_info = {}
485-
for monitor_id, history in self._active_screenshots.items():
486-
active_contexts_info[monitor_id] = [
487-
{
488-
"uuid": ctx.uuid,
489-
"duration_count": ctx.metadata.get("duration_count"),
490-
"timestamp": ctx.metadata.get("timestamp"),
491-
}
492-
for img, ctx in history
493-
]
484+
last_screenshots_info = {}
485+
for monitor_id, (img, ctx) in self._last_screenshots.items():
486+
last_screenshots_info[monitor_id] = {
487+
"uuid": ctx.uuid,
488+
"duration_count": ctx.additional_info.get("duration_count"),
489+
"timestamp": ctx.additional_info.get("timestamp"),
490+
}
494491

495492
return {
496493
"screenshot_count": self._screenshot_count,
497-
"active_screenshots": active_contexts_info,
494+
"last_screenshots": last_screenshots_info,
498495
}
499496

500497
def _reset_statistics_impl(self) -> None:
501498
"""
502499
Reset statistics implementation
503500
"""
504501
self._screenshot_count = 0
505-
self._active_screenshots = {}
502+
self._last_screenshots.clear()
506503
self._last_screenshot_time = None
507504
self._last_screenshot_path = None

0 commit comments

Comments
 (0)