feat: add recap page

This commit is contained in:
2026-07-17 17:19:26 +02:00
parent 0cfe4c7108
commit 63a5a69c67
6 changed files with 281 additions and 58 deletions
+23 -9
View File
@@ -9,7 +9,7 @@ from django.urls import reverse
from django.utils import timezone
from django.utils.dateparse import parse_date
from tracker.api import build_day, pulse_trend
from tracker.api import build_day, build_recap, pulse_trend
from tracker.models import DailyNote, DoseLog, GlobalNote, PulseReading, ScheduledDose
CHART_WIDTH = 320
@@ -103,12 +103,6 @@ def today(request):
messages.success(request, f"Saved for {day:%A %d %B}.")
return redirect(f"{reverse('tracker:today')}?date={day.isoformat()}")
readings = list(
PulseReading.objects.filter(
date__gte=timezone.localdate() - timedelta(days=90)
).order_by("date")
)
return render(
request,
"tracker/today.html",
@@ -118,8 +112,6 @@ def today(request):
"is_today": day == timezone.localdate(),
"previous_date": day - timedelta(days=1),
"next_date": day + timedelta(days=1),
"chart": build_chart(readings),
"reading_count": len(readings),
"global_note": GlobalNote.load(),
# Empty when push is not configured; the card then says so rather than
# vanishing, because a missing card looks like a bug in the page.
@@ -132,3 +124,25 @@ def today(request):
"subscribed_devices": request.user.push_subscriptions.count(),
},
)
@staff_member_required
def recap(request):
"""The overview: dose completeness per day, the pulse graph, and the journal."""
readings = list(
PulseReading.objects.filter(
date__gte=timezone.localdate() - timedelta(days=90)
).order_by("date")
)
return render(
request,
"tracker/recap.html",
{
"title": "Recap",
"recap_days": build_recap(14),
"chart": build_chart(readings),
"reading_count": len(readings),
"daily_notes": DailyNote.objects.all(),
},
)