forked from mirrors/bookwyrm
Merge pull request #1811 from bookwyrm-social/cache-fix
Fixes active readthrough cache bug
This commit is contained in:
commit
e378e74901
1 changed files with 13 additions and 11 deletions
|
@ -132,18 +132,20 @@ def related_status(notification):
|
|||
def active_shelf(context, book):
|
||||
"""check what shelf a user has a book on, if any"""
|
||||
user = context["request"].user
|
||||
return cache.get_or_set(
|
||||
f"active_shelf-{user.id}-{book.id}",
|
||||
lambda u, b: (
|
||||
models.ShelfBook.objects.filter(
|
||||
shelf__user=u,
|
||||
book__parent_work__editions=b,
|
||||
).first()
|
||||
return (
|
||||
cache.get_or_set(
|
||||
f"active_shelf-{user.id}-{book.id}",
|
||||
lambda u, b: (
|
||||
models.ShelfBook.objects.filter(
|
||||
shelf__user=u,
|
||||
book__parent_work__editions=b,
|
||||
).first()
|
||||
),
|
||||
user,
|
||||
book,
|
||||
timeout=15552000,
|
||||
)
|
||||
or {"book": book},
|
||||
user,
|
||||
book,
|
||||
timeout=15552000,
|
||||
or {"book": book}
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue