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

27 lines
1 KiB
Python
Raw Normal View History

2020-06-28 21:52:20 +00:00
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:
2020-08-29 22:57:09 +00:00
"""Get Royalpack information about all users."""
users: typing.List[rbt.User] = await ru.asyncify(
data.session.query(self.alchemy.get(rbt.User)).all
)
2020-06-28 21:52:20 +00:00
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],
2020-08-29 18:36:58 +00:00
"osu": [osu.json() for osu in user.osu],
2020-09-20 15:45:57 +00:00
"trivia": user.trivia_score.json() if user.trivia_score is not None else None,
2020-08-29 22:57:09 +00:00
} for user in users if "member" in user.roles]