Farid Karimli
commited on
Commit
·
0a47b7e
1
Parent(s):
39406a1
bug fix
Browse files- apps/ai_tutor/helpers.py +7 -3
apps/ai_tutor/helpers.py
CHANGED
@@ -51,9 +51,13 @@ async def reset_tokens_for_user(user_info, TOKENS_LEFT, REGEN_TIME):
|
|
51 |
user_info = convert_to_dict(user_info)
|
52 |
last_message_time_str = user_info["metadata"].get("last_message_time")
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
57 |
current_time = datetime.fromisoformat(get_time()).replace(tzinfo=timezone.utc)
|
58 |
|
59 |
# Calculate the elapsed time since the last message
|
|
|
51 |
user_info = convert_to_dict(user_info)
|
52 |
last_message_time_str = user_info["metadata"].get("last_message_time")
|
53 |
|
54 |
+
try:
|
55 |
+
last_message_time = datetime.fromisoformat(last_message_time_str).replace(
|
56 |
+
tzinfo=timezone.utc
|
57 |
+
)
|
58 |
+
except Exception: # this probably means the user has never sent a message before
|
59 |
+
last_message_time = datetime.min.replace(tzinfo=timezone.utc)
|
60 |
+
|
61 |
current_time = datetime.fromisoformat(get_time()).replace(tzinfo=timezone.utc)
|
62 |
|
63 |
# Calculate the elapsed time since the last message
|