Update homepage event display algorithm.
authorJonathan S. Katz <jonathan.katz@excoventures.com>
Fri, 18 May 2018 17:16:09 +0000 (13:16 -0400)
committerJonathan S. Katz <jonathan.katz@excoventures.com>
Fri, 18 May 2018 17:16:09 +0000 (13:16 -0400)
The event display algorithm shows up to two non-badged events
that take place over the next three months.  Subsequently, up to
seven minus |non-badged events| are returned.

pgweb/core/views.py

index 1e0feb4e8cb71d4a176032ece01819506fd392cb..fe067f20f5da90ad37514819853243dfc23b17aa 100644 (file)
@@ -12,7 +12,7 @@ from django.utils.http import http_date, parse_http_date
 from django.conf import settings
 import django
 
-from datetime import date, datetime
+from datetime import date, datetime, timedelta
 import os
 import re
 import urllib
@@ -47,8 +47,11 @@ def home(request):
                training=False,
                enddate__gte=date.today(),
        )
-       # first, see if there are up to do non-badged events
-       other_events = event_base_queryset.filter(badged=False).order_by('enddate', 'startdate')[:2]
+       # first, see if there are up to two non-badged events within 90 days
+       other_events = event_base_queryset.filter(
+               badged=False,
+               startdate__lte=date.today() + timedelta(days=90),
+       ).order_by('enddate', 'startdate')[:2]
        # based on that, get 7 - |other_events| community events to display
        community_event_queryset = event_base_queryset.filter(badged=True).order_by('enddate', 'startdate')[:(7 - other_events.count())]
        # now, return all the events in one unioned array!