[scrobbles] Add lookup of last serial scrobble

This commit is contained in:
2024-10-20 14:33:38 -04:00
parent f2bbb7f5d0
commit 0f0fb7cceb

View File

@ -571,6 +571,12 @@ class Scrobble(TimeStampedModel):
long_play_seconds = models.BigIntegerField(**BNULL)
long_play_complete = models.BooleanField(**BNULL)
@property
def last_serial_scrobble(self) -> Optional["Scrobble"]:
from scrobbles.models import Scrobble
if self.logdata and self.logdata.serial_scrobble_id:
return Scrobble.objects.filter(id=self.logdata.serial_scrobble_id).first()
def save(self, *args, **kwargs):
if not self.uuid:
self.uuid = uuid4()