Skip to content

Instantly share code, notes, and snippets.

@joneskoo
Created September 15, 2011 04:01
Show Gist options
  • Save joneskoo/1218504 to your computer and use it in GitHub Desktop.
Save joneskoo/1218504 to your computer and use it in GitHub Desktop.
Sikteeri list members by month
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# https://gist.github.com/1218504
"""
generate_test_data.py
Copyright (c) 2010-2011 Kapsi Internet-käyttäjät ry. All rights reserved.
"""
import sys
import os
import traceback
import logging
from datetime import datetime
os.environ['DJANGO_SETTINGS_MODULE'] = 'sikteeri.settings'
sys.path.insert(0, 'sikteeri')
from django.conf import settings
from django.core import management
from django.db import transaction
from django.contrib.auth.models import User
from django.contrib.comments.models import Comment
from django.db.models import Avg, Max, Min, Count
from membership.models import Membership
def main():
dates = Membership.objects.dates('created', 'month')
print "# month total deleted"
for d in dates:
total = Membership.objects.filter(created__year=d.year,
created__month=d.month).count()
deleted = Membership.objects.filter(created__year=d.year, status='D',
created__month=d.month).count()
print "%04d-%02d %5d %5d" % (d.year, d.month, total, deleted)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment