Spaces:
Sleeping
Sleeping
fix: correctly use LOG_FILE_PATH variable in all functions"
Browse files
logs.py
CHANGED
@@ -15,18 +15,14 @@ def save_log(user_id: int, history: dict, response: str):
|
|
15 |
f"Recomendação: {response.strip()}\n"
|
16 |
f"{'-'*40}\n"
|
17 |
)
|
18 |
-
with open(
|
19 |
f.write(log_entry)
|
20 |
|
21 |
|
22 |
def get_user_history(user_id: int) -> dict:
|
23 |
-
"""
|
24 |
-
Lê o arquivo recommender.log e retorna o último histórico do usuário.
|
25 |
-
"""
|
26 |
history = {}
|
27 |
-
|
28 |
try:
|
29 |
-
with open(
|
30 |
lines = f.readlines()
|
31 |
|
32 |
current_user = None
|
@@ -44,13 +40,9 @@ def get_user_history(user_id: int) -> dict:
|
|
44 |
|
45 |
|
46 |
def get_all_users() -> dict:
|
47 |
-
"""
|
48 |
-
Retorna todos os usuários e seus históricos a partir do arquivo de log.
|
49 |
-
"""
|
50 |
users = {}
|
51 |
-
|
52 |
try:
|
53 |
-
with open(
|
54 |
lines = f.readlines()
|
55 |
|
56 |
current_user = None
|
|
|
15 |
f"Recomendação: {response.strip()}\n"
|
16 |
f"{'-'*40}\n"
|
17 |
)
|
18 |
+
with open(LOG_FILE_PATH, "a", encoding="utf-8") as f:
|
19 |
f.write(log_entry)
|
20 |
|
21 |
|
22 |
def get_user_history(user_id: int) -> dict:
|
|
|
|
|
|
|
23 |
history = {}
|
|
|
24 |
try:
|
25 |
+
with open(LOG_FILE_PATH, "r", encoding="utf-8") as f:
|
26 |
lines = f.readlines()
|
27 |
|
28 |
current_user = None
|
|
|
40 |
|
41 |
|
42 |
def get_all_users() -> dict:
|
|
|
|
|
|
|
43 |
users = {}
|
|
|
44 |
try:
|
45 |
+
with open(LOG_FILE_PATH, "r", encoding="utf-8") as f:
|
46 |
lines = f.readlines()
|
47 |
|
48 |
current_user = None
|