From aad562bb880ca9892c521ff5038f0e520ae86867 Mon Sep 17 00:00:00 2001 From: alexjanousekGSA Date: Mon, 24 Feb 2025 12:35:25 -0500 Subject: [PATCH] Fixed flake errors --- app/dao/services_dao.py | 2 +- app/service/rest.py | 12 +----------- tests/app/dao/test_date_utils.py | 2 ++ 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/dao/services_dao.py b/app/dao/services_dao.py index 57abb0a97..fc973fecd 100644 --- a/app/dao/services_dao.py +++ b/app/dao/services_dao.py @@ -526,6 +526,7 @@ def dao_fetch_stats_for_service_from_days(service_id, start_date, end_date): return total_notifications, data + def dao_fetch_stats_for_service_from_hours(service_id, start_date, end_date): start_date = get_midnight_in_utc(start_date) end_date = get_midnight_in_utc(end_date + timedelta(days=1)) @@ -588,7 +589,6 @@ def dao_fetch_stats_for_service_from_hours(service_id, start_date, end_date): return total_notifications, data - def dao_fetch_stats_for_service_from_days_for_user( service_id, start_date, end_date, user_id ): diff --git a/app/service/rest.py b/app/service/rest.py index a67344a54..57d963424 100644 --- a/app/service/rest.py +++ b/app/service/rest.py @@ -240,12 +240,6 @@ def get_service_statistics_for_specific_days(service_id, start, days=1): end_date, ) - # Debug logs: Raw output from DB query - print(f"🚀 Fetching stats for service {service_id} from {start_date} to {end_date}") - print(f"🔍 Total Notifications: {total_notifications}") - print(f"📝 Raw Query Results: {results}") - - # Convert days to hours (since 1 day = 24 hours) hours = days * 24 # Process data using new hourly stats function @@ -256,11 +250,7 @@ def get_service_statistics_for_specific_days(service_id, start, days=1): total_notifications=total_notifications, ) - # Debug log: Final processed stats - print(f"✅ Processed Stats: {stats}") - - return stats # ✅ Make sure to return stats - + return stats @service_blueprint.route( diff --git a/tests/app/dao/test_date_utils.py b/tests/app/dao/test_date_utils.py index aa46dec84..b25281dfc 100644 --- a/tests/app/dao/test_date_utils.py +++ b/tests/app/dao/test_date_utils.py @@ -92,6 +92,7 @@ def test_generate_hourly_range_with_end_date(): assert result == expected, f"Expected {expected}, but got {result}" + def test_generate_hourly_range_with_hours(): start_date = datetime(2025, 2, 18, 12, 0) result = list(generate_hourly_range(start_date, hours=3)) @@ -104,6 +105,7 @@ def test_generate_hourly_range_with_hours(): assert result == expected, f"Expected {expected}, but got {result}" + def test_generate_hourly_range_with_zero_hours(): start_date = datetime(2025, 2, 18, 12, 0) result = list(generate_hourly_range(start_date, hours=0))