@@ -0,0 +1,1022 @@
+from competition.models import Competition%0A%0Aimport collections%0Aimport csv%0Aimport datetime%0Aimport itertools%0Aimport json%0Aimport StringIO%0A%0A%0Adef daterange(start_date, end_date):%0A    num_days = int((end_date - start_date).days) + 1%0A    for n in range(num_days + 1):%0A        yield start_date + datetime.timedelta(days=n)%0A%0A%0Adef accumulate(registrations):%0A    dates = %5Bx.signup_date for x in registrations%5D%0A    result = collections.OrderedDict()%0A    for day in daterange(min(dates), max(dates)):%0A        key = day.strftime(%22%25m-%25d-%25Y%22)%0A        result%5Bkey%5D = registrations.filter(signup_date__lt=day).count()%0A    return result%0A%0A%0Adef run():%0A    for competition in Competition.objects.all():%0A        registrations = competition.registration_set.filter(active=True)%0A%0A        csv_content = StringIO.StringIO()%0A        writer = csv.writer(csv_content)%0A%0A        print %22%5Cn%22, competition.name%0A        for date, count in accumulate(registrations).iteritems():%0A            writer.writerow(%5Bdate, count%5D)%0A%0A        print csv_content.getvalue()%0A

Add script to calculate registration trends