test
このコミットが含まれているのは:
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import TypedDict
|
||||
|
||||
from eloquent import DatabaseManager, Model # type: ignore
|
||||
|
||||
CONFIG: DBConfig = { 'default': 'nico', 'connections': {
|
||||
'ai': { 'driver': 'mysql',
|
||||
'host': 'localhost',
|
||||
'database': 'nizika_ai',
|
||||
'user': os.environ['MYSQL_USER'],
|
||||
'password': os.environ['MYSQL_PASS'],
|
||||
'prefix': '' },
|
||||
|
||||
'nico': { 'driver': 'mysql',
|
||||
'host': 'localhost',
|
||||
'database': 'nizika_nico',
|
||||
'user': os.environ['MYSQL_USER'],
|
||||
'password': os.environ['MYSQL_PASS'],
|
||||
'prefix': '' } } }
|
||||
|
||||
DB = DatabaseManager (CONFIG)
|
||||
Model.set_connection_resolver (DB)
|
||||
|
||||
|
||||
class DBConfig (TypedDict):
|
||||
default: str
|
||||
connections: dict[str, DBConnection]
|
||||
|
||||
|
||||
class DBConnection (TypedDict):
|
||||
driver: str
|
||||
host: str
|
||||
database: str
|
||||
user: str
|
||||
password: str
|
||||
prefix: str
|
||||
@@ -12,13 +12,18 @@ from typing import cast
|
||||
|
||||
import nicolib
|
||||
import queries_to_answers as q2a
|
||||
from db.config import DB as NicoDB
|
||||
from config import DB
|
||||
from db.models import Comment, Video, VideoHistory
|
||||
from nicolib import VideoInfo
|
||||
from nizika_ai.config import DB as AIDB
|
||||
from nizika_ai.consts import Character, GPTModel, QueryType
|
||||
from nizika_ai.models import Query
|
||||
|
||||
# DB 設定
|
||||
DB
|
||||
for m in (Comment, Video, VideoHistory):
|
||||
m.__connection__ = 'nico'
|
||||
Query.__connection__ = 'ai'
|
||||
|
||||
KIRIBAN_VIEWS_COUNTS: list[int] = sorted ({ *range (1_000, 10_000, 1_000),
|
||||
*range (10_000, 1_000_001, 10_000),
|
||||
114_514, 1_940, 2_450, 5_100,
|
||||
@@ -39,10 +44,6 @@ async def main (
|
||||
メーン処理
|
||||
"""
|
||||
|
||||
# DB 準備
|
||||
NicoDB
|
||||
AIDB
|
||||
|
||||
await asyncio.gather (
|
||||
queries_to_answers (),
|
||||
report_kiriban (),
|
||||
|
||||
新しい課題から参照
ユーザをブロックする