From 4df97f6d5e22ee80829727cb8d3e60a28aee451d Mon Sep 17 00:00:00 2001 From: wbanks Date: Wed, 5 Feb 2025 15:57:50 -0500 Subject: [PATCH 1/2] Add feedback_reason column to the notification table - Added new notification_status: pinpoint-failure - Added pinpoint-failure to various enum-like variables --- app/models.py | 4 ++ app/utils.py | 1 + .../0474_add_feedback_reason_column.py | 41 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 migrations/versions/0474_add_feedback_reason_column.py diff --git a/app/models.py b/app/models.py index dd04d61bf2..ec6fb01e3e 100644 --- a/app/models.py +++ b/app/models.py @@ -1548,6 +1548,7 @@ def check_code(self, cde): NOTIFICATION_TECHNICAL_FAILURE = "technical-failure" NOTIFICATION_TEMPORARY_FAILURE = "temporary-failure" NOTIFICATION_PERMANENT_FAILURE = "permanent-failure" +NOTIFICATION_PINPOINT_FAILURE = "pinpoint-failure" NOTIFICATION_PENDING_VIRUS_CHECK = "pending-virus-check" NOTIFICATION_VALIDATION_FAILED = "validation-failed" NOTIFICATION_VIRUS_SCAN_FAILED = "virus-scan-failed" @@ -1558,6 +1559,7 @@ def check_code(self, cde): NOTIFICATION_TECHNICAL_FAILURE, NOTIFICATION_TEMPORARY_FAILURE, NOTIFICATION_PERMANENT_FAILURE, + NOTIFICATION_PINPOINT_FAILURE, NOTIFICATION_VALIDATION_FAILED, NOTIFICATION_VIRUS_SCAN_FAILED, NOTIFICATION_RETURNED_LETTER, @@ -1605,6 +1607,7 @@ def check_code(self, cde): NOTIFICATION_TECHNICAL_FAILURE, NOTIFICATION_TEMPORARY_FAILURE, NOTIFICATION_PERMANENT_FAILURE, + NOTIFICATION_PINPOINT_FAILURE, NOTIFICATION_PENDING_VIRUS_CHECK, NOTIFICATION_VALIDATION_FAILED, NOTIFICATION_VIRUS_SCAN_FAILED, @@ -1739,6 +1742,7 @@ class Notification(BaseModel): feedback_subtype = db.Column(db.String, nullable=True) ses_feedback_id = db.Column(db.String, nullable=True) ses_feedback_date = db.Column(db.DateTime, nullable=True) + feedback_reason = db.Column(db.String, nullable=True) # SMS columns sms_total_message_price = db.Column(db.Numeric(), nullable=True) diff --git a/app/utils.py b/app/utils.py index e808123295..c06a466a5b 100644 --- a/app/utils.py +++ b/app/utils.py @@ -21,6 +21,7 @@ "temporary-failure", "permanent-failure", "technical-failure", + "pinpoint-failure", "virus-scan-failed", "validation-failed", ] diff --git a/migrations/versions/0474_add_feedback_reason_column.py b/migrations/versions/0474_add_feedback_reason_column.py new file mode 100644 index 0000000000..e0f762a018 --- /dev/null +++ b/migrations/versions/0474_add_feedback_reason_column.py @@ -0,0 +1,41 @@ +""" + +Revision ID: 0474_add_feedback_reason_column +Revises: 0473_change_pt_support_email +Create Date: 2025-02-05 14:40:00 EST + +""" + +import sqlalchemy as sa +from alembic import op + +revision = "0474_add_feedback_reason_column" +down_revision = "0473_change_pt_support_email" + +new_notification_status = "pinpoint-failure" + + +def upgrade(): + op.add_column("notifications", sa.Column("feedback_reason", sa.String(length=255), nullable=True)) + op.add_column("notification_history", sa.Column("feedback_reason", sa.String(length=255), nullable=True)) + + op.create_index( + op.f("ix_notifications_feedback_reason"), + "notifications", + ["feedback_reason"], + ) + op.create_index( + op.f("ix_notification_history_feedback_reason"), + "notification_history", + ["feedback_reason"], + ) + + op.execute("INSERT INTO notification_status_types (name) VALUES ('{}')".format(new_notification_status)) + + +def downgrade(): + op.drop_index(op.f("ix_notifications_feedback_reason"), table_name="notifications") + op.drop_index(op.f("ix_notification_history_feedback_reason"), table_name="notification_history") + op.drop_column("notifications", "feedback_reason") + op.drop_column("notification_history", "feedback_reason") + op.execute("DELETE FROM notification_status_types WHERE name = '{}'".format(new_notification_status)) From b9f45a2efb490549a0046fd53d2f914213050e20 Mon Sep 17 00:00:00 2001 From: wbanks Date: Wed, 5 Feb 2025 16:42:22 -0500 Subject: [PATCH 2/2] Fix tests --- tests/app/v2/notifications/test_get_notifications.py | 2 +- tests/app/v2/notifications/test_notification_schemas.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/app/v2/notifications/test_get_notifications.py b/tests/app/v2/notifications/test_get_notifications.py index cfa4e7bc91..05a4a70bc3 100644 --- a/tests/app/v2/notifications/test_get_notifications.py +++ b/tests/app/v2/notifications/test_get_notifications.py @@ -464,7 +464,7 @@ def test_get_all_notifications_filter_by_status_invalid_status(client, sample_no assert len(json_response["errors"]) == 1 assert ( json_response["errors"][0]["message"] == "status elephant is not one of [cancelled, created, sending, " - "sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, " + "sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, pinpoint-failure, " "pending-virus-check, validation-failed, virus-scan-failed, returned-letter, " "pii-check-failed, accepted, received]" ) diff --git a/tests/app/v2/notifications/test_notification_schemas.py b/tests/app/v2/notifications/test_notification_schemas.py index f445eb5162..4ef39c1c44 100644 --- a/tests/app/v2/notifications/test_notification_schemas.py +++ b/tests/app/v2/notifications/test_notification_schemas.py @@ -46,7 +46,7 @@ def test_get_notifications_request_invalid_statuses(invalid_statuses, valid_stat partial_error_status = ( "is not one of " "[cancelled, created, sending, sent, delivered, pending, failed, " - "technical-failure, temporary-failure, permanent-failure, pending-virus-check, " + "technical-failure, temporary-failure, permanent-failure, pinpoint-failure, pending-virus-check, " "validation-failed, virus-scan-failed, returned-letter, pii-check-failed, accepted, received]" ) @@ -103,7 +103,7 @@ def test_get_notifications_request_invalid_statuses_and_template_types(): for invalid_status in ["elephant", "giraffe"]: assert ( "status {} is not one of [cancelled, created, sending, sent, delivered, " - "pending, failed, technical-failure, temporary-failure, permanent-failure, " + "pending, failed, technical-failure, temporary-failure, permanent-failure, pinpoint-failure, " "pending-virus-check, validation-failed, virus-scan-failed, returned-letter, " "pii-check-failed, accepted, received]".format(invalid_status) in error_messages )