mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
Removed unused code in services_dao, which led to looking some of the queries.
By removing the join to services for the fetch_stats_by_date_range_for_all_services and dao_fetch_todays_stats_for_all_services queries we get a 30% and 25% performance improvement.
This commit is contained in:
@@ -233,8 +233,6 @@ def get_notifications_for_job(service_id, job_id, filter_dict=None, page=1, page
|
|||||||
|
|
||||||
@statsd(namespace="dao")
|
@statsd(namespace="dao")
|
||||||
def get_notification_billable_unit_count_per_month(service_id, year):
|
def get_notification_billable_unit_count_per_month(service_id, year):
|
||||||
start, end = get_financial_year(year)
|
|
||||||
|
|
||||||
month = get_london_month_from_utc_column(NotificationHistory.created_at)
|
month = get_london_month_from_utc_column(NotificationHistory.created_at)
|
||||||
|
|
||||||
notifications = db.session.query(
|
notifications = db.session.query(
|
||||||
|
|||||||
@@ -226,9 +226,6 @@ def _stats_for_service_query(service_id):
|
|||||||
|
|
||||||
@statsd(namespace="dao")
|
@statsd(namespace="dao")
|
||||||
def dao_fetch_monthly_historical_stats_for_service(service_id, year):
|
def dao_fetch_monthly_historical_stats_for_service(service_id, year):
|
||||||
monday_of_notification_week = func.date_trunc('week', NotificationHistory.created_at).label('week_start')
|
|
||||||
start, end = get_financial_year(year)
|
|
||||||
|
|
||||||
month = get_london_month_from_utc_column(NotificationHistory.created_at)
|
month = get_london_month_from_utc_column(NotificationHistory.created_at)
|
||||||
|
|
||||||
rows = db.session.query(
|
rows = db.session.query(
|
||||||
@@ -275,10 +272,6 @@ def dao_fetch_todays_stats_for_all_services(include_from_test_key=True):
|
|||||||
Notification.status,
|
Notification.status,
|
||||||
Notification.service_id,
|
Notification.service_id,
|
||||||
func.count(Notification.id).label('count')
|
func.count(Notification.id).label('count')
|
||||||
).select_from(
|
|
||||||
Service
|
|
||||||
).join(
|
|
||||||
Notification
|
|
||||||
).filter(
|
).filter(
|
||||||
func.date(Notification.created_at) == date.today()
|
func.date(Notification.created_at) == date.today()
|
||||||
).group_by(
|
).group_by(
|
||||||
@@ -302,10 +295,6 @@ def fetch_stats_by_date_range_for_all_services(start_date, end_date, include_fro
|
|||||||
NotificationHistory.status,
|
NotificationHistory.status,
|
||||||
NotificationHistory.service_id,
|
NotificationHistory.service_id,
|
||||||
func.count(NotificationHistory.id).label('count')
|
func.count(NotificationHistory.id).label('count')
|
||||||
).select_from(
|
|
||||||
Service
|
|
||||||
).join(
|
|
||||||
NotificationHistory
|
|
||||||
).filter(
|
).filter(
|
||||||
func.date(NotificationHistory.created_at) >= start_date,
|
func.date(NotificationHistory.created_at) >= start_date,
|
||||||
func.date(NotificationHistory.created_at) <= end_date
|
func.date(NotificationHistory.created_at) <= end_date
|
||||||
|
|||||||
Reference in New Issue
Block a user