[Enhance] Add background task

- Add background task module for log database
- Update some data for Arcaea v4.4.4
This commit is contained in:
Lost-MSth
2023-04-28 14:27:11 +08:00
parent 8efd11cd02
commit 880b66a995
5 changed files with 83 additions and 6 deletions

View File

@@ -2,12 +2,13 @@ from base64 import b64encode
from os import urandom
from time import time
from .bgtask import logdb_execute
from .constant import Constant
from .course import CoursePlay
from .error import NoData, StaminaNotEnough
from .item import ItemCore
from .song import Chart
from .sql import Connect, Query, Sql
from .sql import Query, Sql
from .util import md5
from .world import WorldPlay
@@ -427,9 +428,8 @@ class UserPlay(UserScore):
def record_score(self) -> None:
'''向log数据库记录分数请注意列名不同'''
with Connect(Constant.SQLITE_LOG_DATABASE_PATH) as c2:
c2.execute('''insert into user_score values(?,?,?,?,?,?,?,?,?,?,?,?,?)''', (self.user.user_id, self.song.song_id, self.song.difficulty, self.time_played,
self.score, self.shiny_perfect_count, self.perfect_count, self.near_count, self.miss_count, self.health, self.modifier, self.clear_type, self.rating))
logdb_execute('''insert into user_score values(?,?,?,?,?,?,?,?,?,?,?,?,?)''', (self.user.user_id, self.song.song_id, self.song.difficulty, self.time_played,
self.score, self.shiny_perfect_count, self.perfect_count, self.near_count, self.miss_count, self.health, self.modifier, self.clear_type, self.rating))
def upload_score(self) -> None:
'''上传分数包括user的recent更新best更新recent30更新世界模式计算'''
@@ -477,6 +477,7 @@ class UserPlay(UserScore):
self.user.rating_ptt = int(self.ptt.value * 100)
self.c.execute('''update user set rating_ptt = :a where user_id = :b''', {
'a': self.user.rating_ptt, 'b': self.user.user_id})
# TODO: PTT log
# 世界模式判断
if self.is_world_mode: