Skip to content

Commit

Permalink
pep8 and fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
mekarpeles authored Jun 7, 2022
1 parent 477d86f commit 0267ca4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion openlibrary/core/bookshelves.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def most_logged_books(cls, shelf_id=None, limit=10, since=False, page=1):
users. This query is limited to a specific shelf_id (e.g. 1
for "Want to Read").
"""
offset=(page-1)*limit
offset = (page - 1) * limit
oldb = db.get_db()
where = 'WHERE bookshelf_id' + ('=$shelf_id' if shelf_id else ' IS NOT NULL ')
if since:
Expand Down
15 changes: 5 additions & 10 deletions openlibrary/plugins/openlibrary/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
(long term support)
"""

from openlibrary.views.loanstats import get_logged_books_carousel
import web
import re
import json
Expand Down Expand Up @@ -72,12 +71,8 @@ def GET(self):
trending=False
)
if i.trending:
works = get_logged_books_carousel(limit = int(i.limit), page = int(i.page))
works = get_logged_books_carousel(limit=int(i.limit), page=int(i.page))
url=""
result = {
'query': url,
'works': [dict(work) for work in works],
}
else:
sorts = i.sorts.split(',')
page = int(i.page)
Expand All @@ -92,10 +87,10 @@ def GET(self):
sorts=sorts,
)
works = lending.get_available(url=url) if url else []
result = {
'query': url,
'works': [work.dict() for work in works],
}
result = {
'query': url,
'works': [work.dict() for work in works],
}
return delegate.RawText(json.dumps(result), content_type="application/json")


Expand Down
3 changes: 1 addition & 2 deletions openlibrary/views/loanstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def cached_get_most_logged_books(shelf_id=None, since_days=1, limit=20):

@public
def get_logged_books_carousel(since_days=1, limit=18 ,page=1):
books = get_most_logged_books(since_days = since_days, limit = limit, page = page)
books = get_most_logged_books(since_days=since_days, limit=limit, page=page)
work_index = get_solr_works(f"/works/OL{book['work_id']}W" for book in books)
availability_index = get_availabilities(work_index.values())
for work_key in availability_index:
Expand All @@ -52,7 +52,6 @@ def get_logged_books_carousel(since_days=1, limit=18 ,page=1):
if key in work_index:
tab.append(work_index[key])
return tab
@public
def get_most_logged_books(shelf_id=None, since_days=1, limit=20 ,page=1):
"""
shelf_id: Bookshelves.PRESET_BOOKSHELVES['Want to Read'|'Already Read'|'Currently Reading']
Expand Down

0 comments on commit 0267ca4

Please sign in to comment.