Open source video conferencing app powered by LiveKit. Built with Django and React.
🐛(summary) fix data type serialization issues with Redis and PostHog
lebaudantoinee4582727455b
diff --git a/src/summary/summary/core/analytics.py b/src/summary/summary/core/analytics.pyindex 212f2add..e945e8cc 100644--- a/src/summary/summary/core/analytics.py+++ b/src/summary/summary/core/analytics.py@@ -73,10 +73,22 @@ class TasksTracker:"""Save metadata for a specific task to Redis."""self._redis.hset(self._get_redis_key(task_id), mapping=metadata)++ @staticmethod+ def _convert_value(value):+ """Convert a string value to the most appropriate Python type."""+ try:+ return int(value)+ except ValueError:+ try:+ return float(value)+ except ValueError:+ return value+def _get_metadata(self, task_id):"""Retrieve and parse metadata for a specific task from Redis."""raw_metadata = self._redis.hgetall(self._get_redis_key(task_id))- return {k.decode("utf-8"): v.decode("utf-8") for k, v in raw_metadata.items()}+ return {k.decode("utf-8"): self._convert_value(v.decode("utf-8")) for k, v in raw_metadata.items()}def has_task_id(self, task_id):"""Check if task_id exists in tasks metadata cache."""@@ -182,9 +194,9 @@ class TasksTracker:metadata = self._get_metadata(task_id)if "start_time" in metadata:- metadata["execution_time"] = str(round(- time.time() - float(metadata["start_time"]), 2- ))+ metadata["execution_time"] = round(+ time.time() - metadata["start_time"], 2+ )del metadata["start_time"]metadata["task_id"] = task_id