diff --git a/bookwyrm/templates/feed/feed.html b/bookwyrm/templates/feed/feed.html
index 010ba0f9..f25ec869 100644
--- a/bookwyrm/templates/feed/feed.html
+++ b/bookwyrm/templates/feed/feed.html
@@ -64,14 +64,20 @@
{{ allowed_status_types|json_script:"unread-notifications-wrapper" }}
-{% if request.user.show_goal and not goal and tab.key == 'home' %}
-{% now 'Y' as year %}
-
-
+
+
+{% blocktrans %}The end of the year is the best moment to take stock of all the books read during the last 12 months. How many pages have you read? Which book is your best-rated of the year? We compiled these stats, and more!{% endblocktrans %} +
+ ++ + {% blocktrans %}Discover your stats for {{ year }}!{% endblocktrans %} + +
+{% endblock %} diff --git a/bookwyrm/views/annual_summary.py b/bookwyrm/views/annual_summary.py index 05221de1..4bd2e697 100644 --- a/bookwyrm/views/annual_summary.py +++ b/bookwyrm/views/annual_summary.py @@ -11,6 +11,21 @@ from bookwyrm import models # December day of first availability FIRST_DAY = 15 +# January day of last availability, 0 for no availability in Jan. +LAST_DAY = 15 + + +def get_annual_summary_year(): + """return the latest available annual summary year or None""" + + today = date.today() + if today >= date(today.year, 12, FIRST_DAY) and today <= date(today.year, 12, 31): + return today.year + + if LAST_DAY > 0 and today >= date(today.year, 1, 1) and today <= date(today.year, 1, LAST_DAY): + return today.year - 1 + + return None def is_year_available(year): diff --git a/bookwyrm/views/feed.py b/bookwyrm/views/feed.py index ba6c3af5..d2350088 100644 --- a/bookwyrm/views/feed.py +++ b/bookwyrm/views/feed.py @@ -16,6 +16,7 @@ from bookwyrm.settings import PAGE_LENGTH, STREAMS from bookwyrm.suggested_users import suggested_users from .helpers import filter_stream_by_status_type, get_user_from_username from .helpers import is_api_request, is_bookwyrm_request +from .annual_summary import get_annual_summary_year # pylint: disable= no-self-use @@ -62,6 +63,7 @@ class Feed(View): "allowed_status_types": request.user.feed_status_types, "settings_saved": settings_saved, "path": f"/{tab['key']}", + "annual_summary_year": get_annual_summary_year(), }, } return TemplateResponse(request, "feed/feed.html", data)