Try to ignore duplicate geo scrobbles

This commit is contained in:
2023-11-26 21:20:49 +01:00
parent 0505d01b71
commit 1670a7cd7a

View File

@ -674,6 +674,7 @@ class Scrobble(TimeStampedModel):
) -> "Scrobble":
media_class = media.__class__.__name__
dup = None
media_query = models.Q(track=media)
if media_class == "Track":
@ -699,6 +700,15 @@ class Scrobble(TimeStampedModel):
if media_class == "GeoLocation":
media_query = models.Q(geo_location=media)
scrobble_data["geo_location_id"] = media.id
dup = cls.objects.filter(
media_type=cls.MEDIA_TYPE.GeoLocation,
timestamp = scrobble_data.get("timestamp"),
).first()
if dup:
logger.info("[scrobbling] scrobble with identical timestamp found")
return
scrobble = (
cls.objects.filter(
@ -709,6 +719,7 @@ class Scrobble(TimeStampedModel):
.first()
)
if scrobble and scrobble.can_be_updated:
source = scrobble_data["source"]
mtype = media.__class__.__name__