From b0eb58953ba77589221212c165952d76b65eb127 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Mon, 17 Nov 2025 21:45:08 -0500 Subject: [PATCH] [food] Add calories if they're missing --- vrobbler/apps/scrobbles/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 43e6ee5..7263780 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -22,7 +22,7 @@ from django.db import models from django.urls import reverse from django.utils import timezone from django_extensions.db.models import TimeStampedModel -from foods.models import Food +from foods.models import Food, FoodLogData from imagekit.models import ImageSpecField from imagekit.processors import ResizeToFit from lifeevents.models import LifeEvent @@ -1210,6 +1210,9 @@ class Scrobble(TimeStampedModel): "source": source, }, ) + if mtype == cls.MediaType.FOOD and not scrobble_data.get("log", {}).get("calories", None): + if media.calories: + scrobble_data["log"] = FoodLogData(calories=media.calories) scrobble = cls.create(scrobble_data) return scrobble