From 21f076ac5d5ddaf07bd61d388468842c7f057efb Mon Sep 17 00:00:00 2001 From: Rishi Gupta Date: Tue, 29 Aug 2017 17:42:52 -0700 Subject: [PATCH] hotspots.py: Clean up SEND_ALL codepath. Moves SEND_ALL to inside get_next_hotspots, since it is not something other files should call. Also changes the delay to 0s, and gates the code behind an `if settings.DEVELOPMENT`. --- zerver/lib/hotspots.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/zerver/lib/hotspots.py b/zerver/lib/hotspots.py index 6d273a6b8b..329736aa28 100644 --- a/zerver/lib/hotspots.py +++ b/zerver/lib/hotspots.py @@ -1,9 +1,8 @@ +from django.conf import settings from zerver.models import UserProfile, UserHotspot from typing import List, Text, Dict -SEND_ALL = False - ALL_HOTSPOTS = { # TODO: Tag these for translation once we've finalized the content. 'intro_reply': { @@ -30,18 +29,15 @@ ALL_HOTSPOTS = { def get_next_hotspots(user): # type: (UserProfile) -> List[Dict[str, object]] - - if SEND_ALL: - result = [] - for hotspot in ALL_HOTSPOTS: - result.append({ - 'name': hotspot, - 'title': ALL_HOTSPOTS[hotspot]['title'], - 'description': ALL_HOTSPOTS[hotspot]['description'], - 'delay': 5, - }) - - return result + # Only used for manual testing + SEND_ALL = False + if settings.DEVELOPMENT and SEND_ALL: + return [{ + 'name': hotspot, + 'title': ALL_HOTSPOTS[hotspot]['title'], + 'description': ALL_HOTSPOTS[hotspot]['description'], + 'delay': 0, + } for hotspot in ALL_HOTSPOTS] seen_hotspots = frozenset(UserHotspot.objects.filter(user=user).values_list('hotspot', flat=True)) for hotspot in ['intro_reply', 'intro_streams', 'intro_topics', 'intro_compose']: