mirror of
https://github.com/zulip/zulip.git
synced 2025-10-29 02:53:52 +00:00
This contains the various fixes that needed to be made in order to get accurate statistics. Most notably, the active_users_between function in the previous version of zerver/lib/statistics.py was broken for end dates in the past, because it used the UserActivity table to get its data -- so in fact it really was querying "users last active between". This commit isn't super clean, but I figure we're probably better off having our latest code for historical usage data in git so it doesn't bitrot and anyone can improve on it. (imported from commit 24ff2f24a22e5bdc004ea8043d8da12deb97ff2f)
25 lines
922 B
Python
25 lines
922 B
Python
from __future__ import absolute_import
|
|
|
|
import datetime
|
|
import pytz
|
|
|
|
from optparse import make_option
|
|
from django.core.management.base import BaseCommand
|
|
from zerver.lib.statistics import activity_averages_during_day
|
|
|
|
class Command(BaseCommand):
|
|
help = "Generate statistics on user activity for a given day."
|
|
|
|
option_list = BaseCommand.option_list + \
|
|
(make_option('--date', default=None, action='store',
|
|
help="Day to query in format 2013-12-05. Default is yesterday"),)
|
|
|
|
def handle(self, *args, **options):
|
|
if options["date"] is None:
|
|
date = datetime.datetime.now() - datetime.timedelta(days=1)
|
|
else:
|
|
date = datetime.datetime.strptime(options["date"], "%Y-%m-%d")
|
|
print "Activity data for", date
|
|
print activity_averages_during_day(date)
|
|
print "Please note that the total registered user count is a total for today"
|