Fix.
[redakcja.git] / src / sources / management / commands / sources_process.py
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
6
7
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'):
13             print(s)
14             try:
15                 s.process()
16             except Exception as e:
17                 print(e)
18                 pass
19