mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
try by not closing session
This commit is contained in:
@@ -3,7 +3,7 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from sqlalchemy import Float, cast, select
|
from sqlalchemy import Float, cast, select
|
||||||
from sqlalchemy.orm import Session, joinedload
|
from sqlalchemy.orm import joinedload
|
||||||
from sqlalchemy.sql.expression import and_, asc, case, func
|
from sqlalchemy.sql.expression import and_, asc, case, func
|
||||||
|
|
||||||
from app import db
|
from app import db
|
||||||
@@ -51,7 +51,7 @@ from app.utils import (
|
|||||||
|
|
||||||
|
|
||||||
def dao_fetch_all_services(only_active=False):
|
def dao_fetch_all_services(only_active=False):
|
||||||
with Session(db.engine) as session:
|
|
||||||
stmt = (
|
stmt = (
|
||||||
select(Service)
|
select(Service)
|
||||||
.order_by(asc(Service.created_at))
|
.order_by(asc(Service.created_at))
|
||||||
@@ -64,7 +64,7 @@ def dao_fetch_all_services(only_active=False):
|
|||||||
.order_by(asc(Service.created_at))
|
.order_by(asc(Service.created_at))
|
||||||
.options(joinedload(Service.users))
|
.options(joinedload(Service.users))
|
||||||
)
|
)
|
||||||
result = session.execute(stmt).unique()
|
result = db.session.execute(stmt).unique()
|
||||||
return result.scalars().all()
|
return result.scalars().all()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user