Spaces:
Runtime error
Runtime error
Update logger.py
Browse files
logger.py
CHANGED
@@ -1,19 +1,22 @@
|
|
|
|
1 |
import firebase_admin
|
2 |
from firebase_admin import credentials, firestore
|
|
|
3 |
|
4 |
-
#
|
5 |
if not firebase_admin._apps:
|
6 |
cred = credentials.Certificate("firebase_key.json")
|
7 |
firebase_admin.initialize_app(cred)
|
8 |
|
9 |
db = firestore.client()
|
10 |
|
11 |
-
def
|
12 |
-
|
13 |
-
|
14 |
-
"
|
15 |
"solution_1": sol1,
|
16 |
"solution_2": sol2,
|
17 |
"winner": winner
|
18 |
-
}
|
19 |
-
|
|
|
|
1 |
+
import json
|
2 |
import firebase_admin
|
3 |
from firebase_admin import credentials, firestore
|
4 |
+
from datetime import datetime
|
5 |
|
6 |
+
# Initialize Firebase app once
|
7 |
if not firebase_admin._apps:
|
8 |
cred = credentials.Certificate("firebase_key.json")
|
9 |
firebase_admin.initialize_app(cred)
|
10 |
|
11 |
db = firestore.client()
|
12 |
|
13 |
+
def log_user_feedback(goal, sol1, sol2, winner):
|
14 |
+
doc = {
|
15 |
+
"timestamp": datetime.utcnow().isoformat(),
|
16 |
+
"goal": goal,
|
17 |
"solution_1": sol1,
|
18 |
"solution_2": sol2,
|
19 |
"winner": winner
|
20 |
+
}
|
21 |
+
db.collection("feedback_logs").add(doc)
|
22 |
+
print(f"π₯ Logged feedback: {winner}")
|