From df3424c68fa8f893432267169c6a7bec90c2950d Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sun, 18 Feb 2024 01:39:40 -0500 Subject: [PATCH] [scrobbles] We don't have a user here yet --- vrobbler/apps/scrobbles/models.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 59068c1..e0070ce 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/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]