Skip to content

Commit

Permalink
feat: fix indentation error and add force settings to braze remind ta…
Browse files Browse the repository at this point in the history
…sk (#483)
  • Loading branch information
katrinan029 authored Jun 10, 2024
1 parent 289d890 commit bf4b09a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
38 changes: 19 additions & 19 deletions enterprise_access/apps/enterprise_groups/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_braze_campaign_properties(
catalog_count,
subsidy_expiration_datetime,)

if current_date - timedelta(
if settings.BRAZE_GROUP_EMAIL_FORCE_REMIND_ALL_PENDING_LEARNERS or current_date - timedelta(
days=BRAZE_GROUPS_EMAIL_CAMPAIGNS_FIRST_REMINDER_DAY
) == datetime.strptime(recent_action_time, "%B %d, %Y"):
logger.info('get_braze_campaign_properties_2: properties for reminder day {%s} for enterprise customer {%s}',
Expand All @@ -59,7 +59,7 @@ def get_braze_campaign_properties(
},
}

if current_date - timedelta(
if settings.BRAZE_GROUP_EMAIL_FORCE_REMIND_ALL_PENDING_LEARNERS or current_date - timedelta(
days=BRAZE_GROUPS_EMAIL_CAMPAIGNS_SECOND_REMINDER_DAY
) == datetime.strptime(recent_action_time, "%B %d, %Y"):
logger.info('get_braze_campaign_properties_3: properties for reminder day {%s} for enterprise customer {%s}',
Expand All @@ -74,7 +74,7 @@ def get_braze_campaign_properties(
},
}

if current_date - timedelta(
if settings.BRAZE_GROUP_EMAIL_FORCE_REMIND_ALL_PENDING_LEARNERS or current_date - timedelta(
days=BRAZE_GROUPS_EMAIL_CAMPAIGNS_THIRD_REMINDER_DAY
) == datetime.strptime(recent_action_time, "%B %d, %Y"):
logger.info('get_braze_campaign_properties_4: properties for reminder day {%s} for enterprise customer {%s}',
Expand All @@ -89,7 +89,7 @@ def get_braze_campaign_properties(
},
}

if current_date - timedelta(
if settings.BRAZE_GROUP_EMAIL_FORCE_REMIND_ALL_PENDING_LEARNERS or current_date - timedelta(
days=BRAZE_GROUPS_EMAIL_CAMPAIGNS_FOURTH_REMINDER_DAY
) == datetime.strptime(recent_action_time, "%B %d, %Y"):
logger.info('get_braze_campaign_properties_5: properties for reminder day {%s} for enterprise customer {%s}',
Expand All @@ -105,7 +105,7 @@ def get_braze_campaign_properties(
},
}

if current_date - timedelta(
if settings.BRAZE_GROUP_EMAIL_FORCE_REMIND_ALL_PENDING_LEARNERS or current_date - timedelta(
days=BRAZE_GROUPS_EMAIL_CAMPAIGNS_FINAL_REMINDER_DAY
) == datetime.strptime(recent_action_time, "%B %d, %Y"):
logger.info('get_braze_campaign_properties_6: properties for reminder day {%s} for enterprise customer {%s}',
Expand Down Expand Up @@ -152,17 +152,17 @@ def send_group_reminder_emails(pending_enterprise_users):
pending_enterprise_user["catalog_count"],
pending_enterprise_user["subsidy_expiration_datetime"],
)
try:
logger.info(f'Sending braze campaign group reminder email to {recipient}.')
braze_client_instance.send_campaign_message(
braze_properties["braze_campaign_id"],
recipients=[recipient],
trigger_properties=braze_properties["braze_trigger_properties"],
)
except BrazeClientError as exc:
message = (
"Groups learner reminder email could not be sent "
f"to {recipient} with braze properties {braze_properties}."
)
logger.exception(message)
raise exc
try:
logger.info(f'Sending braze campaign group reminder email to {recipient}.')
braze_client_instance.send_campaign_message(
braze_properties["braze_campaign_id"],
recipients=[recipient],
trigger_properties=braze_properties["braze_trigger_properties"],
)
except BrazeClientError as exc:
message = (
"Groups learner reminder email could not be sent "
f"to {recipient} with braze properties {braze_properties}."
)
logger.exception(message)
raise exc
1 change: 1 addition & 0 deletions enterprise_access/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ def root(*path_fragments):

ALL_ENTERPRISE_GROUP_MEMBERS_CACHE_TIMEOUT = 60 * 5

BRAZE_GROUP_EMAIL_FORCE_REMIND_ALL_PENDING_LEARNERS = False
BRAZE_GROUPS_EMAIL_AUTO_REMINDER_DAY_5_CAMPAIGN = ''
BRAZE_GROUPS_EMAIL_AUTO_REMINDER_DAY_25_CAMPAIGN = ''
BRAZE_GROUPS_EMAIL_AUTO_REMINDER_DAY_50_CAMPAIGN = ''
Expand Down

0 comments on commit bf4b09a

Please sign in to comment.