LogicGoInfotechSpaces commited on
Commit
f2ba5b8
·
verified ·
1 Parent(s): 970adae

Update api/main.py

Browse files
Files changed (1) hide show
  1. api/main.py +15 -1
api/main.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import uuid
3
  import shutil
@@ -193,6 +194,14 @@ def _build_ai_edit_daily_count(
193
  }
194
  )
195
 
 
 
 
 
 
 
 
 
196
  # Enforce 32-entry limit (keep the most recent 32 days)
197
  if len(result) > 32:
198
  result = result[-32:]
@@ -943,7 +952,6 @@ def get_logs(_: None = Depends(bearer_auth)) -> JSONResponse:
943
  return JSONResponse(content=logs)
944
 
945
 
946
-
947
  # import os
948
  # import uuid
949
  # import shutil
@@ -1068,6 +1076,8 @@ def get_logs(_: None = Depends(bearer_auth)) -> JSONResponse:
1068
  # - Case B (today already recorded): return list unchanged
1069
  # - Case C (gap in days): fill missing days with count=0 and append today with count=1
1070
 
 
 
1071
  # The stored "date" value is a midnight UTC (naive UTC) datetime for the given day.
1072
  # """
1073
 
@@ -1137,6 +1147,10 @@ def get_logs(_: None = Depends(bearer_auth)) -> JSONResponse:
1137
  # }
1138
  # )
1139
 
 
 
 
 
1140
  # return result
1141
 
1142
  # def bearer_auth(authorization: Optional[str] = Header(default=None)) -> None:
 
1
+
2
  import os
3
  import uuid
4
  import shutil
 
194
  }
195
  )
196
 
197
+ # Sort by date ascending (older dates first) to guarantee stable ordering:
198
+ # [oldest, ..., newest]
199
+ try:
200
+ result.sort(key=lambda entry: _to_date_only(entry.get("date")))
201
+ except Exception:
202
+ # If anything goes wrong during sort, fall back to current ordering
203
+ pass
204
+
205
  # Enforce 32-entry limit (keep the most recent 32 days)
206
  if len(result) > 32:
207
  result = result[-32:]
 
952
  return JSONResponse(content=logs)
953
 
954
 
 
955
  # import os
956
  # import uuid
957
  # import shutil
 
1076
  # - Case B (today already recorded): return list unchanged
1077
  # - Case C (gap in days): fill missing days with count=0 and append today with count=1
1078
 
1079
+ # Additionally, the returned list is capped to the most recent 32 entries.
1080
+
1081
  # The stored "date" value is a midnight UTC (naive UTC) datetime for the given day.
1082
  # """
1083
 
 
1147
  # }
1148
  # )
1149
 
1150
+ # # Enforce 32-entry limit (keep the most recent 32 days)
1151
+ # if len(result) > 32:
1152
+ # result = result[-32:]
1153
+
1154
  # return result
1155
 
1156
  # def bearer_auth(authorization: Optional[str] = Header(default=None)) -> None: