if changes
This commit is contained in:
parent
8f474a1081
commit
8d4bcfdf0c
|
|
@ -125,22 +125,7 @@ def list_patchnotes(since: str | None = None):
|
||||||
|
|
||||||
user_id = current_user_id() # 1) aktueller Benutzer
|
user_id = current_user_id() # 1) aktueller Benutzer
|
||||||
last_login = last_login_collection.find_one({"user_id": user_id}, {"last_login"})
|
last_login = last_login_collection.find_one({"user_id": user_id}, {"last_login"})
|
||||||
if since is None:
|
if since:
|
||||||
try:
|
|
||||||
docs = collection.find({})
|
|
||||||
for d in docs:
|
|
||||||
d.pop("_id", None)
|
|
||||||
if isinstance(d["patch_date"], (datetime, date)):
|
|
||||||
d["patch_date"] = d["patch_date"].isoformat()
|
|
||||||
except ValueError as e:
|
|
||||||
raise ProblemException(
|
|
||||||
title="Internal Server Error",
|
|
||||||
detail=str(e),
|
|
||||||
status=500,
|
|
||||||
)
|
|
||||||
|
|
||||||
# 3) Datum validieren (nur wenn vorhanden)
|
|
||||||
elif since:
|
|
||||||
query = {
|
query = {
|
||||||
"patch_date": {
|
"patch_date": {
|
||||||
"$gte": last_login,
|
"$gte": last_login,
|
||||||
|
|
@ -155,6 +140,22 @@ def list_patchnotes(since: str | None = None):
|
||||||
detail="since must be YYYY-MM-DD",
|
detail="since must be YYYY-MM-DD",
|
||||||
status=400,
|
status=400,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# 3) Datum validieren (nur wenn vorhanden)
|
||||||
|
elif since is None:
|
||||||
|
try:
|
||||||
|
docs = collection.find({})
|
||||||
|
for d in docs:
|
||||||
|
d.pop("_id", None)
|
||||||
|
if isinstance(d["patch_date"], (datetime, date)):
|
||||||
|
d["patch_date"] = d["patch_date"].isoformat()
|
||||||
|
except ValueError as e:
|
||||||
|
raise ProblemException(
|
||||||
|
title="Internal Server Error",
|
||||||
|
detail=str(e),
|
||||||
|
status=500,
|
||||||
|
)
|
||||||
# 4) Patchnotes abholen
|
# 4) Patchnotes abholen
|
||||||
|
|
||||||
docs = list(collection.find(query).sort("patch_date", 1))
|
docs = list(collection.find(query).sort("patch_date", 1))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue