Skip to content

Commit 35260fc

Browse files
committed
fix: Only show last 30d
1 parent cd42c41 commit 35260fc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/training/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from collections import defaultdict
2+
from datetime import timedelta
23

34
from django.db.models import Max, Q
45
from django.shortcuts import get_object_or_404
@@ -41,7 +42,8 @@ def get(self, request):
4142
"""
4243
Get list of all training sessions.
4344
"""
44-
sessions = TrainingSession.objects.select_related("instructor", "student")
45+
thirty_days_ago = timezone.now() - timedelta(days=30)
46+
sessions = TrainingSession.objects.filter(start__gte=thirty_days_ago).select_related("instructor", "student")
4547
serializer = TrainingSessionSerializer(sessions, many=True)
4648
return Response(serializer.data)
4749

0 commit comments

Comments
 (0)