From ed5e3b3d9c90b88249833e67a5d2d1ba68c797ae Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Wed, 26 May 2021 13:47:53 +0100 Subject: [PATCH] Removed the end date in the filter. It's always going to be in the future anyway. After some analysis the query does perform better without it. I'll make a note to update other queries where we get todays notification data to remove the end date filter in a separate PR. --- app/dao/services_dao.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/dao/services_dao.py b/app/dao/services_dao.py index d28267dae..85449f2fb 100644 --- a/app/dao/services_dao.py +++ b/app/dao/services_dao.py @@ -431,10 +431,8 @@ def dao_fetch_stats_for_service(service_id, limit_days): def dao_fetch_todays_stats_for_service(service_id): today = date.today() start_date = get_london_midnight_in_utc(today) - end_date = get_london_midnight_in_utc(today + timedelta(days=1)) return _stats_for_service_query(service_id).filter( - Notification.created_at >= start_date, - Notification.created_at < end_date + Notification.created_at >= start_date ).all()