[scrobbles] Fix calorie aggregation bug

This commit is contained in:
2025-10-28 14:56:30 -04:00
parent 2b634e3b7e
commit dff63f325f

View File

@ -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