def status(request, days=21): timeline = SortedDict() first = dt.date.today() + dt.timedelta(days=1) last = dt.datetime.today() - dt.timedelta(days=days) releases = Release.objects.filter(pub_date__gte=last) releases = releases.select_related('comic__slug') releases = releases.order_by('comic__slug').distinct() for comic in Comic.objects.all(): schedule = get_comic_schedule(comic) timeline[comic] = [] for i in range(days+2): day = first - dt.timedelta(days=i) classes = set() if not schedule: classes.add('unscheduled') elif int(day.strftime('%w')) in schedule: classes.add('scheduled') timeline[comic].append([classes, day, None]) for release in releases: day = (first - release.pub_date).days timeline[release.comic][day][0].add('fetched') timeline[release.comic][day][2] = release return render_to_response('core/status.html', {'timeline': timeline}, context_instance=RequestContext(request))
def status(request, num_days=21): today = datetime.date.today() timeline = SortedDict() last = today - datetime.timedelta(days=num_days) releases = Release.objects.filter(pub_date__gte=last, comic__active=True) releases = releases.select_related().order_by('comic__slug').distinct() comics = Comic.objects.filter(active=True) comics = comics.annotate(last_pub_date=Max('release__pub_date')) comics = comics.order_by('last_pub_date') for comic in comics: if comic.last_pub_date: comic.days_since_last_release = (today - comic.last_pub_date).days else: comic.days_since_last_release = 1000 schedule = get_comic_schedule(comic) timeline[comic] = [] for i in range(num_days + 1): day = today - datetime.timedelta(days=i) classes = set() if not schedule: classes.add('unscheduled') elif int(day.strftime('%w')) in schedule: classes.add('scheduled') timeline[comic].append([classes, day, None]) for release in releases: day = (today - release.pub_date).days timeline[release.comic][day][0].add('fetched') timeline[release.comic][day][2] = release days = [ today - datetime.timedelta(days=i) for i in range(num_days + 1)] return render(request, 'status/status.html', { 'active': {'status': True}, 'days': days, 'timeline': timeline, })
def status(request, num_days=21): today = datetime.date.today() timeline = SortedDict() last = today - datetime.timedelta(days=num_days) releases = Release.objects.filter(pub_date__gte=last, comic__active=True) releases = releases.select_related().order_by('comic__slug').distinct() comics = Comic.objects.filter(active=True) comics = comics.annotate(last_pub_date=Max('release__pub_date')) comics = comics.order_by('last_pub_date') for comic in comics: if comic.last_pub_date: comic.days_since_last_release = (today - comic.last_pub_date).days else: comic.days_since_last_release = 1000 schedule = get_comic_schedule(comic) timeline[comic] = [] for i in range(num_days + 1): day = today - datetime.timedelta(days=i) classes = set() if not schedule: classes.add('unscheduled') elif int(day.strftime('%w')) in schedule: classes.add('scheduled') timeline[comic].append([classes, day, None]) for release in releases: day = (today - release.pub_date).days timeline[release.comic][day][0].add('fetched') timeline[release.comic][day][2] = release days = [today - datetime.timedelta(days=i) for i in range(num_days + 1)] return render(request, 'status/status.html', { 'active': { 'status': True }, 'days': days, 'timeline': timeline, })
def status(request, days=21): timeline = SortedDict() first = datetime.date.today() + datetime.timedelta(days=1) last = datetime.date.today() - datetime.timedelta(days=days) releases = Release.objects.filter(pub_date__gte=last, comic__active=True) releases = releases.select_related().order_by('comic__slug').distinct() for comic in Comic.objects.filter(active=True).order_by('slug'): schedule = get_comic_schedule(comic) timeline[comic] = [] for i in range(days + 2): day = first - datetime.timedelta(days=i) classes = set() if not schedule: classes.add('unscheduled') elif int(day.strftime('%w')) in schedule: classes.add('scheduled') timeline[comic].append([classes, day, None]) for release in releases: day = (first - release.pub_date).days timeline[release.comic][day][0].add('fetched') timeline[release.comic][day][2] = release days = [ datetime.date.today() - datetime.timedelta(days=i) for i in range(-1, 22)] return render(request, 'status/status.html', { 'days': days, 'timeline': timeline, })