mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 22:42:28 -05:00
Merge pull request #897 from alphagov/fix-slow-delete
remove slow join from template-last-use query
This commit is contained in:
@@ -124,10 +124,10 @@ def dao_get_template_usage(service_id, limit_days=None):
|
||||
def dao_get_last_template_usage(template_id):
|
||||
return NotificationHistory.query.filter(
|
||||
NotificationHistory.template_id == template_id,
|
||||
NotificationHistory.key_type != KEY_TYPE_TEST) \
|
||||
.join(Template) \
|
||||
.order_by(desc(NotificationHistory.created_at)) \
|
||||
.first()
|
||||
NotificationHistory.key_type != KEY_TYPE_TEST
|
||||
).order_by(
|
||||
desc(NotificationHistory.created_at)
|
||||
).first()
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
|
||||
Reference in New Issue
Block a user