2013-10-18 17:40:16 +02:00
|
|
|
from __future__ import absolute_import
|
2015-11-01 17:11:06 +01:00
|
|
|
from __future__ import print_function
|
2013-10-18 17:40:16 +02:00
|
|
|
|
|
|
|
import datetime
|
|
|
|
import pytz
|
|
|
|
|
|
|
|
from optparse import make_option
|
2016-06-04 16:52:18 +02:00
|
|
|
from typing import Any
|
2013-10-18 17:40:16 +02:00
|
|
|
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):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (*Any, **Any) -> None
|
2013-10-18 17:40:16 +02:00
|
|
|
if options["date"] is None:
|
|
|
|
date = datetime.datetime.now() - datetime.timedelta(days=1)
|
|
|
|
else:
|
|
|
|
date = datetime.datetime.strptime(options["date"], "%Y-%m-%d")
|
2015-11-01 17:11:06 +01:00
|
|
|
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")
|