Prechádzať zdrojové kódy

[scrobbles] Fix calorie aggregation bug

Colin Powell 2 týždňov pred
rodič
commit
dff63f325f
1 zmenil súbory, kde vykonal 4 pridanie a 1 odobranie
  1. 4 1
      vrobbler/apps/scrobbles/utils.py

+ 4 - 1
vrobbler/apps/scrobbles/utils.py

@@ -394,7 +394,10 @@ def get_daily_calories_for_user_by_day(user_id: int, date: date| str) -> int:
     if isinstance(date, str):
         date = pendulum.parse(date)
 
-    qs = base_scrobble_qs(user_id).filter(day=date)
+    try:
+        qs = base_scrobble_qs(user_id).filter(day=date)
+    except AttibuteError as e:
+        logger.warning(f"Can't generate calorie total: {e}")
     agg = qs.aggregate(total_calories=models.Sum("calories_int"))
 
     return agg["total_calories"] or 0