From 8d4bcfdf0c2f64ef0acc319fb15ee6004692a773 Mon Sep 17 00:00:00 2001 From: justinbaer Date: Thu, 26 Jun 2025 09:46:35 +0200 Subject: [PATCH] if changes --- .../controllers/patchnotes_controller.py | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/gen/openapi_server/controllers/patchnotes_controller.py b/gen/openapi_server/controllers/patchnotes_controller.py index ab812cc..411f9d8 100644 --- a/gen/openapi_server/controllers/patchnotes_controller.py +++ b/gen/openapi_server/controllers/patchnotes_controller.py @@ -125,22 +125,7 @@ def list_patchnotes(since: str | None = None): 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({}) - 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: + if since: query = { "patch_date": { "$gte": last_login, @@ -155,6 +140,22 @@ def list_patchnotes(since: str | None = None): detail="since must be YYYY-MM-DD", 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 docs = list(collection.find(query).sort("patch_date", 1))