Spaces:
Sleeping
Sleeping
Commit
·
357cf4e
1
Parent(s):
4ca0f84
update storage add log debug
Browse files- app/services/storage.py +14 -1
app/services/storage.py
CHANGED
|
@@ -3,6 +3,8 @@ from app.services.firebase import db
|
|
| 3 |
|
| 4 |
COLLECTION = "notes"
|
| 5 |
|
|
|
|
|
|
|
| 6 |
def create_note(note_id: str, payload: dict):
|
| 7 |
now = datetime.utcnow()
|
| 8 |
payload.update({
|
|
@@ -10,7 +12,16 @@ def create_note(note_id: str, payload: dict):
|
|
| 10 |
"created_at": now,
|
| 11 |
"updated_at": now
|
| 12 |
})
|
|
|
|
| 13 |
db.collection(COLLECTION).document(note_id).set(payload)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def update_note(note_id: str, data: dict = None, status: str = None):
|
| 16 |
updates = {"updated_at": datetime.utcnow()}
|
|
@@ -22,5 +33,7 @@ def update_note(note_id: str, data: dict = None, status: str = None):
|
|
| 22 |
db.collection(COLLECTION).document(note_id).update(updates)
|
| 23 |
|
| 24 |
def get_note(note_id: str):
|
|
|
|
| 25 |
doc = db.collection(COLLECTION).document(note_id).get()
|
| 26 |
-
|
|
|
|
|
|
| 3 |
|
| 4 |
COLLECTION = "notes"
|
| 5 |
|
| 6 |
+
import logging
|
| 7 |
+
|
| 8 |
def create_note(note_id: str, payload: dict):
|
| 9 |
now = datetime.utcnow()
|
| 10 |
payload.update({
|
|
|
|
| 12 |
"created_at": now,
|
| 13 |
"updated_at": now
|
| 14 |
})
|
| 15 |
+
logging.info(f"[NoteService] create_note: id={note_id}, keys={list(payload.keys())}")
|
| 16 |
db.collection(COLLECTION).document(note_id).set(payload)
|
| 17 |
+
logging.info(f"[NoteService] create_note: saved id={note_id}")
|
| 18 |
+
|
| 19 |
+
def get_note(note_id: str):
|
| 20 |
+
logging.info(f"[NoteService] get_note: id={note_id}")
|
| 21 |
+
doc = db.collection(COLLECTION).document(note_id).get()
|
| 22 |
+
logging.info(f"[NoteService] get_note: exists={doc.exists}")
|
| 23 |
+
return doc.to_dict() if doc.exists else None
|
| 24 |
+
|
| 25 |
|
| 26 |
def update_note(note_id: str, data: dict = None, status: str = None):
|
| 27 |
updates = {"updated_at": datetime.utcnow()}
|
|
|
|
| 33 |
db.collection(COLLECTION).document(note_id).update(updates)
|
| 34 |
|
| 35 |
def get_note(note_id: str):
|
| 36 |
+
logging.info(f"[NoteService] get_note: id={note_id}")
|
| 37 |
doc = db.collection(COLLECTION).document(note_id).get()
|
| 38 |
+
logging.info(f"[NoteService] get_note: exists={doc.exists}")
|
| 39 |
+
return doc.to_dict() if doc.exists else None
|