diff --git a/openlibrary/plugins/upstream/mybooks.py b/openlibrary/plugins/upstream/mybooks.py index bf4f775f5148..ee0fac5451a6 100644 --- a/openlibrary/plugins/upstream/mybooks.py +++ b/openlibrary/plugins/upstream/mybooks.py @@ -296,7 +296,9 @@ def render( elif is_logged_in_user and self.key == "loan_history": account = OpenLibraryAccount.get(username=logged_in_username) s3_keys = web.ctx.site.store.get(account._key).get('s3_keys') - template_data = self.process_loan_history_data(page=page, s3_keys=s3_keys) + template_data = self.process_loan_history_data( + page=page, s3_keys=s3_keys + ) return render['account/books']( docs=template_data.get('editions', []), @@ -312,7 +314,7 @@ def render( q=q, results_per_page=template_data['limit'], show_next=template_data['show_next'], - page=template_data.get('page', '') + page=template_data.get('page', ''), ) else: @@ -366,8 +368,7 @@ def process_loan_history_data(self, page: int, s3_keys: dict[str, str]): ocaids = [loan_record['identifier'] for loan_record in loan_history] availability = get_availability_of_ocaids(ocaids) loan_history_map = { - loan_record['identifier']: loan_record - for loan_record in loan_history + loan_record['identifier']: loan_record for loan_record in loan_history } editions = web.ctx.site.get_many( [ @@ -379,7 +380,7 @@ def process_loan_history_data(self, page: int, s3_keys: dict[str, str]): # Handle case where no loaned books on this page are in OL and there are more pages. if not editions and show_next: - return self.process_loan_history_data(page=page+1, s3_keys=s3_keys) + return self.process_loan_history_data(page=page + 1, s3_keys=s3_keys) for i, ed in enumerate(editions): if ed.ocaid in ocaids: @@ -387,7 +388,6 @@ def process_loan_history_data(self, page: int, s3_keys: dict[str, str]): editions[i].availability = availability.get(ed.ocaid) editions[i].loan = loan_history_map[ed.ocaid] - template_data = { 'editions': editions, 'doc_count': len(loan_history_map), @@ -398,7 +398,6 @@ def process_loan_history_data(self, page: int, s3_keys: dict[str, str]): return template_data - def _prepare_data( self, logged_in_user,