1 from datetime import timedelta
2 from django.core.management.base import BaseCommand
3 from django.db.models import F
4 from django.utils.timezone import now
5 from sources.models import Source
8 class Command(BaseCommand):
9 def handle(self, **options):
10 for s in Source.objects.filter(
11 modified_at__lt=now() - timedelta(seconds=60)
12 ).exclude(processed_at__gt=F('modified_at')).order_by('modified_at'):
16 except Exception as e: