From d2d5fa71ef620ef5242bd988c807e9f41ca81d58 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 18 Nov 2024 13:52:20 -0800 Subject: [PATCH] fix --- app/dao/fact_processing_time_dao.py | 9 +++++---- tests/app/dao/test_inbound_sms_dao.py | 7 ++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/dao/fact_processing_time_dao.py b/app/dao/fact_processing_time_dao.py index 2bab55072..a7783c9b8 100644 --- a/app/dao/fact_processing_time_dao.py +++ b/app/dao/fact_processing_time_dao.py @@ -1,3 +1,4 @@ +from sqlalchemy import select from sqlalchemy.dialects.postgresql import insert from sqlalchemy.sql.expression import case @@ -33,8 +34,8 @@ def insert_update_processing_time(processing_time): def get_processing_time_percentage_for_date_range(start_date, end_date): - query = ( - db.session.query( + stmt = ( + select( FactProcessingTime.local_date.cast(db.Text).label("date"), FactProcessingTime.messages_total, FactProcessingTime.messages_within_10_secs, @@ -52,11 +53,11 @@ def get_processing_time_percentage_for_date_range(start_date, end_date): (FactProcessingTime.messages_total == 0, 100.0), ).label("percentage"), ) - .filter( + .where( FactProcessingTime.local_date >= start_date, FactProcessingTime.local_date <= end_date, ) .order_by(FactProcessingTime.local_date) ) - return db.session.execute(query).scalars().all() + return db.session.execute(stmt).scalars().all() diff --git a/tests/app/dao/test_inbound_sms_dao.py b/tests/app/dao/test_inbound_sms_dao.py index 17bbd4afc..1c9b039fa 100644 --- a/tests/app/dao/test_inbound_sms_dao.py +++ b/tests/app/dao/test_inbound_sms_dao.py @@ -320,9 +320,7 @@ def test_dao_get_paginated_inbound_sms_for_service_for_public_api_older_than_ret ) expected_inbound_sms = reversed_inbound_sms[2:] - print(f"EXPECTED {expected_inbound_sms}") - print(f"ACTUAL {inbound_from_db.items}") - assert expected_inbound_sms == inbound_from_db + assert expected_inbound_sms == inbound_from_db.items def test_dao_get_paginated_inbound_sms_for_service_for_public_api_older_than_end_returns_empty_list( @@ -339,8 +337,7 @@ def test_dao_get_paginated_inbound_sms_for_service_for_public_api_older_than_end inbound_from_db = dao_get_paginated_inbound_sms_for_service_for_public_api( sample_service.id, older_than=reversed_inbound_sms[1].id, page_size=2 ) - print(f"HERE IS INBOUND FROM DB {inbound_from_db.items}") - assert inbound_from_db.has_next is False + assert inbound_from_db.items == [] def test_most_recent_inbound_sms_only_returns_most_recent_for_each_number(