From 68bcfe8f8ce94784468a325226c307d39d66ec1b Mon Sep 17 00:00:00 2001 From: Jumana B Date: Fri, 2 Feb 2024 10:04:59 -0500 Subject: [PATCH] Reverting notification history (#2102) --- app/dao/fact_notification_status_dao.py | 9 +------ .../dao/test_fact_notification_status_dao.py | 26 +++++++++---------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/app/dao/fact_notification_status_dao.py b/app/dao/fact_notification_status_dao.py index f210622a2b..86c2404708 100644 --- a/app/dao/fact_notification_status_dao.py +++ b/app/dao/fact_notification_status_dao.py @@ -362,14 +362,7 @@ def get_last_send_for_api_key(api_key_id): .filter(Notification.api_key_id == api_key_id) .all() ) - if not notification_table[0][0]: - notification_table = ( - db.session.query(func.max(NotificationHistory.created_at).label("last_notification_created")) - .filter(NotificationHistory.api_key_id == api_key_id) - .all() - ) - notification_table = [] if notification_table[0][0] is None else notification_table - return notification_table + return [] if notification_table[0][0] is None else notification_table return api_key_table diff --git a/tests/app/dao/test_fact_notification_status_dao.py b/tests/app/dao/test_fact_notification_status_dao.py index 70b2c4ac50..85cd078d91 100644 --- a/tests/app/dao/test_fact_notification_status_dao.py +++ b/tests/app/dao/test_fact_notification_status_dao.py @@ -423,24 +423,24 @@ def test_get_api_key_ranked_by_notifications_created(notify_db_session): assert int(second_place[8]) == sms_sends -def test_last_used_for_api_key(notify_db_session): - service = create_service(service_name="Service 1") - api_key_1 = create_api_key(service, key_type=KEY_TYPE_NORMAL, key_name="Key 1") - api_key_2 = create_api_key(service, key_type=KEY_TYPE_NORMAL, key_name="Key 2") - api_key_3 = create_api_key(service, key_type=KEY_TYPE_NORMAL, key_name="Key 3") - template_email = create_template(service=service, template_type="email") - create_notification_history(template=template_email, api_key=api_key_1, created_at="2022-03-04") - save_notification(create_notification(template=template_email, api_key=api_key_1, created_at="2022-03-05")) +# def test_last_used_for_api_key(notify_db_session): +# service = create_service(service_name="Service 1") +# api_key_1 = create_api_key(service, key_type=KEY_TYPE_NORMAL, key_name="Key 1") +# api_key_2 = create_api_key(service, key_type=KEY_TYPE_NORMAL, key_name="Key 2") +# api_key_3 = create_api_key(service, key_type=KEY_TYPE_NORMAL, key_name="Key 3") +# template_email = create_template(service=service, template_type="email") +# create_notification_history(template=template_email, api_key=api_key_1, created_at="2022-03-04") +# save_notification(create_notification(template=template_email, api_key=api_key_1, created_at="2022-03-05")) - assert (get_last_send_for_api_key(str(api_key_1.id))[0][0]).strftime("%Y-%m-%d") == "2022-03-05" +# assert (get_last_send_for_api_key(str(api_key_1.id))[0][0]).strftime("%Y-%m-%d") == "2022-03-05" - save_notification(create_notification(template=template_email, api_key=api_key_2, created_at="2022-03-06")) +# save_notification(create_notification(template=template_email, api_key=api_key_2, created_at="2022-03-06")) - assert (get_last_send_for_api_key(str(api_key_2.id))[0][0]).strftime("%Y-%m-%d") == "2022-03-06" +# assert (get_last_send_for_api_key(str(api_key_2.id))[0][0]).strftime("%Y-%m-%d") == "2022-03-06" - create_notification_history(template=template_email, api_key=api_key_3, created_at="2022-03-07") +# create_notification_history(template=template_email, api_key=api_key_3, created_at="2022-03-07") - assert (get_last_send_for_api_key(str(api_key_3.id))[0][0]).strftime("%Y-%m-%d") == "2022-03-07" +# assert (get_last_send_for_api_key(str(api_key_3.id))[0][0]).strftime("%Y-%m-%d") == "2022-03-07" @pytest.mark.parametrize(