浏览代码

[scrobbles] We don't have a user here yet

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

+ 7 - 4
vrobbler/apps/scrobbles/models.py

@@ -826,7 +826,7 @@ class Scrobble(TimeStampedModel):
             return scrobble
 
         if not location.has_moved(
-            self.past_scrobbled_locations(POINTS_FOR_MOVEMENT_HISTORY)
+            cls.past_scrobbled_locations(user_id, POINTS_FOR_MOVEMENT_HISTORY)
         ):
             logger.info(
                 f"[scrobbling] new location{location.id} and old location {scrobble.media_obj.id} are different, but close enough to not move"
@@ -849,10 +849,13 @@ class Scrobble(TimeStampedModel):
         )
         return cls.create(scrobble_data)
 
-    def past_scrobbled_locations(self, num: int) -> Iterable["Location"]:
-        past_scrobbles = Scrobble.objects.filter(
+    @classmethod
+    def past_scrobbled_locations(
+        cls, user_id: int, num: int
+    ) -> list["Location"]:
+        past_scrobbles = cls.objects.filter(
             media_type="GeoLocation",
-            user_id=self.user_id,
+            user_id=user_id,
         ).order_by("-timestamp")[1:num]
         return [s.geo_location for s in past_scrobbles]