diff --git a/app/dao/services_dao.py b/app/dao/services_dao.py index 19755edfe..9ac63327f 100644 --- a/app/dao/services_dao.py +++ b/app/dao/services_dao.py @@ -51,14 +51,22 @@ from app.utils import ( def dao_fetch_all_services(only_active=False): - query = Service.query.order_by(asc(Service.created_at)).options( - joinedload(Service.users) + + stmt = ( + select(Service) + .order_by(asc(Service.created_at)) + .options(joinedload(Service.users)) ) - if only_active: - query = query.filter(Service.active) - - return query.all() + stmt = ( + select(Service) + .where(Service.active is True) + .order_by(asc(Service.created_at)) + .options(joinedload(Service.users)) + ) + if only_active: + stmt = stmt.filter(Service.active) + return db.session.execute(stmt).scalars().all() def get_services_by_partial_name(service_name): diff --git a/app/service_invite/rest.py b/app/service_invite/rest.py index f6d9627da..5728b3ed5 100644 --- a/app/service_invite/rest.py +++ b/app/service_invite/rest.py @@ -86,7 +86,7 @@ def _create_service_invite(invited_user, invite_link_host): redis_store.set( f"email-personalisation-{saved_notification.id}", json.dumps(personalisation), - ex=2*24*60*60, + ex=2 * 24 * 60 * 60, ) send_notification_to_queue(saved_notification, queue=QueueNames.NOTIFY)