From a960eee8f69387c10cbab615456857dd6393795d Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 6 Jan 2023 14:26:14 -0500 Subject: [PATCH] [#1] Limit now playing to the last 10 minutes --- vrobbler/apps/scrobbles/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index e05e023..b1d6abd 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -37,9 +37,13 @@ class RecentScrobbleList(ListView): def get_context_data(self, **kwargs): data = super().get_context_data(**kwargs) - last_five_minutes = timezone.now() - timedelta(minutes=5) + now = timezone.now() + last_ten_minutes = timezone.now() - timedelta(minutes=10) + # Find scrobbles from the last 10 minutes data['now_playing_list'] = Scrobble.objects.filter( - in_progress=True, modified__lte=last_five_minutes + in_progress=True, + timestamp__gte=last_ten_minutes, + timestamp__lte=now, ) return data