[scrobbling] Fix locations in proximity of named locations

This commit is contained in:
2024-03-12 18:28:59 -04:00
parent 874d9dc7d2
commit 79d4e79f3e

View File

@ -955,20 +955,24 @@ class Scrobble(TimeStampedModel):
)
return scrobble
scrobble.stop(force_finish=True)
if existing_locations := location.in_proximity(named=True):
existing_location = existing_locations.first()
scrobble.scrobble_log = (
scrobble.scrobble_log
+ "\nLocation {location.id} too close to this scrobble"
)
scrobble.save(update_fields=[scrobble_log])
logger.info(
f"[scrobbling] checking - found existing named location",
f"[scrobbling] finished - found existing named location",
extra={
"media_id": location.id,
"media_type": cls.MediaType.GEO_LOCATION,
"old_media_id": existing_location.id,
},
)
scrobble_data["geo_location"] = existing_location
return scrobble
scrobble.stop(force_finish=True)
scrobble = cls.create(scrobble_data)
logger.info(
f"[scrobbling] finished - created for location",