Merge remote-tracking branch 'dokku-staging/main' into prepare-comments-optimization-dokku-staging

This commit is contained in:
Igor Lobanov
2022-11-24 18:36:45 +01:00
24 changed files with 202 additions and 135 deletions

View File

@@ -1,5 +1,5 @@
import asyncio
from sqlalchemy.orm import selectinload
from sqlalchemy.orm import selectinload, exc
from orm.user import User
from base.orm import local_session
@@ -22,16 +22,18 @@ class UserStorage:
@staticmethod
async def get_user(id):
with local_session() as session:
user = (
session.query(User).options(
selectinload(User.roles),
selectinload(User.ratings)
).filter(
User.id == id
).one()
)
return user
try:
user = (
session.query(User).options(
selectinload(User.roles),
selectinload(User.ratings)
).filter(
User.id == id
).one()
)
return user
except exc.NoResultFound:
return None
@staticmethod
async def get_all_users():