mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Fixed flake errors
This commit is contained in:
@@ -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
|
||||
):
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user