mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-02-12 10:47:28 +08:00
add back games, conform them to new title dispatch
This commit is contained in:
6
titles/diva/schema/__init__.py
Normal file
6
titles/diva/schema/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from titles.diva.schema.profile import DivaProfileData
|
||||
from titles.diva.schema.score import DivaScoreData
|
||||
from titles.diva.schema.item import DivaItemData
|
||||
from titles.diva.schema.static import DivaStaticData
|
||||
|
||||
__all__ = [DivaProfileData, DivaScoreData, DivaItemData, DivaStaticData]
|
||||
50
titles/diva/schema/item.py
Normal file
50
titles/diva/schema/item.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from typing import Optional, Dict, List
|
||||
from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_, case
|
||||
from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean
|
||||
from sqlalchemy.schema import ForeignKey
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.dialects.mysql import insert
|
||||
|
||||
from core.data.schema import BaseData, metadata
|
||||
|
||||
shop = Table(
|
||||
"diva_profile_shop",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column("version", Integer, nullable=False),
|
||||
Column("mdl_eqp_ary", String(32)),
|
||||
UniqueConstraint("user", "version", name="diva_profile_shop_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
|
||||
class DivaItemData(BaseData):
|
||||
def put_shop(self, aime_id: int, version: int, mdl_eqp_ary: str) -> None:
|
||||
sql = insert(shop).values(
|
||||
version=version,
|
||||
user=aime_id,
|
||||
mdl_eqp_ary=mdl_eqp_ary
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
mdl_eqp_ary = sql.inserted.mdl_eqp_ary
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(f"{__name__} Failed to insert diva profile! aime id: {aime_id} array: {mdl_eqp_ary}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_shop(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
||||
"""
|
||||
Given a game version and either a profile or aime id, return the profile
|
||||
"""
|
||||
sql = shop.select(and_(
|
||||
shop.c.version == version,
|
||||
shop.c.user == aime_id
|
||||
))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
return result.fetchone()
|
||||
113
titles/diva/schema/profile.py
Normal file
113
titles/diva/schema/profile.py
Normal file
@@ -0,0 +1,113 @@
|
||||
from typing import Optional, Dict, List
|
||||
from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_
|
||||
from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON
|
||||
from sqlalchemy.schema import ForeignKey
|
||||
from sqlalchemy.sql import func, select
|
||||
from sqlalchemy.dialects.mysql import insert
|
||||
|
||||
from core.data.schema import BaseData, metadata
|
||||
|
||||
profile = Table(
|
||||
"diva_profile",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column("version", Integer, nullable=False),
|
||||
Column("player_name", String(8), nullable=False),
|
||||
Column("lv_str", String(24), nullable=False, server_default="Dab on 'em"),
|
||||
Column("lv_num", Integer, nullable=False, server_default="0"),
|
||||
Column("lv_pnt", Integer, nullable=False, server_default="0"),
|
||||
Column("vcld_pts", Integer, nullable=False, server_default="0"),
|
||||
Column("hp_vol", Integer, nullable=False, server_default="100"),
|
||||
Column("btn_se_vol", Integer, nullable=False, server_default="100"),
|
||||
Column("btn_se_vol2", Integer, nullable=False, server_default="100"),
|
||||
Column("sldr_se_vol2", Integer, nullable=False, server_default="100"),
|
||||
Column("sort_kind", Integer, nullable=False, server_default="2"),
|
||||
Column("use_pv_mdl_eqp", String(8), nullable=False, server_default="true"),
|
||||
Column("use_pv_btn_se_eqp", String(8), nullable=False, server_default="true"),
|
||||
Column("use_pv_sld_se_eqp", String(8), nullable=False, server_default="false"),
|
||||
Column("use_pv_chn_sld_se_eqp", String(8), nullable=False, server_default="false"),
|
||||
Column("use_pv_sldr_tch_se_eqp", String(8), nullable=False, server_default="false"),
|
||||
Column("nxt_pv_id", Integer, nullable=False, server_default="708"),
|
||||
Column("nxt_dffclty", Integer, nullable=False, server_default="2"),
|
||||
Column("nxt_edtn", Integer, nullable=False, server_default="0"),
|
||||
Column("dsp_clr_brdr", Integer, nullable=False, server_default="7"),
|
||||
Column("dsp_intrm_rnk", Integer, nullable=False, server_default="1"),
|
||||
Column("dsp_clr_sts", Integer, nullable=False, server_default="1"),
|
||||
Column("rgo_sts", Integer, nullable=False, server_default="1"),
|
||||
Column("lv_efct_id", Integer, nullable=False, server_default="0"),
|
||||
Column("lv_plt_id", Integer, nullable=False, server_default="1"),
|
||||
Column("my_qst_id", String(128), server_default="-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1"),
|
||||
Column("my_qst_sts", String(128), server_default="-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1"),
|
||||
UniqueConstraint("user", "version", name="diva_profile_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
|
||||
class DivaProfileData(BaseData):
|
||||
def create_profile(self, version: int, aime_id: int, player_name: str) -> Optional[int]:
|
||||
"""
|
||||
Given a game version, aime id, and player_name, create a profile and return it's ID
|
||||
"""
|
||||
sql = insert(profile).values(
|
||||
version=version,
|
||||
user=aime_id,
|
||||
player_name=player_name
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
player_name = sql.inserted.player_name
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(f"{__name__} Failed to insert diva profile! aime id: {aime_id} username: {player_name}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def update_profile(self, profile_id: int, lv_num: int, lv_pnt: int, vcld_pts: int, hp_vol: int, btn_se_vol: int, btn_se_vol2: int, sldr_se_vol2: int, sort_kind: int, use_pv_mdl_eqp: str, use_pv_btn_se_eqp: str, use_pv_sld_se_eqp: str, use_pv_chn_sld_se_eqp: str, use_pv_sldr_tch_se_eqp: str, nxt_pv_id: int, nxt_dffclty: int, nxt_edtn: int, dsp_clr_brdr: int, dsp_intrm_rnk: int, dsp_clr_sts: int, rgo_sts: int, lv_efct_id: int, lv_plt_id: int, my_qst_id: str, my_qst_sts: str) -> None:
|
||||
sql = profile.update(profile.c.user == profile_id).values(
|
||||
|
||||
lv_num = lv_num,
|
||||
lv_pnt = lv_pnt,
|
||||
vcld_pts = vcld_pts,
|
||||
hp_vol = hp_vol,
|
||||
btn_se_vol = btn_se_vol,
|
||||
btn_se_vol2 = btn_se_vol2,
|
||||
sldr_se_vol2 = sldr_se_vol2,
|
||||
sort_kind = sort_kind,
|
||||
use_pv_mdl_eqp = use_pv_mdl_eqp,
|
||||
use_pv_btn_se_eqp = use_pv_btn_se_eqp,
|
||||
use_pv_sld_se_eqp = use_pv_sld_se_eqp,
|
||||
use_pv_chn_sld_se_eqp = use_pv_chn_sld_se_eqp,
|
||||
use_pv_sldr_tch_se_eqp = use_pv_sldr_tch_se_eqp,
|
||||
nxt_pv_id = nxt_pv_id,
|
||||
nxt_dffclty = nxt_dffclty,
|
||||
nxt_edtn = nxt_edtn,
|
||||
dsp_clr_brdr = dsp_clr_brdr,
|
||||
dsp_intrm_rnk = dsp_intrm_rnk,
|
||||
dsp_clr_sts = dsp_clr_sts,
|
||||
rgo_sts = rgo_sts,
|
||||
lv_efct_id = lv_efct_id,
|
||||
lv_plt_id = lv_plt_id,
|
||||
my_qst_id = my_qst_id,
|
||||
my_qst_sts = my_qst_sts
|
||||
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"update_profile: failed to update profile! profile: {profile_id}")
|
||||
return None
|
||||
|
||||
def get_profile(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
||||
"""
|
||||
Given a game version and either a profile or aime id, return the profile
|
||||
"""
|
||||
sql = profile.select(and_(
|
||||
profile.c.version == version,
|
||||
profile.c.user == aime_id
|
||||
))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
return result.fetchone()
|
||||
141
titles/diva/schema/score.py
Normal file
141
titles/diva/schema/score.py
Normal file
@@ -0,0 +1,141 @@
|
||||
from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_
|
||||
from sqlalchemy.types import Integer, String, TIMESTAMP, JSON, Boolean
|
||||
from sqlalchemy.schema import ForeignKey
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.dialects.mysql import insert
|
||||
from typing import Optional, List, Dict, Any
|
||||
|
||||
from core.data.schema import BaseData, metadata
|
||||
from core.data import cached
|
||||
|
||||
score = Table(
|
||||
"diva_score",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade"), nullable=False),
|
||||
Column("version", Integer),
|
||||
Column("pv_id", Integer),
|
||||
Column("difficulty", Integer),
|
||||
Column("score", Integer),
|
||||
Column("atn_pnt", Integer),
|
||||
Column("clr_kind", Integer),
|
||||
Column("sort_kind", Integer),
|
||||
Column("cool", Integer),
|
||||
Column("fine", Integer),
|
||||
Column("safe", Integer),
|
||||
Column("sad", Integer),
|
||||
Column("worst", Integer),
|
||||
Column("max_combo", Integer),
|
||||
UniqueConstraint("user", "pv_id", "difficulty", name="diva_score_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
|
||||
playlog = Table(
|
||||
"diva_playlog",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade"), nullable=False),
|
||||
Column("version", Integer),
|
||||
Column("pv_id", Integer),
|
||||
Column("difficulty", Integer),
|
||||
Column("score", Integer),
|
||||
Column("atn_pnt", Integer),
|
||||
Column("clr_kind", Integer),
|
||||
Column("sort_kind", Integer),
|
||||
Column("cool", Integer),
|
||||
Column("fine", Integer),
|
||||
Column("safe", Integer),
|
||||
Column("sad", Integer),
|
||||
Column("worst", Integer),
|
||||
Column("max_combo", Integer),
|
||||
Column("date_scored", TIMESTAMP, server_default=func.now()),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
|
||||
class DivaScoreData(BaseData):
|
||||
def put_best_score(self, user_id: int, game_version: int, song_id: int, difficulty: int, song_score: int, atn_pnt: int,
|
||||
clr_kind: int, sort_kind:int, cool: int, fine: int, safe: int, sad: int, worst: int, max_combo: int) -> Optional[int]:
|
||||
"""
|
||||
Update the user's best score for a chart
|
||||
"""
|
||||
sql = insert(score).values(
|
||||
user=user_id,
|
||||
version=game_version,
|
||||
pv_id = song_id,
|
||||
difficulty=difficulty,
|
||||
score=song_score,
|
||||
atn_pnt = atn_pnt,
|
||||
clr_kind = clr_kind,
|
||||
sort_kind = sort_kind,
|
||||
cool = cool,
|
||||
fine = fine,
|
||||
safe = safe,
|
||||
sad = sad,
|
||||
worst = worst,
|
||||
max_combo = max_combo,
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
score=song_score,
|
||||
atn_pnt = atn_pnt,
|
||||
clr_kind = clr_kind,
|
||||
sort_kind = sort_kind,
|
||||
cool = cool,
|
||||
fine = fine,
|
||||
safe = safe,
|
||||
sad = sad,
|
||||
worst = worst,
|
||||
max_combo = max_combo,
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(f"{__name__} failed to insert best score! profile: {user_id}, song: {song_id}")
|
||||
return None
|
||||
|
||||
return result.lastrowid
|
||||
|
||||
def put_playlog(self, user_id: int, game_version: int, song_id: int, difficulty: int, song_score: int, atn_pnt: int,
|
||||
clr_kind: int, sort_kind:int, cool: int, fine: int, safe: int, sad: int, worst: int, max_combo: int) -> Optional[int]:
|
||||
"""
|
||||
Add an entry to the user's play log
|
||||
"""
|
||||
sql = playlog.insert().values(
|
||||
user=user_id,
|
||||
version=game_version,
|
||||
pv_id = song_id,
|
||||
difficulty=difficulty,
|
||||
score=song_score,
|
||||
atn_pnt = atn_pnt,
|
||||
clr_kind = clr_kind,
|
||||
sort_kind = sort_kind,
|
||||
cool = cool,
|
||||
fine = fine,
|
||||
safe = safe,
|
||||
sad = sad,
|
||||
worst = worst,
|
||||
max_combo = max_combo
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"{__name__} failed to insert playlog! profile: {user_id}, song: {song_id}, chart: {difficulty}")
|
||||
return None
|
||||
|
||||
return result.lastrowid
|
||||
|
||||
def get_best_score(self, user_id: int, pv_id: int, chart_id: int) -> Optional[Dict]:
|
||||
sql = score.select(
|
||||
and_(score.c.user == user_id, score.c.pv_id == pv_id, score.c.difficulty == chart_id)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_best_scores(self, user_id: int) -> Optional[Dict]:
|
||||
sql = score.select(score.c.user == user_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
return result.fetchall()
|
||||
222
titles/diva/schema/static.py
Normal file
222
titles/diva/schema/static.py
Normal file
@@ -0,0 +1,222 @@
|
||||
from typing import Dict, List, Optional
|
||||
from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, and_
|
||||
from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, Float
|
||||
from sqlalchemy.engine.base import Connection
|
||||
from sqlalchemy.engine import Row
|
||||
from sqlalchemy.schema import ForeignKey
|
||||
from sqlalchemy.sql import func, select
|
||||
from sqlalchemy.dialects.mysql import insert
|
||||
|
||||
from core.data.schema import BaseData, metadata
|
||||
|
||||
music = Table(
|
||||
"diva_static_music",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("version", Integer, nullable=False),
|
||||
Column("songId", Integer),
|
||||
Column("chartId", Integer),
|
||||
Column("title", String(255)),
|
||||
Column("vocaloid_arranger", String(255)),
|
||||
Column("pv_illustrator", String(255)),
|
||||
Column("lyrics", String(255)),
|
||||
Column("bg_music", String(255)),
|
||||
Column("level", Float),
|
||||
Column("bpm", Integer),
|
||||
Column("date", String(255)),
|
||||
UniqueConstraint("version", "songId", "chartId", name="diva_static_music_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
|
||||
quests = Table(
|
||||
"diva_static_quests",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("version", Integer, nullable=False),
|
||||
Column("questId", Integer),
|
||||
Column("name", String(255)),
|
||||
Column("quest_enable", Boolean, server_default="1"),
|
||||
Column("kind", Integer),
|
||||
Column("unknown_0", Integer),
|
||||
Column("unknown_1", Integer),
|
||||
Column("unknown_2", Integer),
|
||||
Column("quest_order", Integer),
|
||||
Column("start_datetime", String(255)),
|
||||
Column("end_datetime", String(255)),
|
||||
|
||||
UniqueConstraint("version", "questId", name="diva_static_quests_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
|
||||
shop = Table(
|
||||
"diva_static_shop",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("version", Integer, nullable=False),
|
||||
Column("shopId", Integer),
|
||||
Column("name", String(255)),
|
||||
Column("type", Integer),
|
||||
Column("points", Integer),
|
||||
Column("unknown_0", Integer),
|
||||
Column("start_date", String(255)),
|
||||
Column("end_date", String(255)),
|
||||
Column("enabled", Boolean, server_default="1"),
|
||||
UniqueConstraint("version", "shopId", name="diva_static_shop_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
|
||||
items = Table(
|
||||
"diva_static_items",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("version", Integer, nullable=False),
|
||||
Column("itemId", Integer),
|
||||
Column("name", String(255)),
|
||||
Column("type", Integer),
|
||||
Column("points", Integer),
|
||||
Column("unknown_0", Integer),
|
||||
Column("start_date", String(255)),
|
||||
Column("end_date", String(255)),
|
||||
Column("enabled", Boolean, server_default="1"),
|
||||
UniqueConstraint("version", "itemId", name="diva_static_items_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
)
|
||||
|
||||
class DivaStaticData(BaseData):
|
||||
def put_quests(self, version: int, questId: int, name: str, kind: int, unknown_0: int, unknown_1: int, unknown_2: int, quest_order: int, start_datetime: str, end_datetime: str) -> Optional[int]:
|
||||
sql = insert(quests).values(
|
||||
version = version,
|
||||
questId = questId,
|
||||
name = name,
|
||||
kind = kind,
|
||||
unknown_0 = unknown_0,
|
||||
unknown_1 = unknown_1,
|
||||
unknown_2 = unknown_2,
|
||||
quest_order = quest_order,
|
||||
start_datetime = start_datetime,
|
||||
end_datetime = end_datetime
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
name = name
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None: return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_enabled_quests(self, version: int) -> Optional[List[Row]]:
|
||||
sql = select(quests).where(and_(quests.c.version == version, quests.c.quest_enable == True))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_shop(self, version: int, shopId: int, name: str, type: int, points: int, unknown_0: int, start_date: str, end_date: str) -> Optional[int]:
|
||||
sql = insert(shop).values(
|
||||
version = version,
|
||||
shopId = shopId,
|
||||
name = name,
|
||||
type = type,
|
||||
points = points,
|
||||
unknown_0 = unknown_0,
|
||||
start_date = start_date,
|
||||
end_date = end_date
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
name = name
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None: return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_enabled_shop(self, version: int) -> Optional[List[Row]]:
|
||||
sql = select(shop).where(and_(shop.c.version == version, shop.c.enabled == True))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_items(self, version: int, itemId: int, name: str, type: int, points: int, unknown_0: int, start_date: str, end_date: str) -> Optional[int]:
|
||||
sql = insert(items).values(
|
||||
version = version,
|
||||
itemId = itemId,
|
||||
name = name,
|
||||
type = type,
|
||||
points = points,
|
||||
unknown_0 = unknown_0,
|
||||
start_date = start_date,
|
||||
end_date = end_date
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
name = name
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None: return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_enabled_items(self, version: int) -> Optional[List[Row]]:
|
||||
sql = select(items).where(and_(items.c.version == version, items.c.enabled == True))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_music(self, version: int, song: int, chart: int, title: str, arranger: str, illustrator: str,
|
||||
lyrics: str, music_comp: str, level: float, bpm: int, date: str) -> Optional[int]:
|
||||
sql = insert(music).values(
|
||||
version = version,
|
||||
songId = song,
|
||||
chartId = chart,
|
||||
title = title,
|
||||
vocaloid_arranger = arranger,
|
||||
pv_illustrator = illustrator,
|
||||
lyrics = lyrics,
|
||||
bg_music = music_comp,
|
||||
level = level,
|
||||
bpm = bpm,
|
||||
date = date
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
title = title,
|
||||
vocaloid_arranger = arranger,
|
||||
pv_illustrator = illustrator,
|
||||
lyrics = lyrics,
|
||||
bg_music = music_comp,
|
||||
level = level,
|
||||
bpm = bpm,
|
||||
date = date
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None: return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_music(self, version: int, song_id: Optional[int] = None) -> Optional[List[Row]]:
|
||||
if song_id is None:
|
||||
sql = select(music).where(music.c.version == version)
|
||||
else:
|
||||
sql = select(music).where(and_(
|
||||
music.c.version == version,
|
||||
music.c.songId == song_id,
|
||||
))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_music_chart(self, version: int, song_id: int, chart_id: int) -> Optional[List[Row]]:
|
||||
sql = select(music).where(and_(
|
||||
music.c.version == version,
|
||||
music.c.songId == song_id,
|
||||
music.c.chartId == chart_id
|
||||
))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
return result.fetchone()
|
||||
Reference in New Issue
Block a user