1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-30 15:04:18 +00:00
royalnet/royalpack/stars/api_user_ryg_list.py
2020-06-28 23:52:20 +02:00

23 lines
954 B
Python

from starlette.responses import *
import royalnet.utils as ru
import royalnet.backpack.tables as rbt
import royalnet.constellation.api as rca
class ApiUserRygListStar(rca.ApiStar):
path = "/api/user/ryg/list/v1"
tags = ["user"]
@rca.magic
async def get(self, data: rca.ApiData) -> ru.JSON:
"""Get Royalpack information about all user."""
users: typing.List[rbt.User] = await ru.asyncify(data.session.query(self.alchemy.get(rbt.User)).all)
return [{
**user.json(),
"bio": user.bio.json() if user.bio is not None else None,
"fiorygi": user.fiorygi.fiorygi if user.fiorygi is not None else None,
"steam": [steam.json() for steam in user.steam],
"leagueoflegends": [leagueoflegends.json() for leagueoflegends in user.leagueoflegends],
"trivia": user.trivia_score.json() if user.trivia_score is not None else None
} for user in users]