if changes

This commit is contained in:
Justin Weins 2025-06-26 09:40:51 +02:00
parent be28592dfa
commit 8f474a1081
1 changed files with 4 additions and 8 deletions

View File

@ -123,8 +123,8 @@ def get_patchnote(patch_id): # noqa: E501
def list_patchnotes(since: str | None = None):
"""GET /patchnotes liefert neue Patchnotes und setzt last_login."""
user_id = current_user_id() # 1) aktueller Benutzer
last_login = last_login_collection.find_one({"user_id": user_id},{"last_login"})
user_id = current_user_id() # 1) aktueller Benutzer
last_login = last_login_collection.find_one({"user_id": user_id}, {"last_login"})
if since is None:
try:
docs = collection.find({})
@ -140,7 +140,7 @@ def list_patchnotes(since: str | None = None):
)
# 3) Datum validieren (nur wenn vorhanden)
if since:
elif since:
query = {
"patch_date": {
"$gte": last_login,
@ -155,10 +155,8 @@ def list_patchnotes(since: str | None = None):
detail="since must be YYYY-MM-DD",
status=400,
)
else:
query = {} # erster Login → alle Notes
# 4) Patchnotes abholen
docs = list(collection.find(query).sort("patch_date", 1))
for d in docs:
d.pop("_id", None)
@ -235,5 +233,3 @@ def update_patchnote(patch_id, body): # noqa: E501
mimetype="application/json",
status=200,
)