Fix downloading images on publish.
[wolnelektury.git] / src / stats / management / commands / populate_visits.py
1 from datetime import date, timedelta
2 from django.core.management.base import BaseCommand
3 from stats.models import Visits, DayVisits
4
5
6 class Command(BaseCommand):
7     def add_arguments(self, parser):
8         parser.add_argument(
9             '-s' ,'--since', metavar='YYYY-MM-DD',
10             required=True
11         )
12         parser.add_argument(
13             '-u' ,'--until', metavar='YYYY-MM-DD',
14             required=True
15         )
16
17         
18     def handle(self, **options):
19         since = date(*[int(p) for p in options['since'].split('-')])
20         until = date(*[int(p) for p in options['until'].split('-')])
21         while since < until:
22             print(since)
23             DayVisits.build_day(since)
24             since += timedelta(1)
25