Mercurial > public > sg101
diff gpp/core/management/commands/max_users.py @ 519:f72ace06658a
For #194, rework the who's online and max users functions.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 17 Dec 2011 19:29:24 +0000 |
parents | 3fe60148f75c |
children |
line wrap: on
line diff
--- a/gpp/core/management/commands/max_users.py Fri Dec 16 01:17:35 2011 +0000 +++ b/gpp/core/management/commands/max_users.py Sat Dec 17 19:29:24 2011 +0000 @@ -7,41 +7,11 @@ from django.core.management.base import NoArgsCommand -from core.models import Statistic -from core.whos_online import get_users_online, get_visitors_online, tick +from core.whos_online import max_users class Command(NoArgsCommand): help = "Run periodically to compute the max users online statistic." def handle_noargs(self, **options): - - now = datetime.datetime.now() - - users = len(get_users_online()) - guests = len(get_visitors_online()) - - updated = False - try: - stat = Statistic.objects.get(pk=1) - except Statistic.DoesNotExist: - stat = Statistic(max_users=users, - max_users_date=now, - max_anon_users=guests, - max_anon_users_date=now) - updated=True - else: - if users > stat.max_users: - stat.max_users = users - stat.max_users_date = now - updated=True - if guests > stat.max_anon_users: - stat.max_anon_users = guests - stat.max_anon_users_date = now - updated=True - - if updated: - stat.save() - - # "tick" the who's online data collector - tick() + max_users()