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

#2011 - Eliminate Null Status Reason #2083

Merged
merged 17 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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: 29 additions & 4 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ fileignoreconfig:
checksum: ab93313f306c8a3f6576141e8f32d9fc99b0de7da8d44a1ddbe6ea55d167dcdb
- filename: app/notifications/process_notifications.py
checksum: ae4e31c6eb56d91ec80ae09d13baf4558cf461c65f08893b93fee43f036a17a7
- filename: app/service/rest.py
checksum: b42aefd1ae0e6ea76e75db4cf14d425facd0941943b17f7ba2e41f850ad1ec23
- filename: app/template/rest.py
checksum: 1e5bdac8bc694d50f8f656dec127dd036b7b1b5b6156e3282d3411956c71ba0b
- filename: cd/application-deployment/dev/dev.env
Expand Down Expand Up @@ -42,16 +40,43 @@ fileignoreconfig:
- filename: tests/app/celery/test_service_callback_tasks.py
checksum: 70575434f7a4fedd43d4c9164bc899a606768526d432c364db372524eec26542
- filename: lambda_functions/va_profile/va_profile_opt_in_out_lambda.py
checksum: ab4099f87cacd5ebd5b7fdbffd77d062ab6b3880bdc033b0fd65358d392dde97
checksum: a05165537ffbfac90000c5d04d8628251d771f6d1334c91c3aed28bf6c32368c
- filename: tests/app/conftest.py
checksum: a80aa727586db82ed1b50bdb81ddfe1379e649a9dfc1ece2c36047486b41b83d
- filename: tests/app/notifications/test_process_notifications_for_profile_v3.py
checksum: 4e15e63d349635131173ffdd7aebcd547621db08de877ef926d3a41fde72d065
- filename: tests/app/v2/notifications/test_post_notifications.py
checksum: 3181930a13e3679bb2f17eaa3f383512eb9caf4ed5d5e14496ca4193c6083965
- filename: tests/lambda_functions/va_profile/test_va_profile_integration.py
checksum: 94f3e59c05ed2024a08495e15dab266cdc27d33eb6bc56d8256bd53b38668f9a
checksum: 4f0f4d7a4113762219e45a51f7b26a7c0cb83f1d8f10c5598533f6cdcf0e0ada
- filename: app/va/va_profile/va_profile_client.py
checksum: fe634f26f7dc3874f4afcfd1ba3f03bae380b53befe973a752c7347097a88701
- filename: tests/lambda_functions/vetext_incoming_forwarder_lambda/test_vetext_incoming_forwarder_lambda.py
checksum: 7494eb4321fd2fbc3ff3915d8753d8fec7a936a69dc6ab78f0b532a701f032eb
- filename: app/celery/nightly_tasks.py
checksum: b5b4999f778361603fdc7d710772968461e79a016f66badfbafd590bf70c5a11
- filename: tests/app/dao/test_api_key_dao.py
checksum: ef306fcc1dc512b74abeb5dde5f20977cf95e67a2fa049df6289a7b5500339a9
- filename: tests/app/notifications/test_send_notifications.py
checksum: 69304e1edd6993acd9a842a87dba8ee16854befc643863e1589b15c303a71464
- filename: tests/app/v3/notifications/test_rest.py
checksum: 25aeb31ce5974f0a414ff43a9a75f787a6cf41c783f7eacf2415ce1fedf54c1d
- filename: app/commands.py
checksum: 79d914948e4e28dabc9c074956a11a9ceec27e7ae57b8eb8fb483f4a6217f07d
- filename: app/constants.py
checksum: 9262bddf98c91c1eb0bbad4aae89b436f898ae664050920a5755b6475d2821a9
- filename: app/letters/utils.py
checksum: 5e6071b9cab380f9f3ee172f8c731061241200f53453a9863f22bb5eaa05e6af
- filename: app/service/utils.py
checksum: c1e34f85b5b0fc32eb6a3afcc16c7099b74294e578487004dc6ba3bc46832010
- filename: app/v3/notifications/rest.py
checksum: aea8f32b796f324e4b57e1be6703b31c0550447011550d944cdb461489203f7d
- filename: app/user/rest.py
checksum: e867ef2c802c8a3fd187fd0df76533e62cccb1721582c4fc4d2a920eb11c1e3b
- filename: app/notifications/send_notifications.py
checksum: 12ed8e1334772c0d65cc13be03b6d5197ebbf4d35460aee2fac1fc2a9644e9e1
- filename: app/service/rest.py
checksum: 7f8a30dd84b3ceb0d08bae949b5b127fd408ee2fd8097eb7d4b291ede61f8d0f
- filename: tests/app/celery/test_process_delivery_status_result_tasks.py
checksum: c1c596d40f5bc8c8621204c6cfdd1c8adda0092a396fcd73b1d9f843f4951d7f
version: "1.0"
16 changes: 3 additions & 13 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
import random
import string
import uuid
from dotenv import load_dotenv

from dotenv import load_dotenv
from flask import request, g, jsonify, make_response
from flask_marshmallow import Marshmallow
from flask_migrate import Migrate
Expand All @@ -28,9 +27,7 @@
from app.clients.sms.aws_sns import AwsSnsClient
from app.clients.sms.twilio import TwilioSMSClient
from app.clients.sms.aws_pinpoint import AwsPinpointClient
from app.clients.performance_platform.performance_platform_client import (
PerformancePlatformClient,
)
from app.clients.performance_platform.performance_platform_client import PerformancePlatformClient
from app.feature_flags import FeatureFlag, is_feature_enabled
from app.oauth.registry import oauth_registry
from app.va.va_onsite import VAOnsiteClient
Expand All @@ -41,12 +38,9 @@
from app.attachments.store import AttachmentStore
from app.db import db

DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'
DATE_FORMAT = '%Y-%m-%d'
HTTP_TIMEOUT = (3.05, 1) if os.getenv('NOTIFY_ENVIRONMENT') in ('production', 'staging') else (30, 30)

load_dotenv()


migrate = Migrate()
ma = Marshmallow()
notify_celery = NotifyCelery()
Expand Down Expand Up @@ -434,10 +428,6 @@ def exception(error):
return jsonify(result='error', message='Internal server error'), 500


def create_uuid():
return str(uuid.uuid4())


def create_random_identifier():
# the random.choice is used for letter reference number; is not used in security context
return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(16)) # nosec
Expand Down
2 changes: 1 addition & 1 deletion app/api_key/rest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import Blueprint, jsonify
from app import DATETIME_FORMAT
from app.constants import DATETIME_FORMAT
from app.dao.fact_notification_status_dao import (
get_total_notifications_sent_for_api_key,
get_last_send_for_api_key,
Expand Down
3 changes: 2 additions & 1 deletion app/callback/webhook_callback_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
from requests.api import request
from requests.exceptions import HTTPError, RequestException

from app import statsd_client, HTTP_TIMEOUT
from app import statsd_client
from app.callback.service_callback_strategy_interface import ServiceCallbackStrategyInterface
from app.celery.exceptions import NonRetryableException, RetryableException
from app.constants import HTTP_TIMEOUT
from app.dao.api_key_dao import get_unsigned_secret
from app.models import ServiceCallback

Expand Down
12 changes: 9 additions & 3 deletions app/celery/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from app.celery.service_callback_tasks import check_and_queue_callback_task
from app.dao.notifications_dao import get_notification_by_id, update_notification_status_by_id
from app.models import NOTIFICATION_DELIVERED, NOTIFICATION_PERMANENT_FAILURE, NOTIFICATION_TECHNICAL_FAILURE
from app.constants import NOTIFICATION_DELIVERED, NOTIFICATION_PERMANENT_FAILURE, NOTIFICATION_TECHNICAL_FAILURE


RETRIES_EXCEEDED = 'Retries exceeded'
Expand Down Expand Up @@ -94,16 +94,22 @@ def log_and_update_permanent_failure(

def log_notification_total_time(
notification_id: UUID,
created_at: datetime.datetime,
start_time: datetime.datetime,
status: str,
provider: str,
event_timestamp_in_ms: str | None = None,
) -> None:
"""Logs how long it took a notification to go from created to delivered"""
if status == NOTIFICATION_DELIVERED:
end_time = (
datetime.datetime.fromtimestamp(int(event_timestamp_in_ms) / 1000)
if event_timestamp_in_ms
else datetime.datetime.now()
)
current_app.logger.info(
'notification %s took %ss total time to reach %s status - %s',
notification_id,
(datetime.datetime.now() - created_at).total_seconds(),
(end_time - start_time).total_seconds(),
status,
provider,
)
10 changes: 6 additions & 4 deletions app/celery/contact_information_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
from app.celery.common import can_retry, handle_max_retries_exceeded
from app.celery.exceptions import AutoRetryException
from app.celery.service_callback_tasks import check_and_queue_callback_task
from app.constants import (
NOTIFICATION_PERMANENT_FAILURE,
NOTIFICATION_PREFERENCES_DECLINED,
EMAIL_TYPE,
SMS_TYPE,
)
from app.dao.notifications_dao import (
get_notification_by_id,
dao_update_notification,
update_notification_status_by_id,
)
from app.exceptions import NotificationTechnicalFailureException, NotificationPermanentFailureException
from app.models import (
NOTIFICATION_PERMANENT_FAILURE,
NOTIFICATION_PREFERENCES_DECLINED,
EMAIL_TYPE,
SMS_TYPE,
Notification,
RecipientIdentifier,
)
Expand Down
6 changes: 4 additions & 2 deletions app/celery/lookup_va_profile_id_task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from app.exceptions import NotificationTechnicalFailureException, NotificationPermanentFailureException
from app.models import RecipientIdentifier, NOTIFICATION_TECHNICAL_FAILURE, NOTIFICATION_PERMANENT_FAILURE
from flask import current_app
from notifications_utils.statsd_decorators import statsd

from app.constants import NOTIFICATION_TECHNICAL_FAILURE, NOTIFICATION_PERMANENT_FAILURE
from app.exceptions import NotificationTechnicalFailureException, NotificationPermanentFailureException
from app.models import RecipientIdentifier
from app import notify_celery
from app.celery.common import can_retry, handle_max_retries_exceeded
from app.celery.exceptions import AutoRetryException
Expand Down
3 changes: 2 additions & 1 deletion app/celery/nightly_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
from app import db, notify_celery, performance_platform_client, zendesk_client
from app.aws import s3
from app.celery.service_callback_tasks import check_and_queue_callback_task
from app.constants import EMAIL_TYPE, KEY_TYPE_NORMAL, LETTER_TYPE, NOTIFICATION_SENDING, SMS_TYPE
from app.dao.inbound_sms_dao import delete_inbound_sms_older_than_retention
from app.dao.jobs_dao import dao_get_jobs_older_than_data_retention, dao_archive_job
from app.dao.notifications_dao import (
dao_timeout_notifications,
delete_notifications_older_than_retention_by_type,
)
from app.exceptions import NotificationTechnicalFailureException
from app.models import Notification, NOTIFICATION_SENDING, EMAIL_TYPE, SMS_TYPE, LETTER_TYPE, KEY_TYPE_NORMAL
from app.models import Notification
from app.performance_platform import total_sent_notifications, processing_time
from app.cronitor import cronitor
from app.utils import get_local_timezone_midnight_in_utc
Expand Down
Loading