浏览代码

[scrobbles] Add lookup of last serial scrobble

Colin Powell 6 月之前
父节点
当前提交
0f0fb7cceb
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      vrobbler/apps/scrobbles/models.py

+ 6 - 0
vrobbler/apps/scrobbles/models.py

@@ -571,6 +571,12 @@ class Scrobble(TimeStampedModel):
     long_play_seconds = models.BigIntegerField(**BNULL)
     long_play_seconds = models.BigIntegerField(**BNULL)
     long_play_complete = models.BooleanField(**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):
     def save(self, *args, **kwargs):
         if not self.uuid:
         if not self.uuid:
             self.uuid = uuid4()
             self.uuid = uuid4()