Fixed flake errors

This commit is contained in:
alexjanousekGSA
2025-02-24 12:35:25 -05:00
parent 6c8b3dbb63
commit aad562bb88
3 changed files with 4 additions and 12 deletions

View File

@@ -526,6 +526,7 @@ def dao_fetch_stats_for_service_from_days(service_id, start_date, end_date):
return total_notifications, data return total_notifications, data
def dao_fetch_stats_for_service_from_hours(service_id, start_date, end_date): def dao_fetch_stats_for_service_from_hours(service_id, start_date, end_date):
start_date = get_midnight_in_utc(start_date) start_date = get_midnight_in_utc(start_date)
end_date = get_midnight_in_utc(end_date + timedelta(days=1)) 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 return total_notifications, data
def dao_fetch_stats_for_service_from_days_for_user( def dao_fetch_stats_for_service_from_days_for_user(
service_id, start_date, end_date, user_id service_id, start_date, end_date, user_id
): ):

View File

@@ -240,12 +240,6 @@ def get_service_statistics_for_specific_days(service_id, start, days=1):
end_date, 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 hours = days * 24
# Process data using new hourly stats function # 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, total_notifications=total_notifications,
) )
# Debug log: Final processed stats return stats
print(f"✅ Processed Stats: {stats}")
return stats # ✅ Make sure to return stats
@service_blueprint.route( @service_blueprint.route(

View File

@@ -92,6 +92,7 @@ def test_generate_hourly_range_with_end_date():
assert result == expected, f"Expected {expected}, but got {result}" assert result == expected, f"Expected {expected}, but got {result}"
def test_generate_hourly_range_with_hours(): def test_generate_hourly_range_with_hours():
start_date = datetime(2025, 2, 18, 12, 0) start_date = datetime(2025, 2, 18, 12, 0)
result = list(generate_hourly_range(start_date, hours=3)) 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}" assert result == expected, f"Expected {expected}, but got {result}"
def test_generate_hourly_range_with_zero_hours(): def test_generate_hourly_range_with_zero_hours():
start_date = datetime(2025, 2, 18, 12, 0) start_date = datetime(2025, 2, 18, 12, 0)
result = list(generate_hourly_range(start_date, hours=0)) result = list(generate_hourly_range(start_date, hours=0))