diff --git a/src/task_queue/nudges/user_event_nudge.py b/src/task_queue/nudges/user_event_nudge.py index f15b93c88..ece890c8f 100644 --- a/src/task_queue/nudges/user_event_nudge.py +++ b/src/task_queue/nudges/user_event_nudge.py @@ -3,7 +3,6 @@ from _main_.utils.common import encode_data_for_URL, serialize_all from _main_.utils.constants import COMMUNITY_URL_ROOT from _main_.utils.emailer.send_email import send_massenergize_email_with_attachments -from api.constants import GUEST_USER from api.utils.api_utils import get_sender_email from api.utils.constants import USER_EVENTS_NUDGE_TEMPLATE from database.models import Community, CommunityMember, Event, UserProfile, FeatureFlag @@ -19,8 +18,6 @@ MONTHLY = "per_month" DAILY="per_day" - - eastern_tz = pytz.timezone("US/Eastern") LIMIT=5 @@ -44,7 +41,6 @@ USER_EVENT_NUDGE_KEY = "user-event-nudge-feature-flag" - # --------------------------------------------------------------------------------------------------------------------- def should_user_get_nudged(user): @@ -142,8 +138,8 @@ def get_date_range(start, end): start_date =start.strftime('%b-%d-%Y') end_date = end.strftime('%b-%d-%Y') if start_date == end_date: - return f"{convert_date(start,'%b %d, %Y')}, {convert_date(start,' %H:%M %p')} - {convert_date(end,' %H:%M %p')}" - return f"{convert_date(start,'%b %d, %Y %H:%M %p')} - {convert_date(end,'%b %d, %Y %H:%M %p')}" + return f"{convert_date(start,'%b %d, %Y')}, {convert_date(start,' %I:%M %p')} - {convert_date(end,' %I:%M %p')}" + return f"{convert_date(start,'%b %d, %Y %I:%M %p')} - {convert_date(end,'%b %d, %Y %I:%M %p')}" def truncate_title(title): @@ -240,7 +236,7 @@ def get_user_events(notification_dates, community_events): # else use the last nudge date last_time = date_aware if date_aware else a_week_ago - return community_events.filter(Q(published_at__range=[last_time, today])) + return community_events.filter(Q(published_at__range=[last_time, today])).order_by('start_date_and_time') ''' @@ -270,7 +266,7 @@ def prepare_user_events_nudge(task=None,email=None, community_id=None): users = get_community_users(community.id) users = flag.enabled_users(users) - for user in users: + for user in users: user_events = get_user_events(user.notification_dates, events) send_automated_nudge(user_events, user, community)