Skip to content

Commit

Permalink
✨ 利用gs_cache()进行ba查询ba学生排名结果缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
KimigaiiWuyi committed Apr 20, 2024
1 parent c063595 commit 954e0e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions BlueArchiveUID/bauid_guide/get_char.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

async def get_hehedi_char_img(name: str) -> Optional[str]:
name = alias_to_char_name(name)
return await _get_hehedi_char_img(name)


async def _get_hehedi_char_img(name: str) -> Optional[str]:
path = HEHEDI_CHAR_GUIDE_PATH / f'{name}.jpg'
if path.exists():
return await convert_img(path)
Expand Down
2 changes: 2 additions & 0 deletions BlueArchiveUID/bauid_info/draw_user_info_pic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from PIL import Image, ImageDraw
from gsuid_core.models import Event
from gsuid_core.utils.cache import gs_cache
from gsuid_core.utils.image.convert import convert_img
from gsuid_core.utils.fonts.fonts import core_font as cf
from gsuid_core.utils.image.image_tools import (
Expand Down Expand Up @@ -158,6 +159,7 @@ def get_bg(w: int, h: int):
return img


@gs_cache()
async def draw_user_info_img(
_fcode: str, ev: Event, user_id: str
) -> Union[str, bytes]:
Expand Down
6 changes: 6 additions & 0 deletions BlueArchiveUID/bauid_ranklist/draw_rank_pic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Union

from PIL import Image, ImageDraw
from gsuid_core.utils.cache import gs_cache
from gsuid_core.utils.image.convert import convert_img
from gsuid_core.utils.fonts.fonts import core_font as cf

Expand All @@ -27,6 +28,11 @@ def get_color(rank_key: int):

async def draw_rank_pic(student: str) -> Union[bytes, str]:
student_id = student_name_to_id(student)
return await _draw_rank_pic(student_id)


@gs_cache()
async def _draw_rank_pic(student_id: str) -> Union[bytes, str]:
if student_id == '9999':
return '要查询的角色不存在或别名未收录, 请尝试使用完整名字。'

Expand Down

0 comments on commit 954e0e5

Please sign in to comment.