auth and minor fixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
from sqlalchemy.orm import selectinload
|
||||
from orm.user import User
|
||||
from base.orm import local_session
|
||||
|
||||
|
||||
class UserStorage:
|
||||
@@ -20,9 +21,15 @@ class UserStorage:
|
||||
|
||||
@staticmethod
|
||||
async def get_user(id):
|
||||
self = UserStorage
|
||||
async with self.lock:
|
||||
return self.users.get(id)
|
||||
with local_session() as session:
|
||||
user = (
|
||||
session.query(User)
|
||||
.options(selectinload(User.roles), selectinload(User.ratings))
|
||||
.filter(User.id == id)
|
||||
.one()
|
||||
)
|
||||
|
||||
return user
|
||||
|
||||
@staticmethod
|
||||
async def get_all_users():
|
||||
|
@@ -36,7 +36,8 @@ class ReactedStorage:
|
||||
@staticmethod
|
||||
async def get_shout_stat(slug):
|
||||
return {
|
||||
"viewed": await ViewedStorage.get_shout(slug),
|
||||
# TODO
|
||||
"viewed": 0, # await ViewedStorage.get_shout(slug),
|
||||
"reacted": len(await ReactedStorage.get_shout(slug)),
|
||||
"commented": len(await ReactedStorage.get_comments(slug)),
|
||||
"rating": await ReactedStorage.get_rating(slug),
|
||||
|
Reference in New Issue
Block a user