try by not closing session

This commit is contained in:
Kenneth Kehl
2024-10-08 13:29:42 -07:00
parent 49fd034b34
commit b94b2b7b84

View File

@@ -52,20 +52,15 @@ from app.utils import (
def dao_fetch_all_services(only_active=False): def dao_fetch_all_services(only_active=False):
stmt = ( stmt = select(Service)
select(Service)
.order_by(asc(Service.created_at))
.options(joinedload(Service.users))
)
if only_active: if only_active:
stmt = ( stmt = stmt.where(Service.active)
select(Service)
.where(Service.active is True) stmt = stmt.order_by(asc(Service.created_at)).options(joinedload(Service.users))
.order_by(asc(Service.created_at))
.options(joinedload(Service.users)) result = db.session.execute(stmt)
) return result.unique().scalars().one()
result = db.session.execute(stmt).unique()
return result.scalars().all()
def get_services_by_partial_name(service_name): def get_services_by_partial_name(service_name):