forked from Hay1tsme/artemis
let black do it's magic
This commit is contained in:
@ -23,46 +23,62 @@ music = Table(
|
||||
Column("chartDesigner", String(255)),
|
||||
Column("jacketFile", String(255)),
|
||||
UniqueConstraint("version", "songId", "chartId", name="wacca_static_music_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
class WaccaStaticData(BaseData):
|
||||
def put_music(self, version: int, song_id: int, chart_id: int, title: str, artist: str, bpm: str,
|
||||
difficulty: float, chart_designer: str, jacket: str) -> Optional[int]:
|
||||
def put_music(
|
||||
self,
|
||||
version: int,
|
||||
song_id: int,
|
||||
chart_id: int,
|
||||
title: str,
|
||||
artist: str,
|
||||
bpm: str,
|
||||
difficulty: float,
|
||||
chart_designer: str,
|
||||
jacket: str,
|
||||
) -> Optional[int]:
|
||||
sql = insert(music).values(
|
||||
version = version,
|
||||
songId = song_id,
|
||||
chartId = chart_id,
|
||||
title = title,
|
||||
artist = artist,
|
||||
bpm = bpm,
|
||||
difficulty = difficulty,
|
||||
chartDesigner = chart_designer,
|
||||
jacketFile = jacket
|
||||
version=version,
|
||||
songId=song_id,
|
||||
chartId=chart_id,
|
||||
title=title,
|
||||
artist=artist,
|
||||
bpm=bpm,
|
||||
difficulty=difficulty,
|
||||
chartDesigner=chart_designer,
|
||||
jacketFile=jacket,
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
title = title,
|
||||
artist = artist,
|
||||
bpm = bpm,
|
||||
difficulty = difficulty,
|
||||
chartDesigner = chart_designer,
|
||||
jacketFile = jacket
|
||||
title=title,
|
||||
artist=artist,
|
||||
bpm=bpm,
|
||||
difficulty=difficulty,
|
||||
chartDesigner=chart_designer,
|
||||
jacketFile=jacket,
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
if result is None:
|
||||
self.logger.warn(f"Failed to insert music {song_id} chart {chart_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
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
|
||||
))
|
||||
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
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
Reference in New Issue
Block a user