Skip to content

Commit

Permalink
832 - User events nudge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BradHN1 committed Nov 7, 2023
1 parent dbbdf96 commit 19016bd
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/task_queue/nudges/user_event_nudge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,8 +18,6 @@
MONTHLY = "per_month"
DAILY="per_day"



eastern_tz = pytz.timezone("US/Eastern")

LIMIT=5
Expand All @@ -44,7 +41,6 @@

USER_EVENT_NUDGE_KEY = "user-event-nudge-feature-flag"


# ---------------------------------------------------------------------------------------------------------------------

def should_user_get_nudged(user):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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')


'''
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 19016bd

Please sign in to comment.