From 1670a7cd7a68e5131945058bca1b5c2cd376cccf Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sun, 26 Nov 2023 21:20:49 +0100 Subject: [PATCH] Try to ignore duplicate geo scrobbles --- vrobbler/apps/scrobbles/models.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 634f0a2..a5d53e4 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -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__