[food] Add calories if they're missing
This commit is contained in:
@ -22,7 +22,7 @@ from django.db import models
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django_extensions.db.models import TimeStampedModel
|
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.models import ImageSpecField
|
||||||
from imagekit.processors import ResizeToFit
|
from imagekit.processors import ResizeToFit
|
||||||
from lifeevents.models import LifeEvent
|
from lifeevents.models import LifeEvent
|
||||||
@ -1210,6 +1210,9 @@ class Scrobble(TimeStampedModel):
|
|||||||
"source": source,
|
"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)
|
scrobble = cls.create(scrobble_data)
|
||||||
return scrobble
|
return scrobble
|
||||||
|
|||||||
Reference in New Issue
Block a user