mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-07 16:27:26 +08:00
[Enhance] PTT record & log DB cleaner
- Add support for recording users' potential each day - Add a log database cleaner tool - A small change: `/user/<user_id> PUT` API can ban user now.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import os
|
||||
import sqlite3
|
||||
import traceback
|
||||
from atexit import register
|
||||
|
||||
from .constant import Constant
|
||||
from .config_manager import Config
|
||||
from .constant import ARCAEA_LOG_DATBASE_VERSION, Constant
|
||||
from .error import ArcError, InputError
|
||||
|
||||
|
||||
@@ -404,6 +406,31 @@ class DatabaseMigrator:
|
||||
self.update_user_char_full(c2) # 更新user_char_full
|
||||
|
||||
|
||||
class LogDatabaseMigrator:
|
||||
|
||||
def __init__(self, c1_path: str = Config.SQLITE_LOG_DATABASE_PATH) -> None:
|
||||
self.c1_path = c1_path
|
||||
# self.c2_path = c2_path
|
||||
self.init_folder_path = Config.DATABASE_INIT_PATH
|
||||
self.c = None
|
||||
|
||||
@property
|
||||
def sql_path(self) -> str:
|
||||
return os.path.join(self.init_folder_path, 'log_tables.sql')
|
||||
|
||||
def table_update(self) -> None:
|
||||
'''直接更新数据库结构'''
|
||||
with open(self.sql_path, 'r') as f:
|
||||
self.c.executescript(f.read())
|
||||
self.c.execute(
|
||||
'''insert or replace into cache values("version", :a, -1);''', {'a': ARCAEA_LOG_DATBASE_VERSION})
|
||||
|
||||
def update_database(self) -> None:
|
||||
with Connect(self.c1_path) as c:
|
||||
self.c = c
|
||||
self.table_update()
|
||||
|
||||
|
||||
class MemoryDatabase:
|
||||
conn = sqlite3.connect('file:arc_tmp?mode=memory&cache=shared', uri=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user