Преглед на файлове

Fix inversion of next and last for scrobbles

Colin Powell преди 1 година
родител
ревизия
e044c70072
променени са 1 файла, в които са добавени 12 реда и са изтрити 6 реда
  1. 12 6
      vrobbler/apps/scrobbles/models.py

+ 12 - 6
vrobbler/apps/scrobbles/models.py

@@ -576,51 +576,57 @@ class Scrobble(TimeStampedModel):
         return is_stale
 
     @property
-    def previous(self) -> "Scrobble":
+    def next(self) -> "Scrobble":
         return (
             self.media_obj.scrobble_set.order_by("-timestamp")
+            .exclude(id=self.id)
             .filter(timestamp__lt=self.timestamp)
             .first()
         )
 
     @property
-    def next(self) -> "Scrobble":
+    def previous(self) -> "Scrobble":
         return (
             self.media_obj.scrobble_set.order_by("timestamp")
+            .exclude(id=self.id)
             .filter(timestamp__gt=self.timestamp)
             .first()
         )
 
     @property
-    def previous_all(self) -> "Scrobble":
+    def next_all(self) -> "Scrobble":
         return (
             Scrobble.objects.filter(media_type=self.media_type)
+            .exclude(id=self.id)
             .order_by("-timestamp")
             .filter(timestamp__lt=self.timestamp)
             .first()
         )
 
     @property
-    def next_all(self) -> "Scrobble":
+    def previous_all(self) -> "Scrobble":
         return (
             Scrobble.objects.filter(media_type=self.media_type)
+            .exclude(id=self.id)
             .order_by("-timestamp")
             .filter(timestamp__gt=self.timestamp)
             .first()
         )
 
     @property
-    def previous_all_media(self) -> "Scrobble":
+    def next_all_media(self) -> "Scrobble":
         return (
             Scrobble.objects.order_by("-timestamp")
+            .exclude(id=self.id)
             .filter(timestamp__lt=self.timestamp)
             .first()
         )
 
     @property
-    def next_all_media(self) -> "Scrobble":
+    def previous_all_media(self) -> "Scrobble":
         return (
             Scrobble.objects.order_by("-timestamp")
+            .exclude(id=self.id)
             .filter(timestamp__gt=self.timestamp)
             .first()
         )