From 0f0fb7cceb33de2a56c3a42973f2d9399ba68725 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sun, 20 Oct 2024 14:33:38 -0400 Subject: [PATCH] [scrobbles] Add lookup of last serial scrobble --- vrobbler/apps/scrobbles/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index cafd361..86eb8b3 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -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()