Correctly get next meetings when there's multiple

This commit is contained in:
Tanner Collin 2020-02-10 08:13:00 +00:00
parent 35dc736017
commit 6fa73af0be

View File

@ -1,5 +1,7 @@
import time import time
import datetime
from django.core.cache import cache from django.core.cache import cache
from django.utils.timezone import now
from apiserver.api import models from apiserver.api import models
DEFAULTS = { DEFAULTS = {
@ -23,10 +25,12 @@ def changed_card():
def calc_next_events(): def calc_next_events():
sessions = models.Session.objects sessions = models.Session.objects
member_meeting = sessions.filter(course=317).last() member_meeting = sessions.filter(course=317, datetime__gte=now()).first()
monthly_clean = sessions.filter(course=273).last() monthly_clean = sessions.filter(course=273, datetime__gte=now()).first()
if member_meeting:
cache.set('next_meeting', member_meeting.datetime) cache.set('next_meeting', member_meeting.datetime)
if monthly_clean:
cache.set('next_clean', monthly_clean.datetime) cache.set('next_clean', monthly_clean.datetime)
def calc_member_counts(): def calc_member_counts():