🚧 提速测试

This commit is contained in:
Chenric 2024-08-02 23:36:58 +08:00
parent 84d4096af1
commit 75dd80155b
3 changed files with 28 additions and 10 deletions

View File

@ -52,6 +52,7 @@ from .utils import (
msg_counter, msg_counter,
get_rank_image, get_rank_image,
persist_id2user_id, persist_id2user_id,
# get_user_info2,
) )
__plugin_meta__ = PluginMetadata( __plugin_meta__ = PluginMetadata(
@ -193,6 +194,8 @@ async def _group_message(
except ValueError: except ValueError:
await rank_cmd.finish("请输入正确的日期,不然我没法理解呢!") await rank_cmd.finish("请输入正确的日期,不然我没法理解呢!")
logger.debug(f"命令解析花费时间:{t.time() - t1}")
@rank_cmd.got( @rank_cmd.got(
"start", "start",
@ -213,6 +216,7 @@ async def handle_rank(
start: datetime = Arg(), start: datetime = Arg(),
stop: datetime = Arg(), stop: datetime = Arg(),
): ):
t1 = t.time()
if id := state["group_id"]: if id := state["group_id"]:
id = str(id) id = str(id)
logger.debug(f"group_id: {id}") logger.debug(f"group_id: {id}")
@ -223,6 +227,9 @@ async def handle_rank(
if not id: if not id:
await saa.Text("没有指定群哦").finish() await saa.Text("没有指定群哦").finish()
logger.debug(f"所属群聊解析花费时间:{t.time() - t1}")
t1 = t.time()
messages = await get_message_records( messages = await get_message_records(
id2s=[id], id2s=[id],
id_type=SessionIdType.GROUP, id_type=SessionIdType.GROUP,
@ -234,10 +241,15 @@ async def handle_rank(
exclude_id1s=plugin_config.excluded_people, exclude_id1s=plugin_config.excluded_people,
) )
logger.debug(f"获取群聊消息花费时间:{t.time() - t1}")
t1 = t.time()
if not messages: if not messages:
await saa.Text("明明这个时间段都没有人说话怎么会有话痨榜呢?").finish() await saa.Text("明明这个时间段都没有人说话怎么会有话痨榜呢?").finish()
rank = got_rank(msg_counter(messages)) rank = got_rank(msg_counter(messages))
logger.debug(f"群聊消息计数花费时间:{t.time() - t1}")
t1 = t.time()
logger.debug(rank) logger.debug(rank)
rank2: List[UserRankInfo] = [] rank2: List[UserRankInfo] = []
ids = await persist_id2user_id([int(i[0]) for i in rank]) ids = await persist_id2user_id([int(i[0]) for i in rank])
@ -292,6 +304,8 @@ async def handle_rank(
string += str_example string += str_example
msg = saa.Text(string) msg = saa.Text(string)
logger.debug(f"群聊消息渲染文字花费时间:{t.time() - t1}")
t1 = t.time()
if plugin_config.visualization: if plugin_config.visualization:
image = await get_rank_image(rank2) image = await get_rank_image(rank2)
@ -302,11 +316,13 @@ async def handle_rank(
suffix = saa.Text(plugin_config.string_suffix.format(timecost=timecost)) suffix = saa.Text(plugin_config.string_suffix.format(timecost=timecost))
msg += suffix msg += suffix
logger.debug(f"群聊消息渲染图片花费时间:{t.time() - t1}")
await msg.finish(reply=True) await msg.finish(reply=True)
@scheduler.scheduled_job( # @scheduler.scheduled_job(
"dialectlist", day="*/2", id="xxx", args=[1], kwargs={"arg2": 2} # "dialectlist", day="*/2", id="xxx", args=[1], kwargs={"arg2": 2}
) # )
async def __(): # async def __():
pass # pass

View File

@ -1,4 +1,5 @@
from typing import Union from typing import Union
from pydantic import BaseModel
from nonebot_plugin_orm import Model from nonebot_plugin_orm import Model
from nonebot_plugin_userinfo import UserInfo from nonebot_plugin_userinfo import UserInfo
@ -10,6 +11,7 @@ class UserRankInfo(UserInfo):
user_index: Union[int, str] user_index: Union[int, str]
user_avatar_bytes: bytes user_avatar_bytes: bytes
class MsgCountDayData(BaseModel):
class MsgData(Model): user_id:str
__table_args__ = {"extend_existing": True} # class MsgCountData(Model):
# __tablename__ = 'dialectlist_msg_data'

View File

@ -1,5 +1,5 @@
body { body {
background-image: url('https://image.anosu.top/pixiv/direct?size=regular'); background-image: url('https://api.yimian.xyz/img');
background-attachment: scroll; background-attachment: scroll;
margin: 0; margin: 0;
background-size: cover; background-size: cover;