[locations] Refactor has moved to not use multiple points

This commit is contained in:
2024-03-12 16:57:56 -04:00
parent 0fff2ec388
commit df1bfd4177
3 changed files with 28 additions and 59 deletions

View File

@ -932,10 +932,7 @@ class Scrobble(TimeStampedModel):
)
return scrobble
jitter_correction_locations = cls.past_scrobbled_locations(
user_id, POINTS_FOR_MOVEMENT_HISTORY
)
has_moved = location.has_moved(jitter_correction_locations)
has_moved = location.has_moved(scrobble.user.id)
logger.info(
f"[scrobbling] checking - has last location has moved?",
extra={
@ -944,7 +941,6 @@ class Scrobble(TimeStampedModel):
"media_type": cls.MediaType.GEO_LOCATION,
"media_id": location.id,
"has_moved": has_moved,
"past_locations_used": jitter_correction_locations,
},
)
if not has_moved:
@ -986,16 +982,6 @@ class Scrobble(TimeStampedModel):
)
return scrobble
@classmethod
def past_scrobbled_locations(
cls, user_id: int, num: int
) -> list["Location"]:
past_scrobbles = cls.objects.filter(
media_type="GeoLocation",
user_id=user_id,
).order_by("-timestamp")[1:num]
return [s.geo_location for s in past_scrobbles]
def update(self, scrobble_data: dict) -> "Scrobble":
# Status is a field we get from Mopidy, which refuses to poll us
scrobble_status = scrobble_data.pop("mopidy_status", None)