diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 2dc8b3e..656cf0a 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -451,11 +451,20 @@ class Scrobble(TimeStampedModel): @property def previous(self): return ( - self.media_obj.scrobble_set.filter(timestamp__lt=self.timestamp) - .order_by("-timestamp") - .last() + self.media_obj.scrobble_set.order_by("-timestamp") + .filter(timestamp__lt=self.timestamp) + .first() ) + @property + def session_pages_read(self) -> Optional[int]: + """Look one scrobble back, if it isn't complete,""" + if not self.book_pages_read: + return + if self.previous: + return self.book_pages_read - self.previous.book_pages_read + return self.book_pages_read + @property def percent_played(self) -> int: if not self.media_obj: diff --git a/vrobbler/templates/books/book_detail.html b/vrobbler/templates/books/book_detail.html index 91993bd..095a0ce 100644 --- a/vrobbler/templates/books/book_detail.html +++ b/vrobbler/templates/books/book_detail.html @@ -27,7 +27,7 @@
{{object.scrobble_set.count}} scrobbles
-{{object.scrobble_set.last.book_pages_read}} page read to {% if object.scrobble_set.last.long_play_complete %} and completed{% else %}{% endif %}
+Read {{object.scrobble_set.last.book_pages_read}} pages{% if object.scrobble_set.last.long_play_complete %} and completed{% else %}{% endif %}
{% if object.scrobble_set.last.long_play_complete == True %} Read again @@ -45,7 +45,7 @@