Permalink
Browse files

analytics: Do not run update_analytics_counts if there are no realms.

Having no realms was not possible before, but will be once system bots are
no longer on a special system realm.
  • Loading branch information...
rishig authored and timabbott committed Oct 5, 2017
1 parent c7bdabb commit e31758c25745c1c9386e1d8e19a8199539182759
Showing with 7 additions and 2 deletions.
  1. +7 −2 analytics/management/commands/update_analytics_counts.py
@@ -15,7 +15,7 @@
from analytics.models import RealmCount, UserCount
from analytics.lib.counts import COUNT_STATS, logger, process_count_stat
from zerver.lib.timestamp import floor_to_hour
from zerver.models import UserProfile, Message
from zerver.models import UserProfile, Message, Realm
from typing import Any, Dict
@@ -57,8 +57,13 @@ def handle(self, *args, **options):
def run_update_analytics_counts(self, options):
# type: (Dict[str, Any]) -> None
fill_to_time = parse_datetime(options['time'])
# installation_epoch relies on there being at least one realm; we
# shouldn't run the analytics code if that condition isn't satisfied
if not Realm.objects.exists():
logger.info("No realms, stopping update_analytics_counts")
return
fill_to_time = parse_datetime(options['time'])
if options['utc']:
fill_to_time = fill_to_time.replace(tzinfo=timezone_utc)
if fill_to_time.tzinfo is None:

0 comments on commit e31758c

Please sign in to comment.