diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index 4ad50c111..b5690e535 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -103,8 +103,19 @@ def dao_create_notification(notification): orig_time = notification.created_at now_time = utc_now() - print(hilite(f"original time: {orig_time} - {type(orig_time)} \n now time: {now_time} - {type(now_time)}")) - diff_time = now_time - datetime.strptime(orig_time, "%Y-%m-%D-%H-%M-%S") + print( + hilite( + f"original time: {orig_time} - {type(orig_time)} \n now time: {now_time} - {type(now_time)}" + ) + ) + try: + diff_time = now_time - orig_time + except TypeError: + try: + orig_time = datetime.strptime(orig_time, "%Y-%m-%dT%H:%M:%S.%fZ") + except ValueError: + orig_time = datetime.strptime(orig_time, "%Y-%m-%d") + diff_time = now_time - orig_time current_app.logger.error( f"dao_create_notification orig created at: {orig_time} and now created at: {now_time}" ) diff --git a/tests/app/celery/test_reporting_tasks.py b/tests/app/celery/test_reporting_tasks.py index 124038d48..952c65e09 100644 --- a/tests/app/celery/test_reporting_tasks.py +++ b/tests/app/celery/test_reporting_tasks.py @@ -103,7 +103,6 @@ def test_create_nightly_notification_status_triggers_relevant_tasks( mock_celery = mocker.patch( "app.celery.reporting_tasks.create_nightly_notification_status_for_service_and_day" ).apply_async - for notification_type in NotificationType: template = create_template(sample_service, template_type=notification_type) create_notification(template=template, created_at=notification_date)