1
0
Fork 0
mirror of https://github.com/Findus23/acronomy.git synced 2024-09-19 15:33:45 +02:00
acronomy/acros/management/commands/refetch_wikipedia.py

25 lines
707 B
Python
Raw Permalink Normal View History

2023-03-21 23:24:52 +01:00
import time
2023-03-21 23:30:07 +01:00
from datetime import timedelta
2023-03-21 23:24:52 +01:00
2020-06-08 18:45:38 +02:00
from django.core.management.base import BaseCommand
2023-03-21 23:30:07 +01:00
from django.utils import timezone
2020-06-08 18:45:38 +02:00
from acros.models import WikipediaLink
class Command(BaseCommand):
help = 'Updates all Wikipedia articles'
def handle(self, *args, **options):
links = WikipediaLink.objects.all()
for link in links:
2023-03-21 23:24:52 +01:00
self.stdout.write(link.title)
2023-03-21 23:30:07 +01:00
if link.timestamp >= (timezone.now() - timedelta(days=180)):
print("skipped")
continue
2023-03-21 23:24:52 +01:00
link.fetched = False
# update_change_reason(link, "refetch_wikipedia command")
link.clean()
link.save()
2023-03-21 23:30:07 +01:00
time.sleep(3)