forked from Hay1tsme/artemis
let black do it's magic
This commit is contained in:
@ -4,4 +4,10 @@ from titles.ongeki.schema.static import OngekiStaticData
|
||||
from titles.ongeki.schema.score import OngekiScoreData
|
||||
from titles.ongeki.schema.log import OngekiLogData
|
||||
|
||||
__all__ = [OngekiProfileData, OngekiItemData, OngekiStaticData, OngekiScoreData, OngekiLogData]
|
||||
__all__ = [
|
||||
OngekiProfileData,
|
||||
OngekiItemData,
|
||||
OngekiStaticData,
|
||||
OngekiScoreData,
|
||||
OngekiLogData,
|
||||
]
|
||||
|
@ -28,7 +28,7 @@ card = Table(
|
||||
Column("isAcquired", Boolean),
|
||||
Column("created", String(25)),
|
||||
UniqueConstraint("user", "cardId", name="ongeki_user_card_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
deck = Table(
|
||||
@ -41,7 +41,7 @@ deck = Table(
|
||||
Column("cardId2", Integer),
|
||||
Column("cardId3", Integer),
|
||||
UniqueConstraint("user", "deckId", name="ongeki_user_deck_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
character = Table(
|
||||
@ -59,10 +59,10 @@ character = Table(
|
||||
Column("intimateCountDate", String(25)),
|
||||
Column("isNew", Boolean),
|
||||
UniqueConstraint("user", "characterId", name="ongeki_user_character_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
boss = Table (
|
||||
boss = Table(
|
||||
"ongeki_user_boss",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
@ -72,10 +72,10 @@ boss = Table (
|
||||
Column("isClear", Boolean),
|
||||
Column("eventId", Integer),
|
||||
UniqueConstraint("user", "musicId", "eventId", name="ongeki_user_boss_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
story = Table (
|
||||
story = Table(
|
||||
"ongeki_user_story",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
@ -87,7 +87,7 @@ story = Table (
|
||||
Column("lastPlayMusicCategory", Integer),
|
||||
Column("lastPlayMusicLevel", Integer),
|
||||
UniqueConstraint("user", "storyId", name="ongeki_user_story_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
chapter = Table(
|
||||
@ -105,7 +105,7 @@ chapter = Table(
|
||||
Column("skipTiming1", Integer),
|
||||
Column("skipTiming2", Integer),
|
||||
UniqueConstraint("user", "chapterId", name="ongeki_user_chapter_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
memorychapter = Table(
|
||||
@ -126,7 +126,7 @@ memorychapter = Table(
|
||||
Column("lastPlayMusicLevel", Integer),
|
||||
Column("lastPlayMusicCategory", Integer),
|
||||
UniqueConstraint("user", "chapterId", name="ongeki_user_memorychapter_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
item = Table(
|
||||
@ -139,7 +139,7 @@ item = Table(
|
||||
Column("stock", Integer),
|
||||
Column("isValid", Boolean),
|
||||
UniqueConstraint("user", "itemKind", "itemId", name="ongeki_user_item_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
music_item = Table(
|
||||
@ -150,7 +150,7 @@ music_item = Table(
|
||||
Column("musicId", Integer),
|
||||
Column("status", Integer),
|
||||
UniqueConstraint("user", "musicId", name="ongeki_user_music_item_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
login_bonus = Table(
|
||||
@ -162,7 +162,7 @@ login_bonus = Table(
|
||||
Column("bonusCount", Integer),
|
||||
Column("lastUpdateDate", String(25)),
|
||||
UniqueConstraint("user", "bonusId", name="ongeki_user_login_bonus_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
event_point = Table(
|
||||
@ -174,7 +174,7 @@ event_point = Table(
|
||||
Column("point", Integer),
|
||||
Column("isRankingRewarded", Boolean),
|
||||
UniqueConstraint("user", "eventId", name="ongeki_user_event_point_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
mission_point = Table(
|
||||
@ -185,7 +185,7 @@ mission_point = Table(
|
||||
Column("eventId", Integer),
|
||||
Column("point", Integer),
|
||||
UniqueConstraint("user", "eventId", name="ongeki_user_mission_point_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
scenerio = Table(
|
||||
@ -196,7 +196,7 @@ scenerio = Table(
|
||||
Column("scenarioId", Integer),
|
||||
Column("playCount", Integer),
|
||||
UniqueConstraint("user", "scenarioId", name="ongeki_user_scenerio_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
trade_item = Table(
|
||||
@ -207,8 +207,10 @@ trade_item = Table(
|
||||
Column("chapterId", Integer),
|
||||
Column("tradeItemId", Integer),
|
||||
Column("tradeCount", Integer),
|
||||
UniqueConstraint("user", "chapterId", "tradeItemId", name="ongeki_user_trade_item_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
UniqueConstraint(
|
||||
"user", "chapterId", "tradeItemId", name="ongeki_user_trade_item_uk"
|
||||
),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
event_music = Table(
|
||||
@ -224,8 +226,10 @@ event_music = Table(
|
||||
Column("platinumScoreMax", Integer),
|
||||
Column("techRecordDate", String(25)),
|
||||
Column("isTechNewRecord", Boolean),
|
||||
UniqueConstraint("user", "eventId", "type", "musicId", "level", name="ongeki_user_event_music"),
|
||||
mysql_charset='utf8mb4'
|
||||
UniqueConstraint(
|
||||
"user", "eventId", "type", "musicId", "level", name="ongeki_user_event_music"
|
||||
),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
tech_event = Table(
|
||||
@ -240,14 +244,18 @@ tech_event = Table(
|
||||
Column("isRankingRewarded", Boolean),
|
||||
Column("isTotalTechNewRecord", Boolean),
|
||||
UniqueConstraint("user", "eventId", name="ongeki_user_tech_event_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
gacha = Table(
|
||||
"ongeki_user_gacha",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("gachaId", Integer, nullable=False),
|
||||
Column("totalGachaCnt", Integer, server_default="0"),
|
||||
Column("ceilingGachaCnt", Integer, server_default="0"),
|
||||
@ -258,17 +266,21 @@ gacha = Table(
|
||||
Column("elevenGachaCnt", Integer, server_default="0"),
|
||||
Column("dailyGachaDate", TIMESTAMP, nullable=False, server_default=func.now()),
|
||||
UniqueConstraint("user", "gachaId", name="ongeki_user_gacha_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
gacha_supply = Table(
|
||||
"ongeki_user_gacha_supply",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("cardId", Integer, nullable=False),
|
||||
UniqueConstraint("user", "cardId", name="ongeki_user_gacha_supply_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
@ -276,7 +288,11 @@ print_detail = Table(
|
||||
"ongeki_user_print_detail",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("cardId", Integer, nullable=False),
|
||||
Column("cardType", Integer, server_default="0"),
|
||||
Column("printDate", TIMESTAMP, nullable=False),
|
||||
@ -297,11 +313,11 @@ print_detail = Table(
|
||||
Column("printOption9", Boolean, server_default="1"),
|
||||
Column("printOption10", Boolean, server_default="0"),
|
||||
UniqueConstraint("serialId", name="ongeki_user_print_detail_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
class OngekiItemData(BaseData):
|
||||
class OngekiItemData(BaseData):
|
||||
def put_card(self, aime_id: int, card_data: Dict) -> Optional[int]:
|
||||
card_data["user"] = aime_id
|
||||
|
||||
@ -318,7 +334,8 @@ class OngekiItemData(BaseData):
|
||||
sql = select(card).where(card.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_character(self, aime_id: int, character_data: Dict) -> Optional[int]:
|
||||
@ -332,12 +349,13 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_character: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_characters(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(character).where(character.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_deck(self, aime_id: int, deck_data: Dict) -> Optional[int]:
|
||||
@ -351,19 +369,21 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_deck: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_deck(self, aime_id: int, deck_id: int) -> Optional[Dict]:
|
||||
sql = select(deck).where(and_(deck.c.user == aime_id, deck.c.deckId == deck_id))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
|
||||
def get_decks(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(deck).where(deck.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_boss(self, aime_id: int, boss_data: Dict) -> Optional[int]:
|
||||
@ -377,7 +397,7 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_boss: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def put_story(self, aime_id: int, story_data: Dict) -> Optional[int]:
|
||||
story_data["user"] = aime_id
|
||||
|
||||
@ -389,12 +409,13 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_story: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_stories(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(story).where(story.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_chapter(self, aime_id: int, chapter_data: Dict) -> Optional[int]:
|
||||
@ -408,12 +429,13 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_chapter: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_chapters(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(chapter).where(chapter.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_item(self, aime_id: int, item_data: Dict) -> Optional[int]:
|
||||
@ -427,22 +449,26 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_item: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_item(self, aime_id: int, item_id: int, item_kind: int) -> Optional[Dict]:
|
||||
sql = select(item).where(and_(item.c.user == aime_id, item.c.itemId == item_id))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_items(self, aime_id: int, item_kind: int = None) -> Optional[List[Dict]]:
|
||||
if item_kind is None:
|
||||
sql = select(item).where(item.c.user == aime_id)
|
||||
else:
|
||||
sql = select(item).where(and_(item.c.user == aime_id, item.c.itemKind == item_kind))
|
||||
sql = select(item).where(
|
||||
and_(item.c.user == aime_id, item.c.itemKind == item_kind)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_music_item(self, aime_id: int, music_item_data: Dict) -> Optional[int]:
|
||||
@ -456,12 +482,13 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_music_item: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_music_items(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(music_item).where(music_item.c.user == aime_id)
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_login_bonus(self, aime_id: int, login_bonus_data: Dict) -> Optional[int]:
|
||||
@ -475,15 +502,18 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_login_bonus: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_login_bonuses(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(login_bonus).where(login_bonus.c.user == aime_id)
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_mission_point(self, aime_id: int, mission_point_data: Dict) -> Optional[int]:
|
||||
def put_mission_point(
|
||||
self, aime_id: int, mission_point_data: Dict
|
||||
) -> Optional[int]:
|
||||
mission_point_data["user"] = aime_id
|
||||
|
||||
sql = insert(mission_point).values(**mission_point_data)
|
||||
@ -494,14 +524,15 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_mission_point: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_mission_points(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(mission_point).where(mission_point.c.user == aime_id)
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
|
||||
def put_event_point(self, aime_id: int, event_point_data: Dict) -> Optional[int]:
|
||||
event_point_data["user"] = aime_id
|
||||
|
||||
@ -513,12 +544,13 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_event_point: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_event_points(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(event_point).where(event_point.c.user == aime_id)
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_scenerio(self, aime_id: int, scenerio_data: Dict) -> Optional[int]:
|
||||
@ -532,12 +564,13 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_scenerio: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_scenerios(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(scenerio).where(scenerio.c.user == aime_id)
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_trade_item(self, aime_id: int, trade_item_data: Dict) -> Optional[int]:
|
||||
@ -551,14 +584,15 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_trade_item: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_trade_items(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(trade_item).where(trade_item.c.user == aime_id)
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
|
||||
def put_event_music(self, aime_id: int, event_music_data: Dict) -> Optional[int]:
|
||||
event_music_data["user"] = aime_id
|
||||
|
||||
@ -570,12 +604,13 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_event_music: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_event_music(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(event_music).where(event_music.c.user == aime_id)
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_tech_event(self, aime_id: int, tech_event_data: Dict) -> Optional[int]:
|
||||
@ -589,22 +624,26 @@ class OngekiItemData(BaseData):
|
||||
self.logger.warn(f"put_tech_event: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_tech_event(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(tech_event).where(tech_event.c.user == aime_id)
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_bosses(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(boss).where(boss.c.user == aime_id)
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_memorychapter(self, aime_id: int, memorychapter_data: Dict) -> Optional[int]:
|
||||
def put_memorychapter(
|
||||
self, aime_id: int, memorychapter_data: Dict
|
||||
) -> Optional[int]:
|
||||
memorychapter_data["user"] = aime_id
|
||||
|
||||
sql = insert(memorychapter).values(**memorychapter_data)
|
||||
@ -625,10 +664,7 @@ class OngekiItemData(BaseData):
|
||||
return result.fetchall()
|
||||
|
||||
def get_user_gacha(self, aime_id: int, gacha_id: int) -> Optional[Row]:
|
||||
sql = gacha.select(and_(
|
||||
gacha.c.user == aime_id,
|
||||
gacha.c.gachaId == gacha_id
|
||||
))
|
||||
sql = gacha.select(and_(gacha.c.user == aime_id, gacha.c.gachaId == gacha_id))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
@ -652,15 +688,9 @@ class OngekiItemData(BaseData):
|
||||
return result.fetchall()
|
||||
|
||||
def put_user_gacha(self, aime_id: int, gacha_id: int, **data) -> Optional[int]:
|
||||
sql = insert(gacha).values(
|
||||
user=aime_id,
|
||||
gachaId=gacha_id,
|
||||
**data)
|
||||
sql = insert(gacha).values(user=aime_id, gachaId=gacha_id, **data)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
user=aime_id,
|
||||
gachaId=gacha_id,
|
||||
**data)
|
||||
conflict = sql.on_duplicate_key_update(user=aime_id, gachaId=gacha_id, **data)
|
||||
result = self.execute(conflict)
|
||||
|
||||
if result is None:
|
||||
@ -668,20 +698,21 @@ class OngekiItemData(BaseData):
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_user_print_detail(self, aime_id: int, serial_id: str,
|
||||
user_print_data: Dict) -> Optional[int]:
|
||||
def put_user_print_detail(
|
||||
self, aime_id: int, serial_id: str, user_print_data: Dict
|
||||
) -> Optional[int]:
|
||||
sql = insert(print_detail).values(
|
||||
user=aime_id,
|
||||
serialId=serial_id,
|
||||
**user_print_data)
|
||||
user=aime_id, serialId=serial_id, **user_print_data
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
user=aime_id,
|
||||
serialId=serial_id,
|
||||
**user_print_data)
|
||||
user=aime_id, serialId=serial_id, **user_print_data
|
||||
)
|
||||
result = self.execute(conflict)
|
||||
|
||||
if result is None:
|
||||
self.logger.warn(f"put_user_print_detail: Failed to insert! aime_id: {aime_id}")
|
||||
self.logger.warn(
|
||||
f"put_user_print_detail: Failed to insert! aime_id: {aime_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
@ -15,11 +15,13 @@ gp_log = Table(
|
||||
Column("usedCredit", Integer),
|
||||
Column("placeName", String(255)),
|
||||
Column("trxnDate", String(255)),
|
||||
Column("placeId", Integer), # Making this an FK would mess with people playing with default KC
|
||||
Column("kind", Integer),
|
||||
Column("pattern", Integer),
|
||||
Column(
|
||||
"placeId", Integer
|
||||
), # Making this an FK would mess with people playing with default KC
|
||||
Column("kind", Integer),
|
||||
Column("pattern", Integer),
|
||||
Column("currentGP", Integer),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
session_log = Table(
|
||||
@ -32,12 +34,22 @@ session_log = Table(
|
||||
Column("playDate", String(10)),
|
||||
Column("userPlayDate", String(25)),
|
||||
Column("isPaid", Boolean),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
class OngekiLogData(BaseData):
|
||||
def put_gp_log(self, aime_id: Optional[int], used_credit: int, place_name: str, tx_date: str, place_id: int,
|
||||
kind: int, pattern: int, current_gp: int) -> Optional[int]:
|
||||
def put_gp_log(
|
||||
self,
|
||||
aime_id: Optional[int],
|
||||
used_credit: int,
|
||||
place_name: str,
|
||||
tx_date: str,
|
||||
place_id: int,
|
||||
kind: int,
|
||||
pattern: int,
|
||||
current_gp: int,
|
||||
) -> Optional[int]:
|
||||
sql = insert(gp_log).values(
|
||||
user=aime_id,
|
||||
usedCredit=used_credit,
|
||||
@ -51,5 +63,7 @@ class OngekiLogData(BaseData):
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.warn(f"put_gp_log: Failed to insert GP log! aime_id: {aime_id} kind {kind} pattern {pattern} current_gp {current_gp}")
|
||||
return result.lastrowid
|
||||
self.logger.warn(
|
||||
f"put_gp_log: Failed to insert GP log! aime_id: {aime_id} kind {kind} pattern {pattern} current_gp {current_gp}"
|
||||
)
|
||||
return result.lastrowid
|
||||
|
@ -16,7 +16,11 @@ profile = Table(
|
||||
"ongeki_profile_data",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("version", Integer, nullable=False),
|
||||
Column("userName", String(8)),
|
||||
Column("level", Integer),
|
||||
@ -81,7 +85,7 @@ profile = Table(
|
||||
Column("lastEmoneyCredit", Integer, server_default="0"),
|
||||
Column("isDialogWatchedSuggestMemory", Boolean, server_default="0"),
|
||||
UniqueConstraint("user", "version", name="ongeki_profile_profile_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
# No point setting defaults since the game sends everything on profile creation anyway
|
||||
@ -89,7 +93,11 @@ option = Table(
|
||||
"ongeki_profile_option",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("optionSet", Integer),
|
||||
Column("speed", Integer),
|
||||
Column("mirror", Integer),
|
||||
@ -128,14 +136,18 @@ option = Table(
|
||||
Column("stealthField", Integer),
|
||||
Column("colorWallBright", Integer),
|
||||
UniqueConstraint("user", name="ongeki_profile_option_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
activity = Table(
|
||||
"ongeki_profile_activity",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("kind", Integer),
|
||||
Column("activityId", Integer),
|
||||
Column("sortNumber", Integer),
|
||||
@ -144,40 +156,52 @@ activity = Table(
|
||||
Column("param3", Integer),
|
||||
Column("param4", Integer),
|
||||
UniqueConstraint("user", "kind", "activityId", name="ongeki_profile_activity_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
recent_rating = Table(
|
||||
"ongeki_profile_recent_rating",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("recentRating", JSON),
|
||||
UniqueConstraint("user", name="ongeki_profile_recent_rating_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
rating_log = Table(
|
||||
"ongeki_profile_rating_log",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("highestRating", Integer),
|
||||
Column("dataVersion", String(10)),
|
||||
UniqueConstraint("user", "dataVersion", name="ongeki_profile_rating_log_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
region = Table(
|
||||
"ongeki_profile_region",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("regionId", Integer),
|
||||
Column("playCount", Integer),
|
||||
Column("created", String(25)),
|
||||
UniqueConstraint("user", "regionId", name="ongeki_profile_region_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
training_room = Table(
|
||||
@ -185,12 +209,12 @@ training_room = Table(
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("roomId", Integer),
|
||||
Column("roomId", Integer),
|
||||
Column("authKey", Integer),
|
||||
Column("cardId", Integer),
|
||||
Column("valueDate", String(25)),
|
||||
UniqueConstraint("user", "roomId", name="ongeki_profile_training_room_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
kop = Table(
|
||||
@ -199,14 +223,14 @@ kop = Table(
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("authKey", Integer),
|
||||
Column("kopId", Integer),
|
||||
Column("kopId", Integer),
|
||||
Column("areaId", Integer),
|
||||
Column("totalTechScore", Integer),
|
||||
Column("totalPlatinumScore", Integer),
|
||||
Column("techRecordDate", String(25)),
|
||||
Column("isTotalTechNewRecord", Boolean),
|
||||
UniqueConstraint("user", "kopId", name="ongeki_profile_kop_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
rival = Table(
|
||||
@ -214,86 +238,112 @@ rival = Table(
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("rivalUserId", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column(
|
||||
"rivalUserId",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
),
|
||||
UniqueConstraint("user", "rivalUserId", name="ongeki_profile_rival_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
class OngekiProfileData(BaseData):
|
||||
def __init__(self, cfg: CoreConfig, conn: Connection) -> None:
|
||||
super().__init__(cfg, conn)
|
||||
self.date_time_format_ext = "%Y-%m-%d %H:%M:%S.%f" # needs to be lopped off at [:-5]
|
||||
self.date_time_format_ext = (
|
||||
"%Y-%m-%d %H:%M:%S.%f" # needs to be lopped off at [:-5]
|
||||
)
|
||||
self.date_time_format_short = "%Y-%m-%d"
|
||||
|
||||
def get_profile_name(self, aime_id: int, version: int) -> Optional[str]:
|
||||
sql = select(profile.c.userName).where(and_(profile.c.user == aime_id, profile.c.version == version))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
|
||||
row = result.fetchone()
|
||||
if row is None: return None
|
||||
|
||||
return row["userName"]
|
||||
|
||||
def get_profile_preview(self, aime_id: int, version: int) -> Optional[Row]:
|
||||
sql = select([profile, option]).join(option, profile.c.user == option.c.user).filter(
|
||||
sql = select(profile.c.userName).where(
|
||||
and_(profile.c.user == aime_id, profile.c.version == version)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
|
||||
row = result.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
|
||||
return row["userName"]
|
||||
|
||||
def get_profile_preview(self, aime_id: int, version: int) -> Optional[Row]:
|
||||
sql = (
|
||||
select([profile, option])
|
||||
.join(option, profile.c.user == option.c.user)
|
||||
.filter(and_(profile.c.user == aime_id, profile.c.version == version))
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_profile_data(self, aime_id: int, version: int) -> Optional[Row]:
|
||||
sql = select(profile).where(and_(
|
||||
profile.c.user == aime_id,
|
||||
profile.c.version == version,
|
||||
))
|
||||
sql = select(profile).where(
|
||||
and_(
|
||||
profile.c.user == aime_id,
|
||||
profile.c.version == version,
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_profile_options(self, aime_id: int) -> Optional[Row]:
|
||||
sql = select(option).where(and_(
|
||||
option.c.user == aime_id,
|
||||
))
|
||||
sql = select(option).where(
|
||||
and_(
|
||||
option.c.user == aime_id,
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_profile_recent_rating(self, aime_id: int) -> Optional[List[Row]]:
|
||||
sql = select(recent_rating).where(recent_rating.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_profile_rating_log(self, aime_id: int) -> Optional[List[Row]]:
|
||||
sql = select(rating_log).where(recent_rating.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_profile_activity(self, aime_id: int, kind: int = None) -> Optional[List[Row]]:
|
||||
sql = select(activity).where(and_(
|
||||
activity.c.user == aime_id,
|
||||
(activity.c.kind == kind) if kind is not None else True
|
||||
))
|
||||
def get_profile_activity(
|
||||
self, aime_id: int, kind: int = None
|
||||
) -> Optional[List[Row]]:
|
||||
sql = select(activity).where(
|
||||
and_(
|
||||
activity.c.user == aime_id,
|
||||
(activity.c.kind == kind) if kind is not None else True,
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_kop(self, aime_id: int) -> Optional[List[Row]]:
|
||||
sql = select(kop).where(kop.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_rivals(self, aime_id: int) -> Optional[List[Row]]:
|
||||
@ -326,48 +376,62 @@ class OngekiProfileData(BaseData):
|
||||
result = self.execute(conflict)
|
||||
|
||||
if result is None:
|
||||
self.logger.warn(f"put_profile_options: Failed to update! aime_id: {aime_id}")
|
||||
self.logger.warn(
|
||||
f"put_profile_options: Failed to update! aime_id: {aime_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_profile_recent_rating(self, aime_id: int, recent_rating_data: List[Dict]) -> Optional[int]:
|
||||
def put_profile_recent_rating(
|
||||
self, aime_id: int, recent_rating_data: List[Dict]
|
||||
) -> Optional[int]:
|
||||
sql = insert(recent_rating).values(
|
||||
user=aime_id,
|
||||
recentRating=recent_rating_data
|
||||
user=aime_id, recentRating=recent_rating_data
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
recentRating=recent_rating_data
|
||||
)
|
||||
conflict = sql.on_duplicate_key_update(recentRating=recent_rating_data)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(f"put_profile_recent_rating: failed to update recent rating! aime_id {aime_id}")
|
||||
self.logger.warn(
|
||||
f"put_profile_recent_rating: failed to update recent rating! aime_id {aime_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_profile_bp_list(self, aime_id: int, bp_base_list: List[Dict]) -> Optional[int]:
|
||||
def put_profile_bp_list(
|
||||
self, aime_id: int, bp_base_list: List[Dict]
|
||||
) -> Optional[int]:
|
||||
pass
|
||||
|
||||
def put_profile_rating_log(self, aime_id: int, data_version: str, highest_rating: int) -> Optional[int]:
|
||||
|
||||
def put_profile_rating_log(
|
||||
self, aime_id: int, data_version: str, highest_rating: int
|
||||
) -> Optional[int]:
|
||||
sql = insert(rating_log).values(
|
||||
user=aime_id,
|
||||
dataVersion=data_version,
|
||||
highestRating=highest_rating
|
||||
user=aime_id, dataVersion=data_version, highestRating=highest_rating
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
highestRating=highest_rating
|
||||
)
|
||||
conflict = sql.on_duplicate_key_update(highestRating=highest_rating)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(f"put_profile_rating_log: failed to update rating log! aime_id {aime_id} data_version {data_version} highest_rating {highest_rating}")
|
||||
self.logger.warn(
|
||||
f"put_profile_rating_log: failed to update rating log! aime_id {aime_id} data_version {data_version} highest_rating {highest_rating}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_profile_activity(self, aime_id: int, kind: int, activity_id: int, sort_num: int,
|
||||
p1: int, p2: int, p3: int, p4: int) -> Optional[int]:
|
||||
def put_profile_activity(
|
||||
self,
|
||||
aime_id: int,
|
||||
kind: int,
|
||||
activity_id: int,
|
||||
sort_num: int,
|
||||
p1: int,
|
||||
p2: int,
|
||||
p3: int,
|
||||
p4: int,
|
||||
) -> Optional[int]:
|
||||
sql = insert(activity).values(
|
||||
user=aime_id,
|
||||
kind=kind,
|
||||
@ -376,29 +440,24 @@ class OngekiProfileData(BaseData):
|
||||
param1=p1,
|
||||
param2=p2,
|
||||
param3=p3,
|
||||
param4=p4
|
||||
param4=p4,
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
sortNumber=sort_num,
|
||||
param1=p1,
|
||||
param2=p2,
|
||||
param3=p3,
|
||||
param4=p4
|
||||
sortNumber=sort_num, param1=p1, param2=p2, param3=p3, param4=p4
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(f"put_profile_activity: failed to put activity! aime_id {aime_id} kind {kind} activity_id {activity_id}")
|
||||
self.logger.warn(
|
||||
f"put_profile_activity: failed to put activity! aime_id {aime_id} kind {kind} activity_id {activity_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def put_profile_region(self, aime_id: int, region: int, date: str) -> Optional[int]:
|
||||
sql = insert(activity).values(
|
||||
user=aime_id,
|
||||
region=region,
|
||||
playCount=1,
|
||||
created=date
|
||||
user=aime_id, region=region, playCount=1, created=date
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
@ -407,10 +466,12 @@ class OngekiProfileData(BaseData):
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(f"put_profile_region: failed to update! aime_id {aime_id} region {region}")
|
||||
self.logger.warn(
|
||||
f"put_profile_region: failed to update! aime_id {aime_id} region {region}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def put_training_room(self, aime_id: int, room_detail: Dict) -> Optional[int]:
|
||||
room_detail["user"] = aime_id
|
||||
|
||||
@ -422,7 +483,7 @@ class OngekiProfileData(BaseData):
|
||||
self.logger.warn(f"put_best_score: Failed to add score! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def put_kop(self, aime_id: int, kop_data: Dict) -> Optional[int]:
|
||||
kop_data["user"] = aime_id
|
||||
|
||||
@ -434,17 +495,16 @@ class OngekiProfileData(BaseData):
|
||||
self.logger.warn(f"put_kop: Failed to add score! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_rival(self, aime_id: int, rival_id: int) -> Optional[int]:
|
||||
sql = insert(rival).values(
|
||||
user = aime_id,
|
||||
rivalUserId = rival_id
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(rival = rival_id)
|
||||
def put_rival(self, aime_id: int, rival_id: int) -> Optional[int]:
|
||||
sql = insert(rival).values(user=aime_id, rivalUserId=rival_id)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(rival=rival_id)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(f"put_rival: failed to update! aime_id: {aime_id}, rival_id: {rival_id}")
|
||||
self.logger.warn(
|
||||
f"put_rival: failed to update! aime_id: {aime_id}, rival_id: {rival_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
@ -11,14 +11,18 @@ score_best = Table(
|
||||
"ongeki_score_best",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("musicId", Integer, nullable=False),
|
||||
Column("level", Integer, nullable=False),
|
||||
Column("playCount", Integer, nullable=False),
|
||||
Column("playCount", Integer, nullable=False),
|
||||
Column("techScoreMax", Integer, nullable=False),
|
||||
Column("techScoreRank", Integer, nullable=False),
|
||||
Column("battleScoreMax", Integer, nullable=False),
|
||||
Column("battleScoreRank", Integer, nullable=False),
|
||||
Column("battleScoreRank", Integer, nullable=False),
|
||||
Column("maxComboCount", Integer, nullable=False),
|
||||
Column("maxOverKill", Float, nullable=False),
|
||||
Column("maxTeamOverKill", Float, nullable=False),
|
||||
@ -30,14 +34,18 @@ score_best = Table(
|
||||
Column("isStoryWatched", Boolean, nullable=False),
|
||||
Column("platinumScoreMax", Integer),
|
||||
UniqueConstraint("user", "musicId", "level", name="ongeki_best_score_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
playlog = Table(
|
||||
"ongeki_score_playlog",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("sortNumber", Integer),
|
||||
Column("placeId", Integer),
|
||||
Column("placeName", String(255)),
|
||||
@ -99,25 +107,30 @@ playlog = Table(
|
||||
Column("battlePoint", Integer),
|
||||
Column("platinumScore", Integer),
|
||||
Column("platinumScoreMax", Integer),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
tech_count = Table(
|
||||
"ongeki_score_tech_count",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("levelId", Integer, nullable=False),
|
||||
Column("allBreakCount", Integer),
|
||||
Column("allBreakPlusCount", Integer),
|
||||
UniqueConstraint("user", "levelId", name="ongeki_tech_count_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
class OngekiScoreData(BaseData):
|
||||
def get_tech_count(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
return []
|
||||
|
||||
|
||||
def put_tech_count(self, aime_id: int, tech_count_data: Dict) -> Optional[int]:
|
||||
tech_count_data["user"] = aime_id
|
||||
|
||||
@ -129,17 +142,20 @@ class OngekiScoreData(BaseData):
|
||||
self.logger.warn(f"put_tech_count: Failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def get_best_scores(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(score_best).where(score_best.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_best_score(self, aime_id: int, song_id: int, chart_id: int = None) -> Optional[List[Dict]]:
|
||||
def get_best_score(
|
||||
self, aime_id: int, song_id: int, chart_id: int = None
|
||||
) -> Optional[List[Dict]]:
|
||||
return []
|
||||
|
||||
|
||||
def put_best_score(self, aime_id: int, music_detail: Dict) -> Optional[int]:
|
||||
music_detail["user"] = aime_id
|
||||
|
||||
@ -161,4 +177,4 @@ class OngekiScoreData(BaseData):
|
||||
if result is None:
|
||||
self.logger.warn(f"put_playlog: Failed to add playlog! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
return result.lastrowid
|
||||
|
@ -18,7 +18,7 @@ events = Table(
|
||||
Column("name", String(255)),
|
||||
Column("enabled", Boolean, server_default="1"),
|
||||
UniqueConstraint("version", "eventId", "type", name="ongeki_static_events_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ music = Table(
|
||||
Column("genre", String(255)),
|
||||
Column("level", Float),
|
||||
UniqueConstraint("version", "songId", "chartId", name="ongeki_static_music_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
gachas = Table(
|
||||
@ -57,7 +57,7 @@ gachas = Table(
|
||||
Column("noticeEndDate", TIMESTAMP, server_default="2038-01-01 00:00:00.0"),
|
||||
Column("convertEndDate", TIMESTAMP, server_default="2038-01-01 00:00:00.0"),
|
||||
UniqueConstraint("version", "gachaId", "gachaName", name="ongeki_static_gachas_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
gacha_cards = Table(
|
||||
@ -71,7 +71,7 @@ gacha_cards = Table(
|
||||
Column("isPickup", Boolean, server_default="0"),
|
||||
Column("isSelect", Boolean, server_default="0"),
|
||||
UniqueConstraint("gachaId", "cardId", name="ongeki_static_gacha_cards_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
cards = Table(
|
||||
@ -92,16 +92,13 @@ cards = Table(
|
||||
Column("choKaikaSkillId", Integer, nullable=False),
|
||||
Column("cardNumber", String(255)),
|
||||
UniqueConstraint("version", "cardId", name="ongeki_static_cards_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
class OngekiStaticData(BaseData):
|
||||
def put_card(self, version: int, card_id: int, **card_data) -> Optional[int]:
|
||||
sql = insert(cards).values(
|
||||
version=version,
|
||||
cardId=card_id,
|
||||
**card_data)
|
||||
sql = insert(cards).values(version=version, cardId=card_id, **card_data)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(**card_data)
|
||||
|
||||
@ -112,10 +109,7 @@ class OngekiStaticData(BaseData):
|
||||
return result.lastrowid
|
||||
|
||||
def get_card(self, version: int, card_id: int) -> Optional[Dict]:
|
||||
sql = cards.select(and_(
|
||||
cards.c.version <= version,
|
||||
cards.c.cardId == card_id
|
||||
))
|
||||
sql = cards.select(and_(cards.c.version <= version, cards.c.cardId == card_id))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
@ -126,10 +120,9 @@ class OngekiStaticData(BaseData):
|
||||
if not card_number.startswith("[O.N.G.E.K.I.]"):
|
||||
card_number = f"[O.N.G.E.K.I.]{card_number}"
|
||||
|
||||
sql = cards.select(and_(
|
||||
cards.c.version <= version,
|
||||
cards.c.cardNumber == card_number
|
||||
))
|
||||
sql = cards.select(
|
||||
and_(cards.c.version <= version, cards.c.cardNumber == card_number)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
@ -137,10 +130,7 @@ class OngekiStaticData(BaseData):
|
||||
return result.fetchone()
|
||||
|
||||
def get_card_by_name(self, version: int, name: str) -> Optional[Dict]:
|
||||
sql = cards.select(and_(
|
||||
cards.c.version <= version,
|
||||
cards.c.name == name
|
||||
))
|
||||
sql = cards.select(and_(cards.c.version <= version, cards.c.name == name))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
@ -156,24 +146,27 @@ class OngekiStaticData(BaseData):
|
||||
return result.fetchall()
|
||||
|
||||
def get_cards_by_rarity(self, version: int, rarity: int) -> Optional[List[Dict]]:
|
||||
sql = cards.select(and_(
|
||||
cards.c.version <= version,
|
||||
cards.c.rarity == rarity
|
||||
))
|
||||
sql = cards.select(and_(cards.c.version <= version, cards.c.rarity == rarity))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_gacha(self, version: int, gacha_id: int, gacha_name: int,
|
||||
gacha_kind: int, **gacha_data) -> Optional[int]:
|
||||
def put_gacha(
|
||||
self,
|
||||
version: int,
|
||||
gacha_id: int,
|
||||
gacha_name: int,
|
||||
gacha_kind: int,
|
||||
**gacha_data,
|
||||
) -> Optional[int]:
|
||||
sql = insert(gachas).values(
|
||||
version=version,
|
||||
gachaId=gacha_id,
|
||||
gachaName=gacha_name,
|
||||
kind=gacha_kind,
|
||||
**gacha_data
|
||||
**gacha_data,
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
@ -181,7 +174,7 @@ class OngekiStaticData(BaseData):
|
||||
gachaId=gacha_id,
|
||||
gachaName=gacha_name,
|
||||
kind=gacha_kind,
|
||||
**gacha_data
|
||||
**gacha_data,
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
@ -191,10 +184,9 @@ class OngekiStaticData(BaseData):
|
||||
return result.lastrowid
|
||||
|
||||
def get_gacha(self, version: int, gacha_id: int) -> Optional[Dict]:
|
||||
sql = gachas.select(and_(
|
||||
gachas.c.version <= version,
|
||||
gachas.c.gachaId == gacha_id
|
||||
))
|
||||
sql = gachas.select(
|
||||
and_(gachas.c.version <= version, gachas.c.gachaId == gacha_id)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
@ -202,8 +194,7 @@ class OngekiStaticData(BaseData):
|
||||
return result.fetchone()
|
||||
|
||||
def get_gachas(self, version: int) -> Optional[List[Dict]]:
|
||||
sql = gachas.select(
|
||||
gachas.c.version == version).order_by(
|
||||
sql = gachas.select(gachas.c.version == version).order_by(
|
||||
gachas.c.gachaId.asc()
|
||||
)
|
||||
|
||||
@ -212,17 +203,13 @@ class OngekiStaticData(BaseData):
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_gacha_card(self, gacha_id: int, card_id: int, **gacha_card) -> Optional[int]:
|
||||
sql = insert(gacha_cards).values(
|
||||
gachaId=gacha_id,
|
||||
cardId=card_id,
|
||||
**gacha_card
|
||||
)
|
||||
def put_gacha_card(
|
||||
self, gacha_id: int, card_id: int, **gacha_card
|
||||
) -> Optional[int]:
|
||||
sql = insert(gacha_cards).values(gachaId=gacha_id, cardId=card_id, **gacha_card)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
gachaId=gacha_id,
|
||||
cardId=card_id,
|
||||
**gacha_card
|
||||
gachaId=gacha_id, cardId=card_id, **gacha_card
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
@ -232,25 +219,25 @@ class OngekiStaticData(BaseData):
|
||||
return result.lastrowid
|
||||
|
||||
def get_gacha_cards(self, gacha_id: int) -> Optional[List[Dict]]:
|
||||
sql = gacha_cards.select(
|
||||
gacha_cards.c.gachaId == gacha_id
|
||||
)
|
||||
sql = gacha_cards.select(gacha_cards.c.gachaId == gacha_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_event(self, version: int, event_id: int, event_type: int, event_name: str) -> Optional[int]:
|
||||
def put_event(
|
||||
self, version: int, event_id: int, event_type: int, event_name: str
|
||||
) -> Optional[int]:
|
||||
sql = insert(events).values(
|
||||
version = version,
|
||||
eventId = event_id,
|
||||
type = event_type,
|
||||
name = event_name,
|
||||
version=version,
|
||||
eventId=event_id,
|
||||
type=event_type,
|
||||
name=event_name,
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
name = event_name,
|
||||
name=event_name,
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
@ -260,63 +247,88 @@ class OngekiStaticData(BaseData):
|
||||
return result.lastrowid
|
||||
|
||||
def get_event(self, version: int, event_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(events).where(and_(events.c.version == version, events.c.eventId == event_id))
|
||||
|
||||
sql = select(events).where(
|
||||
and_(events.c.version == version, events.c.eventId == event_id)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_events(self, version: int) -> Optional[List[Dict]]:
|
||||
sql = select(events).where(events.c.version == version)
|
||||
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_enabled_events(self, version: int) -> Optional[List[Dict]]:
|
||||
sql = select(events).where(and_(events.c.version == version, events.c.enabled == True))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_chart(self, version: int, song_id: int, chart_id: int, title: str, artist: str, genre: str, level: float) -> Optional[int]:
|
||||
def get_enabled_events(self, version: int) -> Optional[List[Dict]]:
|
||||
sql = select(events).where(
|
||||
and_(events.c.version == version, events.c.enabled == True)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_chart(
|
||||
self,
|
||||
version: int,
|
||||
song_id: int,
|
||||
chart_id: int,
|
||||
title: str,
|
||||
artist: str,
|
||||
genre: str,
|
||||
level: float,
|
||||
) -> Optional[int]:
|
||||
sql = insert(music).values(
|
||||
version = version,
|
||||
songId = song_id,
|
||||
chartId = chart_id,
|
||||
title = title,
|
||||
artist = artist,
|
||||
genre = genre,
|
||||
level = level,
|
||||
version=version,
|
||||
songId=song_id,
|
||||
chartId=chart_id,
|
||||
title=title,
|
||||
artist=artist,
|
||||
genre=genre,
|
||||
level=level,
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
title = title,
|
||||
artist = artist,
|
||||
genre = genre,
|
||||
level = level,
|
||||
title=title,
|
||||
artist=artist,
|
||||
genre=genre,
|
||||
level=level,
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(f"Failed to insert chart! song_id: {song_id}, chart_id: {chart_id}")
|
||||
self.logger.warn(
|
||||
f"Failed to insert chart! song_id: {song_id}, chart_id: {chart_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_chart(self, version: int, song_id: int, chart_id: int = None) -> Optional[List[Dict]]:
|
||||
def get_chart(
|
||||
self, version: int, song_id: int, chart_id: int = None
|
||||
) -> Optional[List[Dict]]:
|
||||
pass
|
||||
|
||||
def get_music(self, version: int) -> Optional[List[Dict]]:
|
||||
pass
|
||||
|
||||
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