[locations] Don't scrobble all the locations!

This commit is contained in:
2024-02-12 11:59:15 -05:00
parent a637a59a40
commit 2c08336e33

View File

@ -802,6 +802,7 @@ class Scrobble(TimeStampedModel):
def user_has_moved_locations( def user_has_moved_locations(
cls, location: GeoLocation, user_id: int cls, location: GeoLocation, user_id: int
) -> bool: ) -> bool:
moved_location = False
scrobble = ( scrobble = (
cls.objects.filter( cls.objects.filter(
media_type=cls.MediaType.GEO_LOCATION, user_id=user_id media_type=cls.MediaType.GEO_LOCATION, user_id=user_id
@ -809,8 +810,20 @@ class Scrobble(TimeStampedModel):
.order_by("-timestamp") .order_by("-timestamp")
.first() .first()
) )
if not scrobble:
logger.info(
f"[scrobbling] No existing location scrobbles, {location} should be created"
)
moved_location = True moved_location = True
if scrobble and scrobble.media_obj != location:
else:
if scrobble.media_obj == location:
logger.info(
f"[scrobbling] New location {location} and last location {scrobble.media_obj} are the same"
)
moved_location = False
if scrobble.media_obj != location:
logger.info( logger.info(
f"[scrobbling] New location {location} and last location {scrobble.media_obj} are different" f"[scrobbling] New location {location} and last location {scrobble.media_obj} are different"
) )