Remove updating provider on failure - we aren't sure yet who is sending the message the callback code sets that property as a fallback anyway.

Remove debug statements.
This commit is contained in:
Rebecca Law
2019-05-08 16:31:51 +01:00
parent 77c35da5ca
commit fc61fd2086
2 changed files with 2 additions and 14 deletions

View File

@@ -7,7 +7,6 @@ from notifications_utils.recipients import (
validate_and_format_email_address
)
from notifications_utils.template import HTMLEmailTemplate, PlainTextEmailTemplate, SMSMessageTemplate
from requests.exceptions import HTTPError
from app import clients, statsd_client, create_uuid
from app.dao.notifications_dao import (
@@ -26,7 +25,6 @@ from app.models import (
BRANDING_BOTH,
BRANDING_ORG_BANNER,
EMAIL_TYPE,
NOTIFICATION_CREATED,
NOTIFICATION_TECHNICAL_FAILURE,
NOTIFICATION_SENT,
NOTIFICATION_SENDING
@@ -42,9 +40,7 @@ def send_sms_to_provider(notification):
if notification.status == 'created':
provider = provider_to_use(SMS_TYPE, notification.id, notification.international)
current_app.logger.debug(
"Starting sending SMS {} to provider at {}".format(notification.id, datetime.utcnow())
)
template_model = dao_get_template_by_id(notification.template_id, notification.template_version)
template = SMSMessageTemplate(
@@ -68,7 +64,6 @@ def send_sms_to_provider(notification):
)
except Exception as e:
notification.billable_units = template.fragment_count
notification.sent_by = provider.get_name()
dao_update_notification(notification)
dao_toggle_sms_provider(provider.name)
raise e
@@ -76,9 +71,6 @@ def send_sms_to_provider(notification):
notification.billable_units = template.fragment_count
update_notification_to_sending(notification, provider)
current_app.logger.debug(
"SMS {} sent to provider {} at {}".format(notification.id, provider.get_name(), notification.sent_at)
)
delta_milliseconds = (datetime.utcnow() - notification.created_at).total_seconds() * 1000
statsd_client.timing("sms.total-time", delta_milliseconds)
@@ -125,9 +117,6 @@ def send_email_to_provider(notification):
notification.reference = reference
update_notification_to_sending(notification, provider)
current_app.logger.debug(
"Email {} sent to provider at {}".format(notification.id, notification.sent_at)
)
delta_milliseconds = (datetime.utcnow() - notification.created_at).total_seconds() * 1000
statsd_client.timing("email.total-time", delta_milliseconds)

View File

@@ -539,7 +539,7 @@ def test_should_update_billable_units_according_to_research_mode_and_key_type(
assert notification.billable_units == billable_units
def test_should_set_notification_billable_units_and_provider_if_sending_to_provider_fails(
def test_should_set_notification_billable_units_if_sending_to_provider_fails(
sample_notification,
mocker,
):
@@ -553,7 +553,6 @@ def test_should_set_notification_billable_units_and_provider_if_sending_to_provi
send_to_providers.send_sms_to_provider(sample_notification)
assert sample_notification.billable_units == 1
assert sample_notification.sent_by == 'mmg'
assert mock_toggle_provider.called