Commit 137e48f922d6b5c691526faf12c3ff95412ef19a

Authored by Rohan Rangray
1 parent 4f3df4b576
Exists in master

Fixed stupid indexing bug

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

flashcards/management/commands/notifyusers.py View file @ 137e48f
from django.core.management import BaseCommand 1 1 from django.core.management import BaseCommand
from flashcards.models import UserFlashcard, User, Now 2 2 from flashcards.models import UserFlashcard, User, Now
from django.utils.timezone import now 3 3 from django.utils.timezone import now
from datetime import timedelta 4 4 from datetime import timedelta
5 5
6 6
class Command(BaseCommand): 7 7 class Command(BaseCommand):
help = 'Notify the users if they have cards to be reviewed' 8 8 help = 'Notify the users if they have cards to be reviewed'
9 9
def handle(self, *args, **options): 10 10 def handle(self, *args, **options):
notify_filter = UserFlashcard.objects.prefetch_related('user').filter( 11 11 notify_filter = UserFlashcard.objects.prefetch_related('user').filter(
next_review__lte=Now() 12 12 next_review__lte=Now()
).exclude( 13 13 ).exclude(
user__registration_id=None, 14 14 user__registration_id=None,
user__last_notified__range=(now()-timedelta(days=1), now()) 15 15 user__last_notified__range=(now()-timedelta(days=1), now())
).values_list('user').distinct().all() 16 16 ).values_list('user').distinct().all()
17 17