move to async database

This commit is contained in:
Hay1tsme
2024-01-09 14:42:17 -05:00
parent edd3ce8ead
commit 05586df08a
77 changed files with 1925 additions and 1948 deletions

View File

@@ -157,7 +157,7 @@ class OngekiBase:
return {"type": data["type"], "length": 0, "gameIdlistList": []}
async def handle_get_game_ranking_api_request(self, data: Dict) -> Dict:
game_ranking_list = self.data.static.get_ranking_list(self.version)
game_ranking_list = await self.data.static.get_ranking_list(self.version)
ranking_list = []
for music in game_ranking_list:
@@ -172,13 +172,13 @@ class OngekiBase:
}
async def handle_get_game_point_api_request(self, data: Dict) -> Dict:
get_game_point = self.data.static.get_static_game_point()
get_game_point = await self.data.static.get_static_game_point()
game_point = []
if not get_game_point:
self.logger.info(f"GP table is empty, inserting defaults")
self.data.static.put_static_game_point_defaults()
get_game_point = self.data.static.get_static_game_point()
await self.data.static.put_static_game_point_defaults()
get_game_point = await self.data.static.get_static_game_point()
for gp in get_game_point:
tmp = gp._asdict()
game_point.append(tmp)
@@ -204,7 +204,7 @@ class OngekiBase:
return {"returnCode": 1, "apiName": "ExtendLockTimeApi"}
async def handle_get_game_reward_api_request(self, data: Dict) -> Dict:
get_game_rewards = self.data.static.get_reward_list(self.version)
get_game_rewards = await self.data.static.get_reward_list(self.version)
reward_list = []
for reward in get_game_rewards:
@@ -222,7 +222,7 @@ class OngekiBase:
}
async def handle_get_game_present_api_request(self, data: Dict) -> Dict:
get_present = self.data.static.get_present_list(self.version)
get_present = await self.data.static.get_present_list(self.version)
present_list = []
for present in get_present:
@@ -245,7 +245,7 @@ class OngekiBase:
return {"length": 0, "gameSaleList": []}
async def handle_get_game_tech_music_api_request(self, data: Dict) -> Dict:
music_list = self.data.static.get_tech_music(self.version)
music_list = await self.data.static.get_tech_music(self.version)
prep_music_list = []
for music in music_list:
@@ -268,9 +268,9 @@ class OngekiBase:
client_id = data["clientId"]
client_setting_data = data["clientSetting"]
cab = self.data.arcade.get_machine(client_id)
cab = await self.data.arcade.get_machine(client_id)
if cab is not None:
self.data.static.put_client_setting_data(cab['id'], client_setting_data)
await self.data.static.put_client_setting_data(cab['id'], client_setting_data)
return {"returnCode": 1, "apiName": "UpsertClientSettingApi"}
async def handle_upsert_client_testmode_api_request(self, data: Dict) -> Dict:
@@ -279,7 +279,7 @@ class OngekiBase:
region_id = data["regionId"]
client_testmode_data = data["clientTestmode"]
self.data.static.put_client_testmode_data(region_id, client_testmode_data)
await self.data.static.put_client_testmode_data(region_id, client_testmode_data)
return {"returnCode": 1, "apiName": "UpsertClientTestmodeApi"}
async def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict:
@@ -296,7 +296,7 @@ class OngekiBase:
if user >= 200000000000000: # Account for guest play
user = None
self.data.log.put_gp_log(
await self.data.log.put_gp_log(
user,
data["usedCredit"],
data["placeName"],
@@ -313,7 +313,7 @@ class OngekiBase:
return {"returnCode": 1, "apiName": "ExtendLockTimeApi"}
async def handle_get_game_event_api_request(self, data: Dict) -> Dict:
evts = self.data.static.get_enabled_events(self.version)
evts = await self.data.static.get_enabled_events(self.version)
if evts is None:
return {
@@ -366,7 +366,7 @@ class OngekiBase:
return {"userId": data["userId"], "length": 0, "userRegionList": []}
async def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
profile = self.data.profile.get_profile_preview(data["userId"], self.version)
profile = await self.data.profile.get_profile_preview(data["userId"], self.version)
if profile is None:
return {
@@ -422,7 +422,7 @@ class OngekiBase:
Gets the number of AB and ABPs a player has per-difficulty (7, 7+, 8, etc)
The game sends this in upsert so we don't have to calculate it all out thankfully
"""
utcl = self.data.score.get_tech_count(data["userId"])
utcl = await self.data.score.get_tech_count(data["userId"])
userTechCountList = []
for tc in utcl:
@@ -437,7 +437,7 @@ class OngekiBase:
}
async def handle_get_user_tech_event_api_request(self, data: Dict) -> Dict:
user_tech_event_list = self.data.item.get_tech_event(self.version, data["userId"])
user_tech_event_list = await self.data.item.get_tech_event(self.version, data["userId"])
if user_tech_event_list is None:
return {}
@@ -456,7 +456,7 @@ class OngekiBase:
}
async def handle_get_user_tech_event_ranking_api_request(self, data: Dict) -> Dict:
user_tech_event_ranks = self.data.item.get_tech_event_ranking(self.version, data["userId"])
user_tech_event_ranks = await self.data.item.get_tech_event_ranking(self.version, data["userId"])
if user_tech_event_ranks is None:
return {
"userId": data["userId"],
@@ -482,7 +482,7 @@ class OngekiBase:
}
async def handle_get_user_kop_api_request(self, data: Dict) -> Dict:
kop_list = self.data.profile.get_kop(data["userId"])
kop_list = await self.data.profile.get_kop(data["userId"])
if kop_list is None:
return {}
@@ -518,7 +518,7 @@ class OngekiBase:
async def handle_get_user_item_api_request(self, data: Dict) -> Dict:
kind = data["nextIndex"] / 10000000000
p = self.data.item.get_items(data["userId"], kind)
p = await self.data.item.get_items(data["userId"], kind)
if p is None:
return {
@@ -553,7 +553,7 @@ class OngekiBase:
}
async def handle_get_user_option_api_request(self, data: Dict) -> Dict:
o = self.data.profile.get_profile_options(data["userId"])
o = await self.data.profile.get_profile_options(data["userId"])
if o is None:
return {}
@@ -567,11 +567,11 @@ class OngekiBase:
return {"userId": data["userId"], "userOption": user_opts}
async def handle_get_user_data_api_request(self, data: Dict) -> Dict:
p = self.data.profile.get_profile_data(data["userId"], self.version)
p = await self.data.profile.get_profile_data(data["userId"], self.version)
if p is None:
return {}
cards = self.data.card.get_user_cards(data["userId"])
cards = await self.data.card.get_user_cards(data["userId"])
if cards is None or len(cards) == 0:
# This should never happen
self.logger.error(
@@ -595,7 +595,7 @@ class OngekiBase:
return {"userId": data["userId"], "userData": user_data}
async def handle_get_user_event_ranking_api_request(self, data: Dict) -> Dict:
user_event_ranking_list = self.data.item.get_ranking_event_ranks(self.version, data["userId"])
user_event_ranking_list = await self.data.item.get_ranking_event_ranks(self.version, data["userId"])
if user_event_ranking_list is None:
return {}
@@ -618,7 +618,7 @@ class OngekiBase:
}
async def handle_get_user_login_bonus_api_request(self, data: Dict) -> Dict:
user_login_bonus_list = self.data.item.get_login_bonuses(data["userId"])
user_login_bonus_list = await self.data.item.get_login_bonuses(data["userId"])
if user_login_bonus_list is None:
return {}
@@ -636,7 +636,7 @@ class OngekiBase:
}
async def handle_get_user_bp_base_request(self, data: Dict) -> Dict:
p = self.data.profile.get_profile(
p = await self.data.profile.get_profile(
self.game, self.version, user_id=data["userId"]
)
if p is None:
@@ -649,7 +649,7 @@ class OngekiBase:
}
async def handle_get_user_recent_rating_api_request(self, data: Dict) -> Dict:
recent_rating = self.data.profile.get_profile_recent_rating(data["userId"])
recent_rating = await self.data.profile.get_profile_recent_rating(data["userId"])
if recent_rating is None:
return {
"userId": data["userId"],
@@ -666,7 +666,7 @@ class OngekiBase:
}
async def handle_get_user_activity_api_request(self, data: Dict) -> Dict:
activity = self.data.profile.get_profile_activity(data["userId"], data["kind"])
activity = await self.data.profile.get_profile_activity(data["userId"], data["kind"])
if activity is None:
return {}
@@ -693,7 +693,7 @@ class OngekiBase:
}
async def handle_get_user_story_api_request(self, data: Dict) -> Dict:
user_stories = self.data.item.get_stories(data["userId"])
user_stories = await self.data.item.get_stories(data["userId"])
if user_stories is None:
return {}
@@ -711,7 +711,7 @@ class OngekiBase:
}
async def handle_get_user_chapter_api_request(self, data: Dict) -> Dict:
user_chapters = self.data.item.get_chapters(data["userId"])
user_chapters = await self.data.item.get_chapters(data["userId"])
if user_chapters is None:
return {}
@@ -736,7 +736,7 @@ class OngekiBase:
}
async def handle_get_user_character_api_request(self, data: Dict) -> Dict:
user_characters = self.data.item.get_characters(data["userId"])
user_characters = await self.data.item.get_characters(data["userId"])
if user_characters is None:
return {}
@@ -754,7 +754,7 @@ class OngekiBase:
}
async def handle_get_user_card_api_request(self, data: Dict) -> Dict:
user_cards = self.data.item.get_cards(data["userId"])
user_cards = await self.data.item.get_cards(data["userId"])
if user_cards is None:
return {}
@@ -773,7 +773,7 @@ class OngekiBase:
async def handle_get_user_deck_by_key_api_request(self, data: Dict) -> Dict:
# Auth key doesn't matter, it just wants all the decks
decks = self.data.item.get_decks(data["userId"])
decks = await self.data.item.get_decks(data["userId"])
if decks is None:
return {}
@@ -791,7 +791,7 @@ class OngekiBase:
}
async def handle_get_user_trade_item_api_request(self, data: Dict) -> Dict:
user_trade_items = self.data.item.get_trade_items(data["userId"])
user_trade_items = await self.data.item.get_trade_items(data["userId"])
if user_trade_items is None:
return {}
@@ -809,7 +809,7 @@ class OngekiBase:
}
async def handle_get_user_scenario_api_request(self, data: Dict) -> Dict:
user_scenerio = self.data.item.get_scenerios(data["userId"])
user_scenerio = await self.data.item.get_scenerios(data["userId"])
if user_scenerio is None:
return {}
@@ -827,7 +827,7 @@ class OngekiBase:
}
async def handle_get_user_ratinglog_api_request(self, data: Dict) -> Dict:
rating_log = self.data.profile.get_profile_rating_log(data["userId"])
rating_log = await self.data.profile.get_profile_rating_log(data["userId"])
if rating_log is None:
return {}
@@ -845,7 +845,7 @@ class OngekiBase:
}
async def handle_get_user_mission_point_api_request(self, data: Dict) -> Dict:
user_mission_point_list = self.data.item.get_mission_points(self.version, data["userId"])
user_mission_point_list = await self.data.item.get_mission_points(self.version, data["userId"])
if user_mission_point_list is None:
return {}
@@ -865,7 +865,7 @@ class OngekiBase:
}
async def handle_get_user_event_point_api_request(self, data: Dict) -> Dict:
user_event_point_list = self.data.item.get_event_points(data["userId"])
user_event_point_list = await self.data.item.get_event_points(data["userId"])
if user_event_point_list is None:
return {}
@@ -887,7 +887,7 @@ class OngekiBase:
}
async def handle_get_user_music_item_api_request(self, data: Dict) -> Dict:
user_music_item_list = self.data.item.get_music_items(data["userId"])
user_music_item_list = await self.data.item.get_music_items(data["userId"])
if user_music_item_list is None:
return {}
@@ -905,7 +905,7 @@ class OngekiBase:
}
async def handle_get_user_event_music_api_request(self, data: Dict) -> Dict:
user_evt_music_list = self.data.item.get_event_music(data["userId"])
user_evt_music_list = await self.data.item.get_event_music(data["userId"])
if user_evt_music_list is None:
return {}
@@ -923,7 +923,7 @@ class OngekiBase:
}
async def handle_get_user_boss_api_request(self, data: Dict) -> Dict:
p = self.data.item.get_bosses(data["userId"])
p = await self.data.item.get_bosses(data["userId"])
if p is None:
return {}
@@ -947,20 +947,20 @@ class OngekiBase:
# The isNew fields are new as of Red and up. We just won't use them for now.
if "userData" in upsert and len(upsert["userData"]) > 0:
self.data.profile.put_profile_data(
await self.data.profile.put_profile_data(
user_id, self.version, upsert["userData"][0]
)
if "userOption" in upsert and len(upsert["userOption"]) > 0:
self.data.profile.put_profile_options(user_id, upsert["userOption"][0])
await self.data.profile.put_profile_options(user_id, upsert["userOption"][0])
if "userPlaylogList" in upsert:
for playlog in upsert["userPlaylogList"]:
self.data.score.put_playlog(user_id, playlog)
await self.data.score.put_playlog(user_id, playlog)
if "userActivityList" in upsert:
for act in upsert["userActivityList"]:
self.data.profile.put_profile_activity(
await self.data.profile.put_profile_activity(
user_id,
act["kind"],
act["id"],
@@ -972,101 +972,101 @@ class OngekiBase:
)
if "userRecentRatingList" in upsert:
self.data.profile.put_profile_recent_rating(
await self.data.profile.put_profile_recent_rating(
user_id, upsert["userRecentRatingList"]
)
if "userBpBaseList" in upsert:
self.data.profile.put_profile_bp_list(user_id, upsert["userBpBaseList"])
await self.data.profile.put_profile_bp_list(user_id, upsert["userBpBaseList"])
if "userMusicDetailList" in upsert:
for x in upsert["userMusicDetailList"]:
self.data.score.put_best_score(user_id, x)
await self.data.score.put_best_score(user_id, x)
if "userCharacterList" in upsert:
for x in upsert["userCharacterList"]:
self.data.item.put_character(user_id, x)
await self.data.item.put_character(user_id, x)
if "userCardList" in upsert:
for x in upsert["userCardList"]:
self.data.item.put_card(user_id, x)
await self.data.item.put_card(user_id, x)
if "userDeckList" in upsert:
for x in upsert["userDeckList"]:
self.data.item.put_deck(user_id, x)
await self.data.item.put_deck(user_id, x)
if "userTrainingRoomList" in upsert:
for x in upsert["userTrainingRoomList"]:
self.data.profile.put_training_room(user_id, x)
await self.data.profile.put_training_room(user_id, x)
if "userStoryList" in upsert:
for x in upsert["userStoryList"]:
self.data.item.put_story(user_id, x)
await self.data.item.put_story(user_id, x)
if "userChapterList" in upsert:
for x in upsert["userChapterList"]:
self.data.item.put_chapter(user_id, x)
await self.data.item.put_chapter(user_id, x)
if "userMemoryChapterList" in upsert:
for x in upsert["userMemoryChapterList"]:
self.data.item.put_memorychapter(user_id, x)
await self.data.item.put_memorychapter(user_id, x)
if "userItemList" in upsert:
for x in upsert["userItemList"]:
self.data.item.put_item(user_id, x)
await self.data.item.put_item(user_id, x)
if "userMusicItemList" in upsert:
for x in upsert["userMusicItemList"]:
self.data.item.put_music_item(user_id, x)
await self.data.item.put_music_item(user_id, x)
if "userLoginBonusList" in upsert:
for x in upsert["userLoginBonusList"]:
self.data.item.put_login_bonus(user_id, x)
await self.data.item.put_login_bonus(user_id, x)
if "userEventPointList" in upsert:
for x in upsert["userEventPointList"]:
self.data.item.put_event_point(user_id, self.version, x)
await self.data.item.put_event_point(user_id, self.version, x)
if "userMissionPointList" in upsert:
for x in upsert["userMissionPointList"]:
self.data.item.put_mission_point(user_id, self.version, x)
await self.data.item.put_mission_point(user_id, self.version, x)
if "userRatinglogList" in upsert:
for x in upsert["userRatinglogList"]:
self.data.profile.put_profile_rating_log(
await self.data.profile.put_profile_rating_log(
user_id, x["dataVersion"], x["highestRating"]
)
if "userBossList" in upsert:
for x in upsert["userBossList"]:
self.data.item.put_boss(user_id, x)
await self.data.item.put_boss(user_id, x)
if "userTechCountList" in upsert:
for x in upsert["userTechCountList"]:
self.data.score.put_tech_count(user_id, x)
await self.data.score.put_tech_count(user_id, x)
if "userScenerioList" in upsert:
for x in upsert["userScenerioList"]:
self.data.item.put_scenerio(user_id, x)
await self.data.item.put_scenerio(user_id, x)
if "userTradeItemList" in upsert:
for x in upsert["userTradeItemList"]:
self.data.item.put_trade_item(user_id, x)
await self.data.item.put_trade_item(user_id, x)
if "userEventMusicList" in upsert:
for x in upsert["userEventMusicList"]:
self.data.item.put_event_music(user_id, x)
await self.data.item.put_event_music(user_id, x)
if "userTechEventList" in upsert:
for x in upsert["userTechEventList"]:
self.data.item.put_tech_event(user_id, self.version, x)
await self.data.item.put_tech_event(user_id, self.version, x)
# This should be updated once a day in maintenance window, but for time being we will push the update on each upsert
self.data.item.put_tech_event_ranking(user_id, self.version, x)
await self.data.item.put_tech_event_ranking(user_id, self.version, x)
if "userKopList" in upsert:
for x in upsert["userKopList"]:
self.data.profile.put_kop(user_id, x)
await self.data.profile.put_kop(user_id, x)
return {"returnCode": 1, "apiName": "upsertUserAll"}
@@ -1076,7 +1076,7 @@ class OngekiBase:
"""
rival_list = []
user_rivals = self.data.profile.get_rivals(data["userId"])
user_rivals = await self.data.profile.get_rivals(data["userId"])
for rival in user_rivals:
tmp = {}
tmp["rivalUserId"] = rival[0]
@@ -1100,7 +1100,7 @@ class OngekiBase:
"""
rivals = []
for rival in data["userRivalList"]:
name = self.data.profile.get_profile_name(
name = await self.data.profile.get_profile_name(
rival["rivalUserId"], self.version
)
if name is None:
@@ -1135,8 +1135,8 @@ class OngekiBase:
}
@cached(2)
def util_generate_music_list(self, user_id: int) -> List:
music_detail = self.data.score.get_best_scores(user_id)
async def util_generate_music_list(self, user_id: int) -> List:
music_detail = await self.data.score.get_best_scores(user_id)
song_list = []
for md in music_detail:

View File

@@ -23,11 +23,11 @@ class OngekiBright(OngekiBase):
async def handle_cm_get_user_data_api_request(self, data: Dict) -> Dict:
# check for a bright profile
p = self.data.profile.get_profile_data(data["userId"], self.version)
p = await self.data.profile.get_profile_data(data["userId"], self.version)
if p is None:
return {}
cards = self.data.card.get_user_cards(data["userId"])
cards = await self.data.card.get_user_cards(data["userId"])
if cards is None or len(cards) == 0:
# This should never happen
self.logger.error(
@@ -62,7 +62,7 @@ class OngekiBright(OngekiBase):
return {"returnCode": 1}
async def handle_cm_get_user_card_api_request(self, data: Dict) -> Dict:
user_cards = self.data.item.get_cards(data["userId"])
user_cards = await self.data.item.get_cards(data["userId"])
if user_cards is None:
return {}
@@ -91,7 +91,7 @@ class OngekiBright(OngekiBase):
}
async def handle_cm_get_user_character_api_request(self, data: Dict) -> Dict:
user_characters = self.data.item.get_characters(data["userId"])
user_characters = await self.data.item.get_characters(data["userId"])
if user_characters is None:
return {
"userId": data["userId"],
@@ -125,7 +125,7 @@ class OngekiBright(OngekiBase):
}
async def handle_get_user_gacha_api_request(self, data: Dict) -> Dict:
user_gachas = self.data.item.get_user_gachas(data["userId"])
user_gachas = await self.data.item.get_user_gachas(data["userId"])
if user_gachas is None:
return {"userId": data["userId"], "length": 0, "userGachaList": []}
@@ -148,7 +148,7 @@ class OngekiBright(OngekiBase):
async def handle_cm_get_user_gacha_supply_api_request(self, data: Dict) -> Dict:
# not used for now? not sure what it even does
user_gacha_supplies = self.data.item.get_user_gacha_supplies(data["userId"])
user_gacha_supplies = await self.data.item.get_user_gacha_supplies(data["userId"])
if user_gacha_supplies is None:
return {"supplyId": 1, "length": 0, "supplyCardList": []}
@@ -168,7 +168,7 @@ class OngekiBright(OngekiBase):
game_gachas = []
# for every gacha_id in the OngekiConfig, grab the banner from the db
for gacha_id in self.game_cfg.gachas.enabled_gachas:
game_gacha = self.data.static.get_gacha(self.version, gacha_id)
game_gacha = await self.data.static.get_gacha(self.version, gacha_id)
if game_gacha:
game_gachas.append(game_gacha)
@@ -265,26 +265,26 @@ class OngekiBright(OngekiBase):
return self.handle_roll_gacha_api_request(data)
# get a list of cards for each rarity
cards_r = self.data.static.get_cards_by_rarity(self.version, 1)
cards_r = await self.data.static.get_cards_by_rarity(self.version, 1)
cards_sr, cards_ssr = [], []
# free gachas are only allowed to get their specific cards! (R irrelevant)
if gacha_id in {1011, 1012}:
gacha_cards = self.data.static.get_gacha_cards(gacha_id)
gacha_cards = await self.data.static.get_gacha_cards(gacha_id)
for card in gacha_cards:
if card["rarity"] == 3:
cards_sr.append({"cardId": card["cardId"], "rarity": 2})
elif card["rarity"] == 4:
cards_ssr.append({"cardId": card["cardId"], "rarity": 3})
else:
cards_sr = self.data.static.get_cards_by_rarity(self.version, 2)
cards_ssr = self.data.static.get_cards_by_rarity(self.version, 3)
cards_sr = await self.data.static.get_cards_by_rarity(self.version, 2)
cards_ssr = await self.data.static.get_cards_by_rarity(self.version, 3)
# get the promoted cards for that gacha and add them multiple
# times to increase chances by factor chances
chances = 10
gacha_cards = self.data.static.get_gacha_cards(gacha_id)
gacha_cards = await self.data.static.get_gacha_cards(gacha_id)
for card in gacha_cards:
# make sure to add the cards to the corresponding rarity
if card["rarity"] == 2:
@@ -339,7 +339,7 @@ class OngekiBright(OngekiBase):
daily_gacha_date = datetime.strptime("2000-01-01", "%Y-%m-%d")
# check if the user previously rolled the exact same gacha
user_gacha = self.data.item.get_user_gacha(user_id, gacha_id)
user_gacha = await self.data.item.get_user_gacha(user_id, gacha_id)
if user_gacha:
total_gacha_count = user_gacha["totalGachaCnt"]
ceiling_gacha_count = user_gacha["ceilingGachaCnt"]
@@ -358,7 +358,7 @@ class OngekiBright(OngekiBase):
daily_gacha_date = play_date
daily_gacha_cnt = 0
self.data.item.put_user_gacha(
await self.data.item.put_user_gacha(
user_id,
gacha_id,
totalGachaCnt=total_gacha_count + gacha_count,
@@ -375,29 +375,29 @@ class OngekiBright(OngekiBase):
if "userData" in upsert and len(upsert["userData"]) > 0:
# check if the profile is a bright memory profile
p = self.data.profile.get_profile_data(data["userId"], self.version)
p = await self.data.profile.get_profile_data(data["userId"], self.version)
if p is not None:
# save the bright memory profile
self.data.profile.put_profile_data(
await self.data.profile.put_profile_data(
user_id, self.version, upsert["userData"][0]
)
else:
# save the bright profile
self.data.profile.put_profile_data(
await self.data.profile.put_profile_data(
user_id, self.version, upsert["userData"][0]
)
if "userCharacterList" in upsert:
for x in upsert["userCharacterList"]:
self.data.item.put_character(user_id, x)
await self.data.item.put_character(user_id, x)
if "userItemList" in upsert:
for x in upsert["userItemList"]:
self.data.item.put_item(user_id, x)
await self.data.item.put_item(user_id, x)
if "userCardList" in upsert:
for x in upsert["userCardList"]:
self.data.item.put_card(user_id, x)
await self.data.item.put_card(user_id, x)
# TODO?
# if "gameGachaCardList" in upsert:
@@ -411,29 +411,29 @@ class OngekiBright(OngekiBase):
if "userData" in upsert and len(upsert["userData"]) > 0:
# check if the profile is a bright memory profile
p = self.data.profile.get_profile_data(data["userId"], self.version)
p = await self.data.profile.get_profile_data(data["userId"], self.version)
if p is not None:
# save the bright memory profile
self.data.profile.put_profile_data(
await self.data.profile.put_profile_data(
user_id, self.version, upsert["userData"][0]
)
else:
# save the bright profile
self.data.profile.put_profile_data(
await self.data.profile.put_profile_data(
user_id, self.version, upsert["userData"][0]
)
if "userCharacterList" in upsert:
for x in upsert["userCharacterList"]:
self.data.item.put_character(user_id, x)
await self.data.item.put_character(user_id, x)
if "userCardList" in upsert:
for x in upsert["userCardList"]:
self.data.item.put_card(user_id, x)
await self.data.item.put_card(user_id, x)
if "selectGachaLogList" in data:
for x in data["selectGachaLogList"]:
self.data.item.put_user_gacha(
await self.data.item.put_user_gacha(
user_id,
x["gachaId"],
selectPoint=0,
@@ -443,7 +443,7 @@ class OngekiBright(OngekiBase):
return {"returnCode": 1, "apiName": "cmUpsertUserSelectGacha"}
async def handle_get_game_gacha_card_by_id_api_request(self, data: Dict) -> Dict:
game_gacha_cards = self.data.static.get_gacha_cards(data["gachaId"])
game_gacha_cards = await self.data.static.get_gacha_cards(data["gachaId"])
if game_gacha_cards == []:
# fallback to be at least able to select that gacha
return {
@@ -579,7 +579,7 @@ class OngekiBright(OngekiBase):
)
# add the entry to the user print table with the random serialId
self.data.item.put_user_print_detail(
await self.data.item.put_user_print_detail(
data["userId"], serial_id, user_print_detail
)
@@ -595,21 +595,21 @@ class OngekiBright(OngekiBase):
if "userData" in upsert and len(upsert["userData"]) > 0:
# check if the profile is a bright memory profile
p = self.data.profile.get_profile_data(data["userId"], self.version)
p = await self.data.profile.get_profile_data(data["userId"], self.version)
if p is not None:
# save the bright memory profile
self.data.profile.put_profile_data(
await self.data.profile.put_profile_data(
user_id, self.version, upsert["userData"][0]
)
else:
# save the bright profile
self.data.profile.put_profile_data(
await self.data.profile.put_profile_data(
user_id, self.version, upsert["userData"][0]
)
if "userActivityList" in upsert:
for act in upsert["userActivityList"]:
self.data.profile.put_profile_activity(
await self.data.profile.put_profile_activity(
user_id,
act["kind"],
act["id"],
@@ -622,10 +622,10 @@ class OngekiBright(OngekiBase):
if "userItemList" in upsert:
for x in upsert["userItemList"]:
self.data.item.put_item(user_id, x)
await self.data.item.put_item(user_id, x)
if "userCardList" in upsert:
for x in upsert["userCardList"]:
self.data.item.put_card(user_id, x)
await self.data.item.put_card(user_id, x)
return {"returnCode": 1, "apiName": "cmUpsertUserAll"}

View File

@@ -28,7 +28,7 @@ class OngekiBrightMemory(OngekiBright):
return ret
async def handle_get_user_memory_chapter_api_request(self, data: Dict) -> Dict:
memories = self.data.item.get_memorychapters(data["userId"])
memories = await self.data.item.get_memorychapters(data["userId"])
if not memories:
return {
"userId": data["userId"],

View File

@@ -28,7 +28,7 @@ class OngekiFrontend(FE_Base):
self.nav_name = "O.N.G.E.K.I."
self.version_list = OngekiConstants.VERSION_NAMES
def render_GET(self, request: Request) -> bytes:
async def render_GET(self, request: Request) -> bytes:
template = self.environment.get_template(
"titles/ongeki/frontend/ongeki_index.jinja"
)
@@ -37,7 +37,7 @@ class OngekiFrontend(FE_Base):
self.version = usr_sesh.ongeki_version
if getattr(usr_sesh, "userId", 0) != 0:
profile_data =self.data.profile.get_profile_data(usr_sesh.userId, self.version)
rival_list = self.data.profile.get_rivals(usr_sesh.userId)
rival_list = await self.data.profile.get_rivals(usr_sesh.userId)
rival_data = {
"userRivalList": rival_list,
"userId": usr_sesh.userId
@@ -58,20 +58,20 @@ class OngekiFrontend(FE_Base):
else:
return redirectTo(b"/gate/", request)
def render_POST(self, request: Request):
async def render_POST(self, request: Request):
uri = request.uri.decode()
sesh: Session = request.getSession()
usr_sesh = IUserSession(sesh)
if hasattr(usr_sesh, "userId"):
if uri == "/game/ongeki/rival.add":
rival_id = request.args[b"rivalUserId"][0].decode()
self.data.profile.put_rival(usr_sesh.userId, rival_id)
await self.data.profile.put_rival(usr_sesh.userId, rival_id)
# self.logger.info(f"{usr_sesh.userId} added a rival")
return redirectTo(b"/game/ongeki/", request)
elif uri == "/game/ongeki/rival.delete":
rival_id = request.args[b"rivalUserId"][0].decode()
self.data.profile.delete_rival(usr_sesh.userId, rival_id)
await self.data.profile.delete_rival(usr_sesh.userId, rival_id)
# self.logger.info(f"{response}")
return redirectTo(b"/game/ongeki/", request)

View File

@@ -1,16 +1,11 @@
from decimal import Decimal
import logging
import os
import re
import xml.etree.ElementTree as ET
from typing import Any, Dict, List, Optional
from typing import Optional
from read import BaseReader
from core.config import CoreConfig
from titles.ongeki.database import OngekiData
from titles.ongeki.const import OngekiConstants
from titles.ongeki.config import OngekiConfig
class OngekiReader(BaseReader):
def __init__(
@@ -32,7 +27,7 @@ class OngekiReader(BaseReader):
self.logger.error(f"Invalid ongeki version {version}")
exit(1)
def read(self) -> None:
async def read(self) -> None:
data_dirs = []
if self.bin_dir is not None:
data_dirs += self.get_data_directories(self.bin_dir)
@@ -41,12 +36,12 @@ class OngekiReader(BaseReader):
data_dirs += self.get_data_directories(self.opt_dir)
for dir in data_dirs:
self.read_events(f"{dir}/event")
self.read_music(f"{dir}/music")
self.read_card(f"{dir}/card")
self.read_reward(f"{dir}/reward")
await self.read_events(f"{dir}/event")
await self.read_music(f"{dir}/music")
await self.read_card(f"{dir}/card")
await self.read_reward(f"{dir}/reward")
def read_card(self, base_dir: str) -> None:
async def read_card(self, base_dir: str) -> None:
self.logger.info(f"Reading cards from {base_dir}...")
version_ids = {
@@ -70,7 +65,7 @@ class OngekiReader(BaseReader):
# skip already existing cards
if (
self.data.static.get_card(
await self.data.static.get_card(
OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY, card_id
)
is not None
@@ -100,7 +95,7 @@ class OngekiReader(BaseReader):
version = version_ids[troot.find("VersionID").find("id").text]
card_number = troot.find("CardNumberString").text
self.data.static.put_card(
await self.data.static.put_card(
version,
card_id,
name=name,
@@ -117,7 +112,7 @@ class OngekiReader(BaseReader):
)
self.logger.info(f"Added card {card_id}")
def read_events(self, base_dir: str) -> None:
async def read_events(self, base_dir: str) -> None:
self.logger.info(f"Reading events from {base_dir}...")
for root, dirs, files in os.walk(base_dir):
@@ -132,10 +127,10 @@ class OngekiReader(BaseReader):
troot.find("EventType").text
].value
self.data.static.put_event(self.version, id, event_type, name)
await self.data.static.put_event(self.version, id, event_type, name)
self.logger.info(f"Added event {id}")
def read_music(self, base_dir: str) -> None:
async def read_music(self, base_dir: str) -> None:
self.logger.info(f"Reading music from {base_dir}...")
for root, dirs, files in os.walk(base_dir):
@@ -168,12 +163,12 @@ class OngekiReader(BaseReader):
f"{fumens_data.find('FumenConstIntegerPart').text}.{fumens_data.find('FumenConstFractionalPart').text}"
)
self.data.static.put_chart(
await self.data.static.put_chart(
self.version, song_id, chart_id, title, artist, genre, level
)
self.logger.info(f"Added song {song_id} chart {chart_id}")
def read_reward(self, base_dir: str) -> None:
async def read_reward(self, base_dir: str) -> None:
self.logger.info(f"Reading rewards from {base_dir}...")
for root, dirs, files in os.walk(base_dir):
@@ -195,5 +190,5 @@ class OngekiReader(BaseReader):
itemKind = OngekiConstants.REWARD_TYPES[troot.find("ItemType").text].value
itemId = troot.find("RewardItem").find("ItemName").find("id").text
self.data.static.put_reward(self.version, rewardId, rewardname, itemKind, itemId)
await self.data.static.put_reward(self.version, rewardId, rewardname, itemKind, itemId)
self.logger.info(f"Added reward {rewardId}")

View File

@@ -339,147 +339,147 @@ print_detail = Table(
)
class OngekiItemData(BaseData):
def put_card(self, aime_id: int, card_data: Dict) -> Optional[int]:
async def put_card(self, aime_id: int, card_data: Dict) -> Optional[int]:
card_data["user"] = aime_id
sql = insert(card).values(**card_data)
conflict = sql.on_duplicate_key_update(**card_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"put_card: Failed to update! aime_id: {aime_id}")
return None
return result.lastrowid
def get_cards(self, aime_id: int) -> Optional[List[Dict]]:
async def get_cards(self, aime_id: int) -> Optional[List[Dict]]:
sql = select(card).where(card.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_character(self, aime_id: int, character_data: Dict) -> Optional[int]:
async def put_character(self, aime_id: int, character_data: Dict) -> Optional[int]:
character_data["user"] = aime_id
sql = insert(character).values(**character_data)
conflict = sql.on_duplicate_key_update(**character_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]]:
async def get_characters(self, aime_id: int) -> Optional[List[Dict]]:
sql = select(character).where(character.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_deck(self, aime_id: int, deck_data: Dict) -> Optional[int]:
async def put_deck(self, aime_id: int, deck_data: Dict) -> Optional[int]:
deck_data["user"] = aime_id
sql = insert(deck).values(**deck_data)
conflict = sql.on_duplicate_key_update(**deck_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]:
async 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)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_decks(self, aime_id: int) -> Optional[List[Dict]]:
async def get_decks(self, aime_id: int) -> Optional[List[Dict]]:
sql = select(deck).where(deck.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_boss(self, aime_id: int, boss_data: Dict) -> Optional[int]:
async def put_boss(self, aime_id: int, boss_data: Dict) -> Optional[int]:
boss_data["user"] = aime_id
sql = insert(boss).values(**boss_data)
conflict = sql.on_duplicate_key_update(**boss_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]:
async def put_story(self, aime_id: int, story_data: Dict) -> Optional[int]:
story_data["user"] = aime_id
sql = insert(story).values(**story_data)
conflict = sql.on_duplicate_key_update(**story_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]]:
async def get_stories(self, aime_id: int) -> Optional[List[Dict]]:
sql = select(story).where(story.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_chapter(self, aime_id: int, chapter_data: Dict) -> Optional[int]:
async def put_chapter(self, aime_id: int, chapter_data: Dict) -> Optional[int]:
chapter_data["user"] = aime_id
sql = insert(chapter).values(**chapter_data)
conflict = sql.on_duplicate_key_update(**chapter_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]]:
async def get_chapters(self, aime_id: int) -> Optional[List[Dict]]:
sql = select(chapter).where(chapter.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_item(self, aime_id: int, item_data: Dict) -> Optional[int]:
async def put_item(self, aime_id: int, item_data: Dict) -> Optional[int]:
item_data["user"] = aime_id
sql = insert(item).values(**item_data)
conflict = sql.on_duplicate_key_update(**item_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]:
async 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)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_items(self, aime_id: int, item_kind: int = None) -> Optional[List[Dict]]:
async 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:
@@ -487,73 +487,73 @@ class OngekiItemData(BaseData):
and_(item.c.user == aime_id, item.c.itemKind == item_kind)
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_music_item(self, aime_id: int, music_item_data: Dict) -> Optional[int]:
async def put_music_item(self, aime_id: int, music_item_data: Dict) -> Optional[int]:
music_item_data["user"] = aime_id
sql = insert(music_item).values(**music_item_data)
conflict = sql.on_duplicate_key_update(**music_item_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]]:
async 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)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_login_bonus(self, aime_id: int, login_bonus_data: Dict) -> Optional[int]:
async def put_login_bonus(self, aime_id: int, login_bonus_data: Dict) -> Optional[int]:
login_bonus_data["user"] = aime_id
sql = insert(login_bonus).values(**login_bonus_data)
conflict = sql.on_duplicate_key_update(**login_bonus_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]]:
async 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)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_mission_point(self, aime_id: int, version: int, mission_point_data: Dict) -> Optional[int]:
async def put_mission_point(self, aime_id: int, version: int, mission_point_data: Dict) -> Optional[int]:
mission_point_data["version"] = version
mission_point_data["user"] = aime_id
sql = insert(mission_point).values(**mission_point_data)
conflict = sql.on_duplicate_key_update(**mission_point_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"put_mission_point: Failed to update! aime_id: {aime_id}")
return None
return result.lastrowid
def get_mission_points(self, version: int, aime_id: int) -> Optional[List[Dict]]:
async def get_mission_points(self, version: int, aime_id: int) -> Optional[List[Dict]]:
sql = select(mission_point).where(and_(mission_point.c.user == aime_id, mission_point.c.version == version))
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_event_point(self, aime_id: int, version: int, event_point_data: Dict) -> Optional[int]:
async def put_event_point(self, aime_id: int, version: int, event_point_data: Dict) -> Optional[int]:
# We update only the newest (type: 1) entry, in official spec game watches for both latest(type:1) and previous (type:2) entries to give an additional info how many ranks has player moved up or down
# This fully featured is on TODO list, at the moment we just update the tables as data comes and give out rank as request comes
event_point_data["user"] = aime_id
@@ -564,95 +564,95 @@ class OngekiItemData(BaseData):
sql = insert(event_point).values(**event_point_data)
conflict = sql.on_duplicate_key_update(**event_point_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]]:
async 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)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_scenerio(self, aime_id: int, scenerio_data: Dict) -> Optional[int]:
async def put_scenerio(self, aime_id: int, scenerio_data: Dict) -> Optional[int]:
scenerio_data["user"] = aime_id
sql = insert(scenerio).values(**scenerio_data)
conflict = sql.on_duplicate_key_update(**scenerio_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]]:
async def get_scenerios(self, aime_id: int) -> Optional[List[Dict]]:
sql = select(scenerio).where(scenerio.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_trade_item(self, aime_id: int, trade_item_data: Dict) -> Optional[int]:
async def put_trade_item(self, aime_id: int, trade_item_data: Dict) -> Optional[int]:
trade_item_data["user"] = aime_id
sql = insert(trade_item).values(**trade_item_data)
conflict = sql.on_duplicate_key_update(**trade_item_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]]:
async 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)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_event_music(self, aime_id: int, event_music_data: Dict) -> Optional[int]:
async def put_event_music(self, aime_id: int, event_music_data: Dict) -> Optional[int]:
event_music_data["user"] = aime_id
sql = insert(event_music).values(**event_music_data)
conflict = sql.on_duplicate_key_update(**event_music_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]]:
async 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)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_tech_event(self, aime_id: int, version: int, tech_event_data: Dict) -> Optional[int]:
async def put_tech_event(self, aime_id: int, version: int, tech_event_data: Dict) -> Optional[int]:
tech_event_data["user"] = aime_id
tech_event_data["version"] = version
sql = insert(tech_event).values(**tech_event_data)
conflict = sql.on_duplicate_key_update(**tech_event_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"put_tech_event: Failed to update! aime_id: {aime_id}")
return None
return result.lastrowid
def put_tech_event_ranking(self, aime_id: int, version: int, tech_event_data: Dict) -> Optional[int]:
async def put_tech_event_ranking(self, aime_id: int, version: int, tech_event_data: Dict) -> Optional[int]:
tech_event_data["user"] = aime_id
tech_event_data["version"] = version
tech_event_data.pop("isRankingRewarded")
@@ -662,87 +662,87 @@ class OngekiItemData(BaseData):
sql = insert(tech_ranking).values(**tech_event_data)
conflict = sql.on_duplicate_key_update(**tech_event_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"put_tech_event_ranking: Failed to update ranking! aime_id {aime_id}")
return None
return result.lastrowid
def get_tech_event(self, version: int, aime_id: int) -> Optional[List[Dict]]:
async def get_tech_event(self, version: int, aime_id: int) -> Optional[List[Dict]]:
sql = select(tech_event).where(and_(tech_event.c.user == aime_id, tech_event.c.version == version))
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def get_bosses(self, aime_id: int) -> Optional[List[Dict]]:
async def get_bosses(self, aime_id: int) -> Optional[List[Dict]]:
sql = select(boss).where(boss.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_memorychapter(
async def put_memorychapter(
self, aime_id: int, memorychapter_data: Dict
) -> Optional[int]:
memorychapter_data["user"] = aime_id
sql = insert(memorychapter).values(**memorychapter_data)
conflict = sql.on_duplicate_key_update(**memorychapter_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"put_memorychapter: Failed to update! aime_id: {aime_id}")
return None
return result.lastrowid
def get_memorychapters(self, aime_id: int) -> Optional[List[Dict]]:
async def get_memorychapters(self, aime_id: int) -> Optional[List[Dict]]:
sql = select(memorychapter).where(memorychapter.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def get_user_gacha(self, aime_id: int, gacha_id: int) -> Optional[Row]:
async 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))
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_user_gachas(self, aime_id: int) -> Optional[List[Row]]:
async def get_user_gachas(self, aime_id: int) -> Optional[List[Row]]:
sql = gacha.select(gacha.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def get_user_gacha_supplies(self, aime_id: int) -> Optional[List[Row]]:
async def get_user_gacha_supplies(self, aime_id: int) -> Optional[List[Row]]:
sql = gacha_supply.select(gacha_supply.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_user_gacha(self, aime_id: int, gacha_id: int, **data) -> Optional[int]:
async 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)
conflict = sql.on_duplicate_key_update(user=aime_id, gachaId=gacha_id, **data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"put_user_gacha: Failed to insert! aime_id: {aime_id}")
return None
return result.lastrowid
def put_user_print_detail(
async def put_user_print_detail(
self, aime_id: int, serial_id: str, user_print_data: Dict
) -> Optional[int]:
sql = insert(print_detail).values(
@@ -750,7 +750,7 @@ class OngekiItemData(BaseData):
)
conflict = sql.on_duplicate_key_update(user=aime_id, **user_print_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(
@@ -760,18 +760,18 @@ class OngekiItemData(BaseData):
return result.lastrowid
def get_ranking_event_ranks(self, version: int, aime_id: int) -> Optional[List[Dict]]:
async def get_ranking_event_ranks(self, version: int, aime_id: int) -> Optional[List[Dict]]:
# Calculates player rank on GameRequest from server, and sends it back, official spec would rank players in maintenance period, on TODO list
sql = select(event_point.c.id, event_point.c.user, event_point.c.eventId, event_point.c.type, func.row_number().over(partition_by=event_point.c.eventId, order_by=event_point.c.point.desc()).label('rank'), event_point.c.date, event_point.c.point).where(event_point.c.version == version)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
self.logger.error(f"failed to rank aime_id: {aime_id} ranking event positions")
return None
return result.fetchall()
def get_tech_event_ranking(self, version: int, aime_id: int) -> Optional[List[Dict]]:
async def get_tech_event_ranking(self, version: int, aime_id: int) -> Optional[List[Dict]]:
sql = select(tech_ranking.c.id, tech_ranking.c.user, tech_ranking.c.date, tech_ranking.c.eventId, func.row_number().over(partition_by=tech_ranking.c.eventId, order_by=[tech_ranking.c.totalTechScore.desc(),tech_ranking.c.totalPlatinumScore.desc()]).label('rank'), tech_ranking.c.totalTechScore, tech_ranking.c.totalPlatinumScore).where(tech_ranking.c.version == version)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
self.logger.warning(f"aime_id: {aime_id} has no tech ranking ranks")
return None

View File

@@ -39,7 +39,7 @@ session_log = Table(
class OngekiLogData(BaseData):
def put_gp_log(
async def put_gp_log(
self,
aime_id: Optional[int],
used_credit: int,
@@ -61,7 +61,7 @@ class OngekiLogData(BaseData):
currentGP=current_gp,
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
self.logger.warning(
f"put_gp_log: Failed to insert GP log! aime_id: {aime_id} kind {kind} pattern {pattern} current_gp {current_gp}"

View File

@@ -255,12 +255,12 @@ class OngekiProfileData(BaseData):
)
self.date_time_format_short = "%Y-%m-%d"
def get_profile_name(self, aime_id: int, version: int) -> Optional[str]:
async 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)
result = await self.execute(sql)
if result is None:
return None
@@ -270,19 +270,19 @@ class OngekiProfileData(BaseData):
return row["userName"]
def get_profile_preview(self, aime_id: int, version: int) -> Optional[Row]:
async 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)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_profile_data(self, aime_id: int, version: int) -> Optional[Row]:
async def get_profile_data(self, aime_id: int, version: int) -> Optional[Row]:
sql = select(profile).where(
and_(
profile.c.user == aime_id,
@@ -290,40 +290,40 @@ class OngekiProfileData(BaseData):
)
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_profile_options(self, aime_id: int) -> Optional[Row]:
async def get_profile_options(self, aime_id: int) -> Optional[Row]:
sql = select(option).where(
and_(
option.c.user == aime_id,
)
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_profile_recent_rating(self, aime_id: int) -> Optional[List[Row]]:
async 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)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_profile_rating_log(self, aime_id: int) -> Optional[List[Row]]:
async def get_profile_rating_log(self, aime_id: int) -> Optional[List[Row]]:
sql = select(rating_log).where(rating_log.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def get_profile_activity(
async def get_profile_activity(
self, aime_id: int, kind: int = None
) -> Optional[List[Row]]:
sql = select(activity).where(
@@ -333,47 +333,47 @@ class OngekiProfileData(BaseData):
)
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def get_kop(self, aime_id: int) -> Optional[List[Row]]:
async def get_kop(self, aime_id: int) -> Optional[List[Row]]:
sql = select(kop).where(kop.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def get_rivals(self, aime_id: int) -> Optional[List[Row]]:
async def get_rivals(self, aime_id: int) -> Optional[List[Row]]:
sql = select(rival.c.rivalUserId).where(rival.c.user == aime_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_profile_data(self, aime_id: int, version: int, data: Dict) -> Optional[int]:
async def put_profile_data(self, aime_id: int, version: int, data: Dict) -> Optional[int]:
data["user"] = aime_id
data["version"] = version
data.pop("accessCode")
sql = insert(profile).values(**data)
conflict = sql.on_duplicate_key_update(**data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"put_profile_data: Failed to update! aime_id: {aime_id}")
return None
return result.lastrowid
def put_profile_options(self, aime_id: int, options_data: Dict) -> Optional[int]:
async def put_profile_options(self, aime_id: int, options_data: Dict) -> Optional[int]:
options_data["user"] = aime_id
sql = insert(option).values(**options_data)
conflict = sql.on_duplicate_key_update(**options_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(
@@ -382,7 +382,7 @@ class OngekiProfileData(BaseData):
return None
return result.lastrowid
def put_profile_recent_rating(
async def put_profile_recent_rating(
self, aime_id: int, recent_rating_data: List[Dict]
) -> Optional[int]:
sql = insert(recent_rating).values(
@@ -391,7 +391,7 @@ class OngekiProfileData(BaseData):
conflict = sql.on_duplicate_key_update(recentRating=recent_rating_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(
f"put_profile_recent_rating: failed to update recent rating! aime_id {aime_id}"
@@ -399,12 +399,12 @@ class OngekiProfileData(BaseData):
return None
return result.lastrowid
def put_profile_bp_list(
async def put_profile_bp_list(
self, aime_id: int, bp_base_list: List[Dict]
) -> Optional[int]:
pass
def put_profile_rating_log(
async def put_profile_rating_log(
self, aime_id: int, data_version: str, highest_rating: int
) -> Optional[int]:
sql = insert(rating_log).values(
@@ -413,7 +413,7 @@ class OngekiProfileData(BaseData):
conflict = sql.on_duplicate_key_update(highestRating=highest_rating)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(
f"put_profile_rating_log: failed to update rating log! aime_id {aime_id} data_version {data_version} highest_rating {highest_rating}"
@@ -421,7 +421,7 @@ class OngekiProfileData(BaseData):
return None
return result.lastrowid
def put_profile_activity(
async def put_profile_activity(
self,
aime_id: int,
kind: int,
@@ -447,7 +447,7 @@ class OngekiProfileData(BaseData):
sortNumber=sort_num, param1=p1, param2=p2, param3=p3, param4=p4
)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(
f"put_profile_activity: failed to put activity! aime_id {aime_id} kind {kind} activity_id {activity_id}"
@@ -455,7 +455,7 @@ class OngekiProfileData(BaseData):
return None
return result.lastrowid
def put_profile_region(self, aime_id: int, region: int, date: str) -> Optional[int]:
async 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
)
@@ -464,7 +464,7 @@ class OngekiProfileData(BaseData):
playCount=activity.c.playCount + 1,
)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(
f"put_profile_region: failed to update! aime_id {aime_id} region {region}"
@@ -472,45 +472,45 @@ class OngekiProfileData(BaseData):
return None
return result.lastrowid
def put_training_room(self, aime_id: int, room_detail: Dict) -> Optional[int]:
async def put_training_room(self, aime_id: int, room_detail: Dict) -> Optional[int]:
room_detail["user"] = aime_id
sql = insert(training_room).values(**room_detail)
conflict = sql.on_duplicate_key_update(**room_detail)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]:
async def put_kop(self, aime_id: int, kop_data: Dict) -> Optional[int]:
kop_data["user"] = aime_id
sql = insert(kop).values(**kop_data)
conflict = sql.on_duplicate_key_update(**kop_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]:
async 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(rivalUserId=rival_id)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(
f"put_rival: failed to update! aime_id: {aime_id}, rival_id: {rival_id}"
)
return None
return result.lastrowid
def delete_rival(self, aime_id: int, rival_id: int) -> Optional[int]:
async def delete_rival(self, aime_id: int, rival_id: int) -> Optional[int]:
sql = delete(rival).where(rival.c.user==aime_id, rival.c.rivalUserId==rival_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
self.logger.error(f"delete_rival: failed to delete! aime_id: {aime_id}, rival_id: {rival_id}")
else:

View File

@@ -128,52 +128,52 @@ tech_count = Table(
class OngekiScoreData(BaseData):
def get_tech_count(self, aime_id: int) -> Optional[List[Dict]]:
async 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]:
async def put_tech_count(self, aime_id: int, tech_count_data: Dict) -> Optional[int]:
tech_count_data["user"] = aime_id
sql = insert(tech_count).values(**tech_count_data)
conflict = sql.on_duplicate_key_update(**tech_count_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(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]]:
async 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)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def get_best_score(
async 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]:
async def put_best_score(self, aime_id: int, music_detail: Dict) -> Optional[int]:
music_detail["user"] = aime_id
sql = insert(score_best).values(**music_detail)
conflict = sql.on_duplicate_key_update(**music_detail)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"put_best_score: Failed to add score! aime_id: {aime_id}")
return None
return result.lastrowid
def put_playlog(self, aime_id: int, playlog_data: Dict) -> Optional[int]:
async def put_playlog(self, aime_id: int, playlog_data: Dict) -> Optional[int]:
playlog_data["user"] = aime_id
sql = insert(playlog).values(**playlog_data)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
self.logger.warning(f"put_playlog: Failed to add playlog! aime_id: {aime_id}")
return None

View File

@@ -188,26 +188,26 @@ game_point = Table(
)
class OngekiStaticData(BaseData):
def put_card(self, version: int, card_id: int, **card_data) -> Optional[int]:
async def put_card(self, version: int, card_id: int, **card_data) -> Optional[int]:
sql = insert(cards).values(version=version, cardId=card_id, **card_data)
conflict = sql.on_duplicate_key_update(**card_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"Failed to insert card! card_id {card_id}")
return None
return result.lastrowid
def get_card(self, version: int, card_id: int) -> Optional[Dict]:
async def get_card(self, version: int, card_id: int) -> Optional[Dict]:
sql = cards.select(and_(cards.c.version <= version, cards.c.cardId == card_id))
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_card_by_card_number(self, version: int, card_number: str) -> Optional[Dict]:
async def get_card_by_card_number(self, version: int, card_number: str) -> Optional[Dict]:
if not card_number.startswith("[O.N.G.E.K.I.]"):
card_number = f"[O.N.G.E.K.I.]{card_number}"
@@ -215,36 +215,36 @@ class OngekiStaticData(BaseData):
and_(cards.c.version <= version, cards.c.cardNumber == card_number)
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_card_by_name(self, version: int, name: str) -> Optional[Dict]:
async def get_card_by_name(self, version: int, name: str) -> Optional[Dict]:
sql = cards.select(and_(cards.c.version <= version, cards.c.name == name))
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_cards(self, version: int) -> Optional[List[Dict]]:
async def get_cards(self, version: int) -> Optional[List[Dict]]:
sql = cards.select(cards.c.version <= version)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def get_cards_by_rarity(self, version: int, rarity: int) -> Optional[List[Dict]]:
async 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))
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_gacha(
async def put_gacha(
self,
version: int,
gacha_id: int,
@@ -268,33 +268,33 @@ class OngekiStaticData(BaseData):
**gacha_data,
)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"Failed to insert gacha! gacha_id {gacha_id}")
return None
return result.lastrowid
def get_gacha(self, version: int, gacha_id: int) -> Optional[Dict]:
async def get_gacha(self, version: int, gacha_id: int) -> Optional[Dict]:
sql = gachas.select(
and_(gachas.c.version <= version, gachas.c.gachaId == gacha_id)
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_gachas(self, version: int) -> Optional[List[Dict]]:
async def get_gachas(self, version: int) -> Optional[List[Dict]]:
sql = gachas.select(gachas.c.version == version).order_by(
gachas.c.gachaId.asc()
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_gacha_card(
async 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)
@@ -303,21 +303,21 @@ class OngekiStaticData(BaseData):
gachaId=gacha_id, cardId=card_id, **gacha_card
)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"Failed to insert gacha card! gacha_id {gacha_id}")
return None
return result.lastrowid
def get_gacha_cards(self, gacha_id: int) -> Optional[List[Dict]]:
async def get_gacha_cards(self, gacha_id: int) -> Optional[List[Dict]]:
sql = gacha_cards.select(gacha_cards.c.gachaId == gacha_id)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_event(
async def put_event(
self, version: int, event_id: int, event_type: int, event_name: str
) -> Optional[int]:
sql = insert(events).values(
@@ -332,41 +332,41 @@ class OngekiStaticData(BaseData):
name=event_name,
)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"Failed to insert event! event_id {event_id}")
return None
return result.lastrowid
def get_event(self, version: int, event_id: int) -> Optional[List[Dict]]:
async 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)
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def get_events(self, version: int) -> Optional[List[Dict]]:
async def get_events(self, version: int) -> Optional[List[Dict]]:
sql = select(events).where(events.c.version == version)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def get_enabled_events(self, version: int) -> Optional[List[Dict]]:
async 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)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_chart(
async def put_chart(
self,
version: int,
song_id: int,
@@ -393,7 +393,7 @@ class OngekiStaticData(BaseData):
level=level,
)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(
f"Failed to insert chart! song_id: {song_id}, chart_id: {chart_id}"
@@ -401,15 +401,15 @@ class OngekiStaticData(BaseData):
return None
return result.lastrowid
def get_chart(
async 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]]:
async def get_music(self, version: int) -> Optional[List[Dict]]:
pass
def get_music_chart(
async def get_music_chart(
self, version: int, song_id: int, chart_id: int
) -> Optional[List[Row]]:
sql = select(music).where(
@@ -420,19 +420,19 @@ class OngekiStaticData(BaseData):
)
)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
def get_ranking_list(self, version: int) -> Optional[List[Dict]]:
async def get_ranking_list(self, version: int) -> Optional[List[Dict]]:
sql = select(music_ranking.c.musicId.label('id'), music_ranking.c.point, music_ranking.c.userName).where(music_ranking.c.version == version)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_reward(self, version: int, rewardId: int, rewardname: str, itemKind: int, itemId: int) -> Optional[int]:
async def put_reward(self, version: int, rewardId: int, rewardname: str, itemKind: int, itemId: int) -> Optional[int]:
sql = insert(rewards).values(
version=version,
rewardId=rewardId,
@@ -443,70 +443,70 @@ class OngekiStaticData(BaseData):
conflict = sql.on_duplicate_key_update(
rewardname=rewardname,
)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"Failed to insert reward! reward_id: {rewardId}")
return None
return result.lastrowid
def get_reward_list(self, version: int) -> Optional[List[Dict]]:
async def get_reward_list(self, version: int) -> Optional[List[Dict]]:
sql = select(rewards).where(rewards.c.version == version)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
self.logger.warning(f"Failed to load reward list")
return None
return result.fetchall()
def get_present_list(self, version: int) -> Optional[List[Dict]]:
async def get_present_list(self, version: int) -> Optional[List[Dict]]:
sql = select(present).where(present.c.version == version)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
self.logger.warning(f"Failed to load present list")
return None
return result.fetchall()
def get_tech_music(self, version: int) -> Optional[List[Dict]]:
async def get_tech_music(self, version: int) -> Optional[List[Dict]]:
sql = select(tech_music).where(tech_music.c.version == version)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()
def put_client_testmode_data(self, region_id: int, client_testmode_data: Dict) -> Optional[List[Dict]]:
async def put_client_testmode_data(self, region_id: int, client_testmode_data: Dict) -> Optional[List[Dict]]:
sql = insert(client_testmode).values(regionId=region_id, **client_testmode_data)
conflict = sql.on_duplicate_key_update(regionId=region_id, **client_testmode_data)
result = self.execute(conflict)
result = await self.execute(conflict)
if result is None:
self.logger.warning(f"region_id: {region_id} Failed to update ClientTestMode data"),
return None
return result.lastrowid
def put_client_setting_data(self, machine_id: int, client_setting_data: Dict) -> Optional[List[Dict]]:
async def put_client_setting_data(self, machine_id: int, client_setting_data: Dict) -> Optional[List[Dict]]:
sql = machine.update(machine.c.id == machine_id).values(data=client_setting_data)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
self.logger.warning(f"machine_id: {machine_id} Failed to update ClientSetting data"),
return None
return result.lastrowid
def put_static_game_point_defaults(self) -> Optional[List[Dict]]:
async def put_static_game_point_defaults(self) -> Optional[List[Dict]]:
game_point_defaults = [{"type": 0, "cost": 100},{"type": 1, "cost": 230},{"type": 2, "cost": 370},{"type": 3, "cost": 120},{"type": 4, "cost": 240},{"type": 5, "cost": 360}]
sql = insert(game_point).values(game_point_defaults)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
self.logger.warning(f"Failed to insert default GP table!")
return None
return result.lastrowid
def get_static_game_point(self) -> Optional[List[Dict]]:
async def get_static_game_point(self) -> Optional[List[Dict]]:
sql = select(game_point.c.type, game_point.c.cost, game_point.c.startDate, game_point.c.endDate)
result = self.execute(sql)
result = await self.execute(sql)
if result is None:
return None
return result.fetchall()