浏览代码

Try to ignore duplicate geo scrobbles

Colin Powell 1 年之前
父节点
当前提交
1670a7cd7a
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      vrobbler/apps/scrobbles/models.py

+ 11 - 0
vrobbler/apps/scrobbles/models.py

@@ -674,6 +674,7 @@ class Scrobble(TimeStampedModel):
     ) -> "Scrobble":
     ) -> "Scrobble":
 
 
         media_class = media.__class__.__name__
         media_class = media.__class__.__name__
+        dup = None
 
 
         media_query = models.Q(track=media)
         media_query = models.Q(track=media)
         if media_class == "Track":
         if media_class == "Track":
@@ -699,6 +700,15 @@ class Scrobble(TimeStampedModel):
         if media_class == "GeoLocation":
         if media_class == "GeoLocation":
             media_query = models.Q(geo_location=media)
             media_query = models.Q(geo_location=media)
             scrobble_data["geo_location_id"] = media.id
             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 = (
         scrobble = (
             cls.objects.filter(
             cls.objects.filter(
@@ -709,6 +719,7 @@ class Scrobble(TimeStampedModel):
             .first()
             .first()
         )
         )
 
 
+
         if scrobble and scrobble.can_be_updated:
         if scrobble and scrobble.can_be_updated:
             source = scrobble_data["source"]
             source = scrobble_data["source"]
             mtype = media.__class__.__name__
             mtype = media.__class__.__name__