Find services by partial name

This commit is contained in:
Pea Tyczynska
2019-08-13 17:20:37 +01:00
parent 515d6602c1
commit 52a1316a7e
4 changed files with 65 additions and 2 deletions

View File

@@ -46,7 +46,7 @@ from app.models import (
SMS_TYPE,
LETTER_TYPE,
)
from app.utils import email_address_is_nhs, get_london_midnight_in_utc, midnight_n_days_ago
from app.utils import email_address_is_nhs, escape_special_characters, get_london_midnight_in_utc, midnight_n_days_ago
DEFAULT_SERVICE_PERMISSIONS = [
SMS_TYPE,
@@ -69,6 +69,11 @@ def dao_fetch_all_services(only_active=False):
return query.all()
def get_services_by_partial_name(service_name):
service_name = escape_special_characters(service_name)
return Service.query.filter(Service.name.ilike("%{}%".format(service_name))).all()
def dao_count_live_services():
return Service.query.filter_by(
active=True,