mai2: add basic webui

This commit is contained in:
Kevin Trocolli
2024-06-09 03:05:57 -04:00
parent e7ddfcda2e
commit b4b8650acc
9 changed files with 813 additions and 2 deletions

View File

@@ -511,6 +511,11 @@ rival = Table(
)
class Mai2ProfileData(BaseData):
async def get_all_profile_versions(self, user_id: int) -> Optional[List[Row]]:
result = await self.execute(detail.select(detail.c.user == user_id))
if result:
return result.fetchall()
async def put_profile_detail(
self, user_id: int, version: int, detail_data: Dict, is_dx: bool = True
) -> Optional[Row]:
@@ -899,3 +904,14 @@ class Mai2ProfileData(BaseData):
result = await self.execute(rival.delete(and_(rival.c.user == user_id, rival.c.rival == rival_id)))
if not result:
self.logger.error(f"Failed to remove rival {rival_id} for user {user_id}!")
async def update_name(self, user_id: int, new_name: str) -> bool:
sql = detail.update(detail.c.user == user_id).values(
userName=new_name
)
result = await self.execute(sql)
if result is None:
self.logger.warning(f"Failed to set user {user_id} name to {new_name}")
return False
return True