New endpoint to search by "to" field of the notification.

The query ignores case and spaces.
This commit is contained in:
Rebecca Law
2017-05-05 14:12:50 +01:00
parent 42032f871f
commit d252dc8976
4 changed files with 90 additions and 1 deletions

View File

@@ -456,3 +456,10 @@ def dao_update_notifications_sent_to_dvla(job_id, provider):
{'status': NOTIFICATION_SENDING, "sent_by": provider, "sent_at": now, "updated_at": now})
return updated_count
@statsd(namespace="dao")
def dao_get_notifications_by_to_field(service_id, search_term):
return Notification.query.filter(
Notification.service_id == service_id,
func.replace(func.lower(Notification.to), " ", "") == search_term.lower().replace(" ", "")).all()