mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
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`.
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
|
from django.conf import settings
|
||||||
from zerver.models import UserProfile, UserHotspot
|
from zerver.models import UserProfile, UserHotspot
|
||||||
|
|
||||||
from typing import List, Text, Dict
|
from typing import List, Text, Dict
|
||||||
|
|
||||||
SEND_ALL = False
|
|
||||||
|
|
||||||
ALL_HOTSPOTS = {
|
ALL_HOTSPOTS = {
|
||||||
# TODO: Tag these for translation once we've finalized the content.
|
# TODO: Tag these for translation once we've finalized the content.
|
||||||
'intro_reply': {
|
'intro_reply': {
|
||||||
@@ -30,18 +29,15 @@ ALL_HOTSPOTS = {
|
|||||||
|
|
||||||
def get_next_hotspots(user):
|
def get_next_hotspots(user):
|
||||||
# type: (UserProfile) -> List[Dict[str, object]]
|
# type: (UserProfile) -> List[Dict[str, object]]
|
||||||
|
# Only used for manual testing
|
||||||
if SEND_ALL:
|
SEND_ALL = False
|
||||||
result = []
|
if settings.DEVELOPMENT and SEND_ALL:
|
||||||
for hotspot in ALL_HOTSPOTS:
|
return [{
|
||||||
result.append({
|
'name': hotspot,
|
||||||
'name': hotspot,
|
'title': ALL_HOTSPOTS[hotspot]['title'],
|
||||||
'title': ALL_HOTSPOTS[hotspot]['title'],
|
'description': ALL_HOTSPOTS[hotspot]['description'],
|
||||||
'description': ALL_HOTSPOTS[hotspot]['description'],
|
'delay': 0,
|
||||||
'delay': 5,
|
} for hotspot in ALL_HOTSPOTS]
|
||||||
})
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
seen_hotspots = frozenset(UserHotspot.objects.filter(user=user).values_list('hotspot', flat=True))
|
seen_hotspots = frozenset(UserHotspot.objects.filter(user=user).values_list('hotspot', flat=True))
|
||||||
for hotspot in ['intro_reply', 'intro_streams', 'intro_topics', 'intro_compose']:
|
for hotspot in ['intro_reply', 'intro_streams', 'intro_topics', 'intro_compose']:
|
||||||
|
|||||||
Reference in New Issue
Block a user