euscan-ng/euscanwww/djeuscan/management/commands/regen-rrds.py

24 lines
835 B
Python
Raw Normal View History

2012-04-28 18:16:05 +02:00
from django.core.management.base import BaseCommand
from djeuscan.models import HerdLog, MaintainerLog, CategoryLog, WorldLog
from djeuscan import charts
2012-04-28 18:16:05 +02:00
class Command(BaseCommand):
_overlays = {}
help = 'Regenerate rrd database'
def handle(self, *args, **options):
for wlog in WorldLog.objects.all():
charts.rrd_update('world', wlog.datetime, wlog)
for clog in CategoryLog.objects.all():
2012-04-28 18:16:05 +02:00
charts.rrd_update('category-%s' % clog.category,
clog.datetime, clog)
for hlog in HerdLog.objects.all():
charts.rrd_update('herd-%d' % hlog.herd.id, hlog.datetime, hlog)
for mlog in MaintainerLog.objects.all():
2012-04-28 18:16:05 +02:00
charts.rrd_update('maintainer-%d' % mlog.maintainer.id,
mlog.datetime, mlog)