Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Shipping Emails on Staging #571

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions microsetta_private_api/util/perk_fulfillment.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def process_subscription_fulfillments():
pf_active = pfr.check_perk_fulfillment_active()

if pf_active:
with Transaction() as t:
pfr = PerkFulfillmentRepo(t)
fulfillment_ids = pfr.get_subscription_fulfillments()
fulfillment_ids = pfr.get_subscription_fulfillments()

for fulfillment_id in fulfillment_ids:
with Transaction() as t:
Expand Down Expand Up @@ -82,21 +80,24 @@ def process_subscription_fulfillments():
def check_shipping_updates():
with Transaction() as t:
pfr = PerkFulfillmentRepo(t)
emails_sent, error_report = pfr.check_for_shipping_updates()
pf_active = pfr.check_perk_fulfillment_active()

if emails_sent > 0 or len(error_report) > 0:
t.commit()
if pf_active:
emails_sent, error_report = pfr.check_for_shipping_updates()

email_content = f"Emails sent: {emails_sent}\n"\
f"Errors: {error_report}"
try:
send_email(SERVER_CONFIG['pester_email'], "pester_daniel",
{"what": "Automated Tracking Updates Output",
"content": email_content},
EN_US)
except: # noqa
# try our best to email
pass
if emails_sent > 0 or len(error_report) > 0:
t.commit()

email_content = f"Emails sent: {emails_sent}\n"\
f"Errors: {error_report}"
try:
send_email(SERVER_CONFIG['pester_email'], "pester_daniel",
{"what": "Automated Tracking Updates Output",
"content": email_content},
EN_US)
except: # noqa
# try our best to email
pass


@celery.task(ignore_result=True)
Expand Down
Loading