🐛 数据统计中, 昨日的数据会被计入当天

This commit is contained in:
KimigaiiWuyi 2025-03-11 09:02:11 +08:00
parent d011e5d8f9
commit 115e397ab7
2 changed files with 7 additions and 7 deletions

View File

@ -6,11 +6,10 @@ import gsuid_core.global_val as gv
from gsuid_core.models import Event
from gsuid_core.aps import scheduler
from gsuid_core.logger import logger
from gsuid_core.global_val import save_all_global_val
from gsuid_core.status.draw_status import draw_status
from gsuid_core.utils.database.models import CoreUser, CoreGroup
from .command_global_val import save_global_val
sv_core_status = SV('Core状态', pm=0)
template = '''收:{}
@ -40,9 +39,10 @@ async def count_group_user():
@scheduler.scheduled_job('cron', hour='0', minute='0')
async def scheduled_save_global_val():
global bot_val
await save_global_val()
await save_all_global_val(1)
gv.bot_val = {}
await count_group_user()
logger.success('[早柚核心] 状态已保存!')
@sv_core_status.on_fullmatch(

View File

@ -150,11 +150,11 @@ async def load_all_global_val():
bot_val[bot_id_path.stem][self_id_path.stem] = data
async def save_all_global_val():
async def save_all_global_val(day: int = 0):
global bot_val
for bot_id in bot_val:
for bot_self_id in bot_val[bot_id]:
await save_global_val(bot_id, bot_self_id)
await save_global_val(bot_id, bot_self_id, day)
async def get_global_val(
@ -182,13 +182,13 @@ async def get_sp_val(bot_id: str, bot_self_id: str, sp: str) -> PlatformVal:
return data
async def save_global_val(bot_id: str, bot_self_id: str):
async def save_global_val(bot_id: str, bot_self_id: str, day: int = 0):
if not bot_self_id:
return
local_val = get_platform_val(bot_id, bot_self_id)
today = datetime.date.today()
today = datetime.date.today() - datetime.timedelta(days=day)
date_format = today.strftime("%Y_%d_%b")
path = global_val_path / bot_id / bot_self_id