Merge pull request #1067 from bookwyrm-social/goal-year

Don't show following years' books in a year's goal
This commit is contained in:
Mouse Reeve 2021-05-10 15:02:18 -07:00 committed by GitHub
commit 5efc7280a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -372,7 +372,10 @@ class AnnualGoal(BookWyrmModel):
def books(self):
"""the books you've read this year"""
return (
self.user.readthrough_set.filter(finish_date__year__gte=self.year)
self.user.readthrough_set.filter(
finish_date__year__gte=self.year,
finish_date__year__lt=self.year + 1,
)
.order_by("-finish_date")
.all()
)
@ -396,7 +399,8 @@ class AnnualGoal(BookWyrmModel):
def book_count(self):
"""how many books you've read this year"""
return self.user.readthrough_set.filter(
finish_date__year__gte=self.year
finish_date__year__gte=self.year,
finish_date__year__lt=self.year + 1,
).count()