Fix progress for books with no scrobbles
This commit is contained in:
@ -160,7 +160,10 @@ class Book(LongPlayScrobblableMixin):
|
|||||||
"""Used to keep track of whether the book is complete or not"""
|
"""Used to keep track of whether the book is complete or not"""
|
||||||
user = User.objects.get(id=user_id)
|
user = User.objects.get(id=user_id)
|
||||||
last_scrobble = get_scrobbles_for_media(self, user).last()
|
last_scrobble = get_scrobbles_for_media(self, user).last()
|
||||||
return int((last_scrobble.book_pages_read / self.pages) * 100)
|
progress = 0
|
||||||
|
if last_scrobble:
|
||||||
|
progress = int((last_scrobble.book_pages_read / self.pages) * 100)
|
||||||
|
return progress
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def find_or_create(cls, data_dict: dict) -> "Game":
|
def find_or_create(cls, data_dict: dict) -> "Game":
|
||||||
|
|||||||
@ -72,10 +72,6 @@ def lookup_book_from_openlibrary(title: str, author: str = None) -> dict:
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
top = results.get("docs")[0]
|
top = results.get("docs")[0]
|
||||||
if author and author not in top["author_name"]:
|
|
||||||
logger.warn(
|
|
||||||
f"Lookup for {title} found top result with mismatched author"
|
|
||||||
)
|
|
||||||
ol_id = top.get("cover_edition_key")
|
ol_id = top.get("cover_edition_key")
|
||||||
ol_author_id = get_first("author_key", top)
|
ol_author_id = get_first("author_key", top)
|
||||||
first_sentence = ""
|
first_sentence = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user