forked from Dniel97/artemis
Added round tables, refactored vs_info methonds
This commit is contained in:
parent
d1a7b898a7
commit
cdb040a65e
@ -224,26 +224,41 @@ vs_info = Table(
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("group_key", String(25)),
|
||||
Column("win_flg", Integer),
|
||||
Column("style_car_id", Integer),
|
||||
Column("course_id", Integer),
|
||||
Column("course_day", Integer),
|
||||
Column("players_num", Integer),
|
||||
Column("winning", Integer),
|
||||
Column("advantage_1", Integer),
|
||||
Column("advantage_2", Integer),
|
||||
Column("advantage_3", Integer),
|
||||
Column("advantage_4", Integer),
|
||||
Column("select_course_id", Integer),
|
||||
Column("select_course_day", Integer),
|
||||
Column("select_course_random", Integer),
|
||||
Column("matching_success_sec", Integer),
|
||||
Column("boost_flag", Integer),
|
||||
Column("vs_history", Integer),
|
||||
Column("battle_mode", Integer),
|
||||
Column("vs_cnt", Integer),
|
||||
Column("vs_win", Integer),
|
||||
Column("invalid", Integer),
|
||||
Column("str", Integer),
|
||||
Column("str_now", Integer),
|
||||
Column("lose_now", Integer),
|
||||
Column("break_count", Integer),
|
||||
Column("break_penalty_flag", Integer),
|
||||
UniqueConstraint("user", "group_key", name="idac_user_vs_info_uk"),
|
||||
Column("vsinfo_course_data", JSON),
|
||||
UniqueConstraint("user", "battle_mode", name="idac_user_vs_info_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
round_infos = Table(
|
||||
"idac_round_info",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("name", String(64)),
|
||||
Column("season", Integer),
|
||||
Column("start_dt", TIMESTAMP, server_default=func.now()),
|
||||
Column("end_dt", TIMESTAMP, server_default=func.now()),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
round_info = Table(
|
||||
"idac_user_round_info",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("round_id", Integer),
|
||||
Column("count", Integer),
|
||||
Column("win", Integer),
|
||||
Column("points", Integer),
|
||||
UniqueConstraint("user", "round_id", name="idac_user_round_info_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
@ -738,6 +753,16 @@ class IDACItemData(BaseData):
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_vs_info_by_mode(self, aime_id: int, battle_mode: int) -> Optional[List[Row]]:
|
||||
sql = select(vs_info_new).where(
|
||||
and_(vs_info_new.c.user == aime_id, vs_info_new.c.battle_mode == battle_mode)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_stamps(self, aime_id: int) -> Optional[List[Row]]:
|
||||
sql = select(stamp).where(
|
||||
and_(
|
||||
@ -934,10 +959,11 @@ class IDACItemData(BaseData):
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_vs_info(self, aime_id: int, vs_info_data: Dict) -> Optional[int]:
|
||||
def put_vs_info(self, aime_id: int, battle_mode: int, vs_info_data: Dict) -> Optional[int]:
|
||||
vs_info_data["user"] = aime_id
|
||||
vs_info_data["battle_mode"] = battle_mode
|
||||
|
||||
sql = insert(vs_info).values(**vs_info_data)
|
||||
sql = insert(vs_info_new).values(**vs_info_data)
|
||||
conflict = sql.on_duplicate_key_update(**vs_info_data)
|
||||
result = self.execute(conflict)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user