mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-02-15 04:07:29 +08:00
move to async database
This commit is contained in:
@@ -98,9 +98,9 @@ class WaccaBase:
|
||||
req = HousingStartRequestV1(data)
|
||||
allnet_region_id = None
|
||||
|
||||
machine = self.data.arcade.get_machine(req.chipId)
|
||||
machine = await self.data.arcade.get_machine(req.chipId)
|
||||
if machine is not None:
|
||||
arcade = self.data.arcade.get_arcade(machine["arcade"])
|
||||
arcade = await self.data.arcade.get_arcade(machine["arcade"])
|
||||
allnet_region_id = arcade["region_id"]
|
||||
|
||||
if req.appVersion.country == AllnetCountryCode.JAPAN.value:
|
||||
@@ -139,7 +139,7 @@ class WaccaBase:
|
||||
req = UserStatusGetRequest(data)
|
||||
resp = UserStatusGetV1Response()
|
||||
|
||||
profile = self.data.profile.get_profile(aime_id=req.aimeId)
|
||||
profile = await self.data.profile.get_profile(aime_id=req.aimeId)
|
||||
if profile is None:
|
||||
self.logger.info(f"No user exists for aime id {req.aimeId}")
|
||||
resp.profileStatus = ProfileStatus.ProfileRegister
|
||||
@@ -159,14 +159,14 @@ class WaccaBase:
|
||||
resp.userStatus.wp = profile["wp"]
|
||||
resp.userStatus.useCount = profile["login_count"]
|
||||
|
||||
set_title_id = self.data.profile.get_options(
|
||||
set_title_id = await self.data.profile.get_options(
|
||||
WaccaConstants.OPTIONS["set_title_id"], profile["user"]
|
||||
)
|
||||
if set_title_id is None:
|
||||
set_title_id = self.OPTIONS_DEFAULTS["set_title_id"]
|
||||
resp.setTitleId = set_title_id
|
||||
|
||||
set_icon_id = self.data.profile.get_options(
|
||||
set_icon_id = await self.data.profile.get_options(
|
||||
WaccaConstants.OPTIONS["set_title_id"], profile["user"]
|
||||
)
|
||||
if set_icon_id is None:
|
||||
@@ -191,7 +191,7 @@ class WaccaBase:
|
||||
resp.lastLoginDate = 0
|
||||
|
||||
else:
|
||||
profile = self.data.profile.get_profile(req.userId)
|
||||
profile = await self.data.profile.get_profile(req.userId)
|
||||
if profile is None:
|
||||
self.logger.warning(
|
||||
f"Unknown user id {req.userId} attempted login from {req.chipId}"
|
||||
@@ -215,7 +215,7 @@ class WaccaBase:
|
||||
if midnight_today_ts - last_login_time > 86400:
|
||||
is_consec_day = False
|
||||
|
||||
self.data.profile.session_login(
|
||||
await self.data.profile.session_login(
|
||||
req.userId, resp.firstLoginDaily, is_consec_day
|
||||
)
|
||||
|
||||
@@ -230,7 +230,7 @@ class WaccaBase:
|
||||
async def handle_user_status_create_request(self, data: Dict) -> Dict:
|
||||
req = UserStatusCreateRequest(data)
|
||||
|
||||
profileId = self.data.profile.create_profile(
|
||||
profileId = await self.data.profile.create_profile(
|
||||
req.aimeId, req.username, self.version
|
||||
)
|
||||
|
||||
@@ -239,30 +239,30 @@ class WaccaBase:
|
||||
|
||||
if profileId == 0:
|
||||
# We've already made this profile, just return success
|
||||
new_user = self.data.profile.get_profile(aime_id=req.aimeId)
|
||||
new_user = await self.data.profile.get_profile(aime_id=req.aimeId)
|
||||
profileId = new_user['id']
|
||||
|
||||
# Insert starting items
|
||||
self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104001)
|
||||
self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104002)
|
||||
self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104003)
|
||||
self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104005)
|
||||
await self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104001)
|
||||
await self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104002)
|
||||
await self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104003)
|
||||
await self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["title"], 104005)
|
||||
|
||||
self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["icon"], 102001)
|
||||
self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["icon"], 102002)
|
||||
await self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["icon"], 102001)
|
||||
await self.data.item.put_item(req.aimeId, WaccaConstants.ITEM_TYPES["icon"], 102002)
|
||||
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["note_color"], 103001
|
||||
)
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["note_color"], 203001
|
||||
)
|
||||
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["note_sound"], 105001
|
||||
)
|
||||
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210001
|
||||
)
|
||||
|
||||
@@ -272,7 +272,7 @@ class WaccaBase:
|
||||
req = UserStatusGetDetailRequest(data)
|
||||
resp = UserStatusGetDetailResponseV1()
|
||||
|
||||
profile = self.data.profile.get_profile(req.userId)
|
||||
profile = await self.data.profile.get_profile(req.userId)
|
||||
if profile is None:
|
||||
self.logger.warning(f"Unknown profile {req.userId}")
|
||||
return resp.make()
|
||||
@@ -280,12 +280,12 @@ class WaccaBase:
|
||||
self.logger.info(f"Get detail for profile {req.userId}")
|
||||
user_id = profile["user"]
|
||||
|
||||
profile_scores = self.data.score.get_best_scores(user_id)
|
||||
profile_items = self.data.item.get_items(user_id)
|
||||
profile_song_unlocks = self.data.item.get_song_unlocks(user_id)
|
||||
profile_options = self.data.profile.get_options(user_id)
|
||||
profile_trophies = self.data.item.get_trophies(user_id)
|
||||
profile_tickets = self.data.item.get_tickets(user_id)
|
||||
profile_scores = await self.data.score.get_best_scores(user_id)
|
||||
profile_items = await self.data.item.get_items(user_id)
|
||||
profile_song_unlocks = await self.data.item.get_song_unlocks(user_id)
|
||||
profile_options = await self.data.profile.get_options(user_id)
|
||||
profile_trophies = await self.data.item.get_trophies(user_id)
|
||||
profile_tickets = await self.data.item.get_tickets(user_id)
|
||||
|
||||
resp.songUpdateTime = int(profile["last_login_date"].timestamp())
|
||||
resp.songPlayStatus = [profile["last_song_id"], 1]
|
||||
@@ -437,7 +437,7 @@ class WaccaBase:
|
||||
req = UserTrialGetRequest(data)
|
||||
resp = UserTrialGetResponse()
|
||||
|
||||
user_id = self.data.profile.profile_to_aime_user(req.profileId)
|
||||
user_id = await self.data.profile.profile_to_aime_user(req.profileId)
|
||||
if user_id is None:
|
||||
self.logger.error(
|
||||
f"handle_user_trial_get_request: No profile with id {req.profileId}"
|
||||
@@ -445,7 +445,7 @@ class WaccaBase:
|
||||
return resp.make()
|
||||
|
||||
self.logger.info(f"Get trial info for user {req.profileId}")
|
||||
stages = self.data.score.get_stageup(user_id, self.version)
|
||||
stages = await self.data.score.get_stageup(user_id, self.version)
|
||||
if stages is None:
|
||||
stages = []
|
||||
|
||||
@@ -485,15 +485,15 @@ class WaccaBase:
|
||||
while len(req.songScores) < 3:
|
||||
req.songScores.append(0)
|
||||
|
||||
profile = self.data.profile.get_profile(req.profileId)
|
||||
profile = await self.data.profile.get_profile(req.profileId)
|
||||
|
||||
user_id = profile["user"]
|
||||
old_stage = self.data.score.get_stageup_stage(
|
||||
old_stage = await self.data.score.get_stageup_stage(
|
||||
user_id, self.version, req.stageId
|
||||
)
|
||||
|
||||
if old_stage is None:
|
||||
self.data.score.put_stageup(
|
||||
await self.data.score.put_stageup(
|
||||
user_id,
|
||||
self.version,
|
||||
req.stageId,
|
||||
@@ -519,7 +519,7 @@ class WaccaBase:
|
||||
best_score2 = old_stage["song2_score"]
|
||||
best_score3 = old_stage["song3_score"]
|
||||
|
||||
self.data.score.put_stageup(
|
||||
await self.data.score.put_stageup(
|
||||
user_id,
|
||||
self.version,
|
||||
req.stageId,
|
||||
@@ -537,17 +537,17 @@ class WaccaBase:
|
||||
req.stageLevel == profile["dan_level"]
|
||||
and req.clearType.value > profile["dan_type"]
|
||||
):
|
||||
self.data.profile.update_profile_dan(
|
||||
await self.data.profile.update_profile_dan(
|
||||
req.profileId, req.stageLevel, req.clearType.value
|
||||
)
|
||||
|
||||
self.util_put_items(req.profileId, user_id, req.itemsObtained)
|
||||
await self.util_put_items(req.profileId, user_id, req.itemsObtained)
|
||||
|
||||
# user/status/update isn't called after stageup so we have to do some things now
|
||||
current_icon = self.data.profile.get_options(
|
||||
current_icon = await self.data.profile.get_options(
|
||||
user_id, WaccaConstants.OPTIONS["set_icon_id"]
|
||||
)
|
||||
current_nav = self.data.profile.get_options(
|
||||
current_nav = await self.data.profile.get_options(
|
||||
user_id, WaccaConstants.OPTIONS["set_nav_id"]
|
||||
)
|
||||
|
||||
@@ -560,13 +560,13 @@ class WaccaBase:
|
||||
else:
|
||||
current_nav = current_nav["value"]
|
||||
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
user_id, WaccaConstants.ITEM_TYPES["icon"], current_icon
|
||||
)
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
user_id, WaccaConstants.ITEM_TYPES["navigator"], current_nav
|
||||
)
|
||||
self.data.profile.update_profile_playtype(
|
||||
await self.data.profile.update_profile_playtype(
|
||||
req.profileId, 4, data["appVersion"][:7]
|
||||
)
|
||||
return BaseResponse().make()
|
||||
@@ -583,16 +583,16 @@ class WaccaBase:
|
||||
req = UserSugarokuUpdateRequestV2(data)
|
||||
mission_flg = req.mission_flag
|
||||
|
||||
user_id = self.data.profile.profile_to_aime_user(req.profileId)
|
||||
user_id = await self.data.profile.profile_to_aime_user(req.profileId)
|
||||
if user_id is None:
|
||||
self.logger.info(
|
||||
f"handle_user_sugoroku_update_request unknwon profile ID {req.profileId}"
|
||||
)
|
||||
return resp.make()
|
||||
|
||||
self.util_put_items(req.profileId, user_id, req.itemsObtainted)
|
||||
await self.util_put_items(req.profileId, user_id, req.itemsObtainted)
|
||||
|
||||
self.data.profile.update_gate(
|
||||
await self.data.profile.update_gate(
|
||||
user_id,
|
||||
req.gateId,
|
||||
req.page,
|
||||
@@ -609,13 +609,13 @@ class WaccaBase:
|
||||
async def handle_user_music_unlock_request(self, data: Dict) -> Dict:
|
||||
req = UserMusicUnlockRequest(data)
|
||||
|
||||
profile = self.data.profile.get_profile(req.profileId)
|
||||
profile = await self.data.profile.get_profile(req.profileId)
|
||||
if profile is None:
|
||||
return BaseResponse().make()
|
||||
user_id = profile["user"]
|
||||
current_wp = profile["wp"]
|
||||
|
||||
tickets = self.data.item.get_tickets(user_id)
|
||||
tickets = await self.data.item.get_tickets(user_id)
|
||||
new_tickets: List[TicketItem] = []
|
||||
|
||||
for ticket in tickets:
|
||||
@@ -628,7 +628,7 @@ class WaccaBase:
|
||||
):
|
||||
if current_wp >= item.quantity:
|
||||
current_wp -= item.quantity
|
||||
self.data.profile.spend_wp(req.profileId, item.quantity)
|
||||
await self.data.profile.spend_wp(req.profileId, item.quantity)
|
||||
else:
|
||||
return BaseResponse().make()
|
||||
|
||||
@@ -641,21 +641,21 @@ class WaccaBase:
|
||||
self.logger.debug(
|
||||
f"Remove ticket ID {new_tickets[x].userTicketId} type {new_tickets[x].ticketId} from {user_id}"
|
||||
)
|
||||
self.data.item.spend_ticket(new_tickets[x].userTicketId)
|
||||
await self.data.item.spend_ticket(new_tickets[x].userTicketId)
|
||||
new_tickets.pop(x)
|
||||
break
|
||||
|
||||
# wp, ticket info
|
||||
if req.difficulty > WaccaConstants.Difficulty.HARD.value:
|
||||
old_score = self.data.score.get_best_score(
|
||||
old_score = await self.data.score.get_best_score(
|
||||
user_id, req.songId, req.difficulty
|
||||
)
|
||||
if not old_score:
|
||||
self.data.score.put_best_score(
|
||||
await self.data.score.put_best_score(
|
||||
user_id, req.songId, req.difficulty, 0, [0] * 5, [0] * 13, 0, 0
|
||||
)
|
||||
|
||||
self.data.item.unlock_song(
|
||||
await self.data.item.unlock_song(
|
||||
user_id,
|
||||
req.songId,
|
||||
req.difficulty
|
||||
@@ -698,7 +698,7 @@ class WaccaBase:
|
||||
)
|
||||
return resp.make()
|
||||
|
||||
profile = self.data.profile.get_profile(req.profileId)
|
||||
profile = await self.data.profile.get_profile(req.profileId)
|
||||
|
||||
if profile is None:
|
||||
self.logger.warning(
|
||||
@@ -707,7 +707,7 @@ class WaccaBase:
|
||||
return resp.make()
|
||||
|
||||
user_id = profile["user"]
|
||||
self.util_put_items(req.profileId, user_id, req.itemsObtained)
|
||||
await self.util_put_items(req.profileId, user_id, req.itemsObtained)
|
||||
|
||||
playlog_clear_status = (
|
||||
req.songDetail.flagCleared
|
||||
@@ -716,7 +716,7 @@ class WaccaBase:
|
||||
+ req.songDetail.flagAllMarvelous
|
||||
)
|
||||
|
||||
self.data.score.put_playlog(
|
||||
await self.data.score.put_playlog(
|
||||
user_id,
|
||||
req.songDetail.songId,
|
||||
req.songDetail.difficulty,
|
||||
@@ -733,7 +733,7 @@ class WaccaBase:
|
||||
self.season,
|
||||
)
|
||||
|
||||
old_score = self.data.score.get_best_score(
|
||||
old_score = await self.data.score.get_best_score(
|
||||
user_id, req.songDetail.songId, req.songDetail.difficulty
|
||||
)
|
||||
|
||||
@@ -749,7 +749,7 @@ class WaccaBase:
|
||||
|
||||
grades[req.songDetail.grade.value - 1] = 1
|
||||
|
||||
self.data.score.put_best_score(
|
||||
await self.data.score.put_best_score(
|
||||
user_id,
|
||||
req.songDetail.songId,
|
||||
req.songDetail.difficulty,
|
||||
@@ -805,7 +805,7 @@ class WaccaBase:
|
||||
old_score["rating"],
|
||||
)
|
||||
|
||||
self.data.score.put_best_score(
|
||||
await self.data.score.put_best_score(
|
||||
user_id,
|
||||
req.songDetail.songId,
|
||||
req.songDetail.difficulty,
|
||||
@@ -846,17 +846,17 @@ class WaccaBase:
|
||||
req = UserMissionUpdateRequest(data)
|
||||
page_status = req.params[1][1]
|
||||
|
||||
profile = self.data.profile.get_profile(req.profileId)
|
||||
profile = await self.data.profile.get_profile(req.profileId)
|
||||
if profile is None:
|
||||
return BaseResponse().make()
|
||||
|
||||
if len(req.itemsObtained) > 0:
|
||||
self.util_put_items(req.profileId, profile["user"], req.itemsObtained)
|
||||
await self.util_put_items(req.profileId, profile["user"], req.itemsObtained)
|
||||
|
||||
self.data.profile.update_bingo(
|
||||
await self.data.profile.update_bingo(
|
||||
profile["user"], req.bingoDetail.pageNumber, page_status
|
||||
)
|
||||
self.data.profile.update_tutorial_flags(req.profileId, req.params[3])
|
||||
await self.data.profile.update_tutorial_flags(req.profileId, req.params[3])
|
||||
|
||||
return BaseResponse().make()
|
||||
|
||||
@@ -864,7 +864,7 @@ class WaccaBase:
|
||||
req = UserGoodsPurchaseRequest(data)
|
||||
resp = UserGoodsPurchaseResponse()
|
||||
|
||||
profile = self.data.profile.get_profile(req.profileId)
|
||||
profile = await self.data.profile.get_profile(req.profileId)
|
||||
if profile is None:
|
||||
return BaseResponse().make()
|
||||
|
||||
@@ -876,20 +876,20 @@ class WaccaBase:
|
||||
and not self.game_config.mods.infinite_wp
|
||||
):
|
||||
resp.currentWp -= req.cost
|
||||
self.data.profile.spend_wp(req.profileId, req.cost)
|
||||
await self.data.profile.spend_wp(req.profileId, req.cost)
|
||||
|
||||
elif req.purchaseType == PurchaseType.PurchaseTypeCredit:
|
||||
self.logger.info(
|
||||
f"User {req.profileId} Purchased item {req.itemObtained.itemType} id {req.itemObtained.itemId} for {req.cost} credits on machine {req.chipId}"
|
||||
)
|
||||
|
||||
self.util_put_items(req.profileId, user_id, [req.itemObtained])
|
||||
await self.util_put_items(req.profileId, user_id, [req.itemObtained])
|
||||
|
||||
if self.game_config.mods.infinite_tickets:
|
||||
for x in range(5):
|
||||
resp.tickets.append(TicketItem(x, 106002, 0))
|
||||
else:
|
||||
tickets = self.data.item.get_tickets(user_id)
|
||||
tickets = await self.data.item.get_tickets(user_id)
|
||||
|
||||
for ticket in tickets:
|
||||
resp.tickets.append(
|
||||
@@ -914,7 +914,7 @@ class WaccaBase:
|
||||
async def handle_user_rating_update_request(self, data: Dict) -> Dict:
|
||||
req = UserRatingUpdateRequest(data)
|
||||
|
||||
user_id = self.data.profile.profile_to_aime_user(req.profileId)
|
||||
user_id = await self.data.profile.profile_to_aime_user(req.profileId)
|
||||
|
||||
if user_id is None:
|
||||
self.logger.error(
|
||||
@@ -923,33 +923,33 @@ class WaccaBase:
|
||||
return BaseResponse().make()
|
||||
|
||||
for song in req.songs:
|
||||
self.data.score.update_song_rating(
|
||||
await self.data.score.update_song_rating(
|
||||
user_id, song.songId, song.difficulty, song.rating
|
||||
)
|
||||
|
||||
self.data.profile.update_user_rating(req.profileId, req.totalRating)
|
||||
await self.data.profile.update_user_rating(req.profileId, req.totalRating)
|
||||
|
||||
return BaseResponse().make()
|
||||
|
||||
async def handle_user_status_update_request(self, data: Dict) -> Dict:
|
||||
req = UserStatusUpdateRequestV1(data)
|
||||
|
||||
user_id = self.data.profile.profile_to_aime_user(req.profileId)
|
||||
user_id = await self.data.profile.profile_to_aime_user(req.profileId)
|
||||
if user_id is None:
|
||||
self.logger.info(
|
||||
f"handle_user_status_update_request: No profile with ID {req.profileId}"
|
||||
)
|
||||
return BaseResponse().make()
|
||||
|
||||
self.util_put_items(req.profileId, user_id, req.itemsRecieved)
|
||||
self.data.profile.update_profile_playtype(
|
||||
await self.util_put_items(req.profileId, user_id, req.itemsRecieved)
|
||||
await self.data.profile.update_profile_playtype(
|
||||
req.profileId, req.playType.value, data["appVersion"][:7]
|
||||
)
|
||||
|
||||
current_icon = self.data.profile.get_options(
|
||||
current_icon = await self.data.profile.get_options(
|
||||
user_id, WaccaConstants.OPTIONS["set_icon_id"]
|
||||
)
|
||||
current_nav = self.data.profile.get_options(
|
||||
current_nav = await self.data.profile.get_options(
|
||||
user_id, WaccaConstants.OPTIONS["set_nav_id"]
|
||||
)
|
||||
|
||||
@@ -962,10 +962,10 @@ class WaccaBase:
|
||||
else:
|
||||
current_nav = current_nav["value"]
|
||||
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
user_id, WaccaConstants.ITEM_TYPES["icon"], current_icon
|
||||
)
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
user_id, WaccaConstants.ITEM_TYPES["navigator"], current_nav
|
||||
)
|
||||
return BaseResponse().make()
|
||||
@@ -973,19 +973,19 @@ class WaccaBase:
|
||||
async def handle_user_info_update_request(self, data: Dict) -> Dict:
|
||||
req = UserInfoUpdateRequest(data)
|
||||
|
||||
user_id = self.data.profile.profile_to_aime_user(req.profileId)
|
||||
user_id = await self.data.profile.profile_to_aime_user(req.profileId)
|
||||
|
||||
for opt in req.optsUpdated:
|
||||
self.data.profile.update_option(user_id, opt.optId, opt.optVal)
|
||||
await self.data.profile.update_option(user_id, opt.optId, opt.optVal)
|
||||
|
||||
for update in req.datesUpdated:
|
||||
pass
|
||||
|
||||
for fav in req.favoritesAdded:
|
||||
self.data.profile.add_favorite_song(user_id, fav)
|
||||
await self.data.profile.add_favorite_song(user_id, fav)
|
||||
|
||||
for unfav in req.favoritesRemoved:
|
||||
self.data.profile.remove_favorite_song(user_id, unfav)
|
||||
await self.data.profile.remove_favorite_song(user_id, unfav)
|
||||
|
||||
return BaseResponse().make()
|
||||
|
||||
@@ -993,7 +993,7 @@ class WaccaBase:
|
||||
req = UserVipGetRequest(data)
|
||||
resp = UserVipGetResponse()
|
||||
|
||||
profile = self.data.profile.get_profile(req.profileId)
|
||||
profile = await self.data.profile.get_profile(req.profileId)
|
||||
if profile is None:
|
||||
self.logger.warning(
|
||||
f"handle_user_vip_get_request no profile with ID {req.profileId}"
|
||||
@@ -1024,7 +1024,7 @@ class WaccaBase:
|
||||
async def handle_user_vip_start_request(self, data: Dict) -> Dict:
|
||||
req = UserVipStartRequest(data)
|
||||
|
||||
profile = self.data.profile.get_profile(req.profileId)
|
||||
profile = await self.data.profile.get_profile(req.profileId)
|
||||
if profile is None:
|
||||
return BaseResponse().make()
|
||||
|
||||
@@ -1040,10 +1040,10 @@ class WaccaBase:
|
||||
).make()
|
||||
|
||||
vip_exp_time = self.srvtime + timedelta(days=req.days)
|
||||
self.data.profile.update_vip_time(req.profileId, vip_exp_time)
|
||||
await self.data.profile.update_vip_time(req.profileId, vip_exp_time)
|
||||
return UserVipStartResponse(int(vip_exp_time.timestamp())).make()
|
||||
|
||||
def util_put_items(
|
||||
async def util_put_items(
|
||||
self, profile_id: int, user_id: int, items_obtained: List[GenericItemRecv]
|
||||
) -> None:
|
||||
if user_id is None or profile_id <= 0:
|
||||
@@ -1052,10 +1052,10 @@ class WaccaBase:
|
||||
if items_obtained:
|
||||
for item in items_obtained:
|
||||
if item.itemType == WaccaConstants.ITEM_TYPES["xp"]:
|
||||
self.data.profile.add_xp(profile_id, item.quantity)
|
||||
await self.data.profile.add_xp(profile_id, item.quantity)
|
||||
|
||||
elif item.itemType == WaccaConstants.ITEM_TYPES["wp"]:
|
||||
self.data.profile.add_wp(profile_id, item.quantity)
|
||||
await self.data.profile.add_wp(profile_id, item.quantity)
|
||||
|
||||
elif (
|
||||
item.itemType
|
||||
@@ -1063,11 +1063,11 @@ class WaccaBase:
|
||||
or item.itemType == WaccaConstants.ITEM_TYPES["music_unlock"]
|
||||
):
|
||||
if item.quantity > WaccaConstants.Difficulty.HARD.value:
|
||||
old_score = self.data.score.get_best_score(
|
||||
old_score = await self.data.score.get_best_score(
|
||||
user_id, item.itemId, item.quantity
|
||||
)
|
||||
if not old_score:
|
||||
self.data.score.put_best_score(
|
||||
await self.data.score.put_best_score(
|
||||
user_id,
|
||||
item.itemId,
|
||||
item.quantity,
|
||||
@@ -1080,18 +1080,18 @@ class WaccaBase:
|
||||
|
||||
if item.quantity == 0:
|
||||
item.quantity = WaccaConstants.Difficulty.HARD.value
|
||||
self.data.item.unlock_song(user_id, item.itemId, item.quantity)
|
||||
await self.data.item.unlock_song(user_id, item.itemId, item.quantity)
|
||||
|
||||
elif item.itemType == WaccaConstants.ITEM_TYPES["ticket"]:
|
||||
self.data.item.add_ticket(user_id, item.itemId)
|
||||
await self.data.item.add_ticket(user_id, item.itemId)
|
||||
|
||||
elif item.itemType == WaccaConstants.ITEM_TYPES["trophy"]:
|
||||
self.data.item.update_trophy(
|
||||
await self.data.item.update_trophy(
|
||||
user_id, item.itemId, self.season, item.quantity, 0
|
||||
)
|
||||
|
||||
else:
|
||||
self.data.item.put_item(user_id, item.itemType, item.itemId)
|
||||
await self.data.item.put_item(user_id, item.itemType, item.itemId)
|
||||
|
||||
def util_calc_song_rating(self, score: int, difficulty: float) -> int:
|
||||
if score >= 990000:
|
||||
|
||||
@@ -24,7 +24,7 @@ class WaccaFrontend(FE_Base):
|
||||
)
|
||||
self.nav_name = "Wacca"
|
||||
|
||||
def render_GET(self, request: Request) -> bytes:
|
||||
async def render_GET(self, request: Request) -> bytes:
|
||||
template = self.environment.get_template(
|
||||
"titles/wacca/frontend/wacca_index.jinja"
|
||||
)
|
||||
|
||||
@@ -45,20 +45,20 @@ class WaccaLily(WaccaS):
|
||||
req = UserStatusCreateRequest(data)
|
||||
ret = await super().handle_user_status_create_request(data)
|
||||
|
||||
new_user = self.data.profile.get_profile(aime_id=req.aimeId)
|
||||
new_user = await self.data.profile.get_profile(aime_id=req.aimeId)
|
||||
|
||||
if new_user is None:
|
||||
return BaseResponse().make()
|
||||
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["user_plate"], 211001
|
||||
) # Added lily
|
||||
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["note_sound"], 205005
|
||||
) # Added lily
|
||||
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210002
|
||||
) # Lily, Added Lily
|
||||
|
||||
@@ -68,13 +68,13 @@ class WaccaLily(WaccaS):
|
||||
req = UserStatusGetRequest(data)
|
||||
resp = UserStatusGetV2Response()
|
||||
|
||||
profile = self.data.profile.get_profile(aime_id=req.aimeId)
|
||||
profile = await self.data.profile.get_profile(aime_id=req.aimeId)
|
||||
if profile is None:
|
||||
self.logger.info(f"No user exists for aime id {req.aimeId}")
|
||||
resp.profileStatus = ProfileStatus.ProfileRegister
|
||||
return resp.make()
|
||||
|
||||
opts = self.data.profile.get_options(req.aimeId)
|
||||
opts = await self.data.profile.get_options(req.aimeId)
|
||||
|
||||
self.logger.info(f"User preview for {req.aimeId} from {req.chipId}")
|
||||
if profile["last_game_ver"] is None:
|
||||
@@ -94,14 +94,14 @@ class WaccaLily(WaccaS):
|
||||
resp.userStatus.loginsToday = profile["login_count_today"]
|
||||
resp.userStatus.rating = profile["rating"]
|
||||
|
||||
set_title_id = self.data.profile.get_options(
|
||||
set_title_id = await self.data.profile.get_options(
|
||||
WaccaConstants.OPTIONS["set_title_id"], profile["user"]
|
||||
)
|
||||
if set_title_id is None:
|
||||
set_title_id = self.OPTIONS_DEFAULTS["set_title_id"]
|
||||
resp.setTitleId = set_title_id
|
||||
|
||||
set_icon_id = self.data.profile.get_options(
|
||||
set_icon_id = await self.data.profile.get_options(
|
||||
WaccaConstants.OPTIONS["set_title_id"], profile["user"]
|
||||
)
|
||||
if set_icon_id is None:
|
||||
@@ -155,7 +155,7 @@ class WaccaLily(WaccaS):
|
||||
resp.lastLoginDate = 0
|
||||
|
||||
else:
|
||||
profile = self.data.profile.get_profile(req.userId)
|
||||
profile = await self.data.profile.get_profile(req.userId)
|
||||
if profile is None:
|
||||
self.logger.warning(
|
||||
f"Unknown user id {req.userId} attempted login from {req.chipId}"
|
||||
@@ -179,7 +179,7 @@ class WaccaLily(WaccaS):
|
||||
if midnight_today_ts - last_login_time > 86400:
|
||||
is_consec_day = False
|
||||
|
||||
self.data.profile.session_login(
|
||||
await self.data.profile.session_login(
|
||||
req.userId, resp.firstLoginDaily, is_consec_day
|
||||
)
|
||||
resp.vipInfo.pageYear = datetime.now().year
|
||||
@@ -196,7 +196,7 @@ class WaccaLily(WaccaS):
|
||||
else:
|
||||
resp = UserStatusGetDetailResponseV2()
|
||||
|
||||
profile = self.data.profile.get_profile(req.userId)
|
||||
profile = await self.data.profile.get_profile(req.userId)
|
||||
if profile is None:
|
||||
self.logger.warning(f"Unknown profile {req.userId}")
|
||||
return resp.make()
|
||||
@@ -204,14 +204,14 @@ class WaccaLily(WaccaS):
|
||||
self.logger.info(f"Get detail for profile {req.userId}")
|
||||
user_id = profile["user"]
|
||||
|
||||
profile_scores = self.data.score.get_best_scores(user_id)
|
||||
profile_items = self.data.item.get_items(user_id)
|
||||
profile_song_unlocks = self.data.item.get_song_unlocks(user_id)
|
||||
profile_options = self.data.profile.get_options(user_id)
|
||||
profile_favorites = self.data.profile.get_favorite_songs(user_id)
|
||||
profile_gates = self.data.profile.get_gates(user_id)
|
||||
profile_trophies = self.data.item.get_trophies(user_id)
|
||||
profile_tickets = self.data.item.get_tickets(user_id)
|
||||
profile_scores = await self.data.score.get_best_scores(user_id)
|
||||
profile_items = await self.data.item.get_items(user_id)
|
||||
profile_song_unlocks = await self.data.item.get_song_unlocks(user_id)
|
||||
profile_options = await self.data.profile.get_options(user_id)
|
||||
profile_favorites = await self.data.profile.get_favorite_songs(user_id)
|
||||
profile_gates = await self.data.profile.get_gates(user_id)
|
||||
profile_trophies = await self.data.item.get_trophies(user_id)
|
||||
profile_tickets = await self.data.item.get_tickets(user_id)
|
||||
|
||||
if profile["vip_expire_time"] is None:
|
||||
resp.userStatus.vipExpireTime = 0
|
||||
@@ -446,7 +446,7 @@ class WaccaLily(WaccaS):
|
||||
async def handle_user_status_update_request(self, data: Dict) -> Dict:
|
||||
super().handle_user_status_update_request(data)
|
||||
req = UserStatusUpdateRequestV2(data)
|
||||
self.data.profile.update_profile_lastplayed(
|
||||
await self.data.profile.update_profile_lastplayed(
|
||||
req.profileId,
|
||||
req.lastSongInfo.lastSongId,
|
||||
req.lastSongInfo.lastSongDiff,
|
||||
|
||||
@@ -43,9 +43,9 @@ class WaccaLilyR(WaccaLily):
|
||||
req = HousingStartRequestV2(data)
|
||||
allnet_region_id = None
|
||||
|
||||
machine = self.data.arcade.get_machine(req.chipId)
|
||||
machine = await self.data.arcade.get_machine(req.chipId)
|
||||
if machine is not None:
|
||||
arcade = self.data.arcade.get_arcade(machine["arcade"])
|
||||
arcade = await self.data.arcade.get_arcade(machine["arcade"])
|
||||
allnet_region_id = arcade["region_id"]
|
||||
|
||||
if req.appVersion.country == AllnetCountryCode.JAPAN.value:
|
||||
@@ -75,28 +75,28 @@ class WaccaLilyR(WaccaLily):
|
||||
req = UserStatusCreateRequest(data)
|
||||
resp = await super().handle_user_status_create_request(data)
|
||||
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210054
|
||||
) # Added lily r
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210055
|
||||
) # Added lily r
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210056
|
||||
) # Added lily r
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210057
|
||||
) # Added lily r
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210058
|
||||
) # Added lily r
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210059
|
||||
) # Added lily r
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210060
|
||||
) # Added lily r
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 210061
|
||||
) # Added lily r
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class WaccaReader(BaseReader):
|
||||
self.logger.error(f"Invalid wacca version {version}")
|
||||
exit(1)
|
||||
|
||||
def read(self) -> None:
|
||||
async def read(self) -> None:
|
||||
if not (
|
||||
path.exists(f"{self.bin_dir}/Table")
|
||||
and path.exists(f"{self.bin_dir}/Message")
|
||||
@@ -37,9 +37,9 @@ class WaccaReader(BaseReader):
|
||||
self.logger.error("Could not find Table or Message folder, nothing to read")
|
||||
return
|
||||
|
||||
self.read_music(f"{self.bin_dir}/Table", "MusicParameterTable")
|
||||
await self.read_music(f"{self.bin_dir}/Table", "MusicParameterTable")
|
||||
|
||||
def read_music(self, base_dir: str, table: str) -> None:
|
||||
async def read_music(self, base_dir: str, table: str) -> None:
|
||||
if not self.check_valid_pair(base_dir, table):
|
||||
self.logger.warning(
|
||||
f"Cannot find {table} uasset/uexp pair at {base_dir}, music will not be read"
|
||||
@@ -67,7 +67,7 @@ class WaccaReader(BaseReader):
|
||||
designer = wacca_data[str(key)]["NotesDesignerNormal"]
|
||||
|
||||
if diff > 0:
|
||||
self.data.static.put_music(
|
||||
await self.data.static.put_music(
|
||||
self.version,
|
||||
song_id,
|
||||
1,
|
||||
@@ -84,7 +84,7 @@ class WaccaReader(BaseReader):
|
||||
designer = wacca_data[str(key)]["NotesDesignerHard"]
|
||||
|
||||
if diff > 0:
|
||||
self.data.static.put_music(
|
||||
await self.data.static.put_music(
|
||||
self.version,
|
||||
song_id,
|
||||
2,
|
||||
@@ -101,7 +101,7 @@ class WaccaReader(BaseReader):
|
||||
designer = wacca_data[str(key)]["NotesDesignerExpert"]
|
||||
|
||||
if diff > 0:
|
||||
self.data.static.put_music(
|
||||
await self.data.static.put_music(
|
||||
self.version,
|
||||
song_id,
|
||||
3,
|
||||
@@ -118,7 +118,7 @@ class WaccaReader(BaseReader):
|
||||
designer = wacca_data[str(key)]["NotesDesignerInferno"]
|
||||
|
||||
if diff > 0:
|
||||
self.data.static.put_music(
|
||||
await self.data.static.put_music(
|
||||
self.version,
|
||||
song_id,
|
||||
4,
|
||||
|
||||
@@ -56,7 +56,7 @@ class WaccaReverse(WaccaLilyR):
|
||||
req = UserStatusGetDetailRequest(data)
|
||||
resp = UserStatusGetDetailResponseV4()
|
||||
|
||||
profile = self.data.profile.get_profile(req.userId)
|
||||
profile = await self.data.profile.get_profile(req.userId)
|
||||
if profile is None:
|
||||
self.logger.warning(f"Unknown profile {req.userId}")
|
||||
return resp.make()
|
||||
@@ -64,15 +64,15 @@ class WaccaReverse(WaccaLilyR):
|
||||
self.logger.info(f"Get detail for profile {req.userId}")
|
||||
user_id = profile["user"]
|
||||
|
||||
profile_scores = self.data.score.get_best_scores(user_id)
|
||||
profile_items = self.data.item.get_items(user_id)
|
||||
profile_song_unlocks = self.data.item.get_song_unlocks(user_id)
|
||||
profile_options = self.data.profile.get_options(user_id)
|
||||
profile_favorites = self.data.profile.get_favorite_songs(user_id)
|
||||
profile_gates = self.data.profile.get_gates(user_id)
|
||||
profile_bingo = self.data.profile.get_bingo(user_id)
|
||||
profile_trophies = self.data.item.get_trophies(user_id)
|
||||
profile_tickets = self.data.item.get_tickets(user_id)
|
||||
profile_scores = await self.data.score.get_best_scores(user_id)
|
||||
profile_items = await self.data.item.get_items(user_id)
|
||||
profile_song_unlocks = await self.data.item.get_song_unlocks(user_id)
|
||||
profile_options = await self.data.profile.get_options(user_id)
|
||||
profile_favorites = await self.data.profile.get_favorite_songs(user_id)
|
||||
profile_gates = await self.data.profile.get_gates(user_id)
|
||||
profile_bingo = await self.data.profile.get_bingo(user_id)
|
||||
profile_trophies = await self.data.item.get_trophies(user_id)
|
||||
profile_tickets = await self.data.item.get_tickets(user_id)
|
||||
|
||||
if profile["gate_tutorial_flags"] is not None:
|
||||
for x in profile["gate_tutorial_flags"]:
|
||||
@@ -309,17 +309,17 @@ class WaccaReverse(WaccaLilyR):
|
||||
req = UserStatusCreateRequest(data)
|
||||
resp = await super().handle_user_status_create_request(data)
|
||||
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 310001
|
||||
) # Added reverse
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["navigator"], 310002
|
||||
) # Added reverse
|
||||
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["touch_effect"], 312000
|
||||
) # Added reverse
|
||||
self.data.item.put_item(
|
||||
await self.data.item.put_item(
|
||||
req.aimeId, WaccaConstants.ITEM_TYPES["touch_effect"], 312001
|
||||
) # Added reverse
|
||||
|
||||
|
||||
@@ -75,16 +75,16 @@ trophy = Table(
|
||||
|
||||
|
||||
class WaccaItemData(BaseData):
|
||||
def get_song_unlocks(self, user_id: int) -> Optional[List[Row]]:
|
||||
async def get_song_unlocks(self, user_id: int) -> Optional[List[Row]]:
|
||||
sql = song_unlock.select(song_unlock.c.user == user_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
|
||||
return result.fetchall()
|
||||
|
||||
def unlock_song(self, user_id: int, song_id: int, difficulty: int) -> Optional[int]:
|
||||
async def unlock_song(self, user_id: int, song_id: int, difficulty: int) -> Optional[int]:
|
||||
sql = insert(song_unlock).values(
|
||||
user=user_id, song_id=song_id, highest_difficulty=difficulty
|
||||
)
|
||||
@@ -99,7 +99,7 @@ class WaccaItemData(BaseData):
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"{__name__} failed to unlock song! user: {user_id}, song_id: {song_id}, difficulty: {difficulty}"
|
||||
@@ -108,7 +108,7 @@ class WaccaItemData(BaseData):
|
||||
|
||||
return result.lastrowid
|
||||
|
||||
def put_item(self, user_id: int, item_type: int, item_id: int) -> Optional[int]:
|
||||
async def put_item(self, user_id: int, item_type: int, item_id: int) -> Optional[int]:
|
||||
sql = insert(item).values(
|
||||
user=user_id,
|
||||
item_id=item_id,
|
||||
@@ -117,7 +117,7 @@ class WaccaItemData(BaseData):
|
||||
|
||||
conflict = sql.on_duplicate_key_update(use_count=item.c.use_count + 1)
|
||||
|
||||
result = self.execute(conflict)
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"{__name__} failed to insert item! user: {user_id}, item_id: {item_id}, item_type: {item_type}"
|
||||
@@ -126,7 +126,7 @@ class WaccaItemData(BaseData):
|
||||
|
||||
return result.lastrowid
|
||||
|
||||
def get_items(
|
||||
async def get_items(
|
||||
self, user_id: int, item_type: int = None, item_id: int = None
|
||||
) -> Optional[List[Row]]:
|
||||
"""
|
||||
@@ -140,23 +140,23 @@ class WaccaItemData(BaseData):
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_tickets(self, user_id: int) -> Optional[List[Row]]:
|
||||
async def get_tickets(self, user_id: int) -> Optional[List[Row]]:
|
||||
sql = select(ticket).where(ticket.c.user == user_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def add_ticket(self, user_id: int, ticket_id: int) -> None:
|
||||
async def add_ticket(self, user_id: int, ticket_id: int) -> None:
|
||||
sql = insert(ticket).values(user=user_id, ticket_id=ticket_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"add_ticket: Failed to insert wacca ticket! user_id: {user_id} ticket_id {ticket_id}"
|
||||
@@ -164,15 +164,15 @@ class WaccaItemData(BaseData):
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def spend_ticket(self, id: int) -> None:
|
||||
async def spend_ticket(self, id: int) -> None:
|
||||
sql = delete(ticket).where(ticket.c.id == id)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.warning(f"Failed to delete ticket id {id}")
|
||||
return None
|
||||
|
||||
def get_trophies(self, user_id: int, season: int = None) -> Optional[List[Row]]:
|
||||
async def get_trophies(self, user_id: int, season: int = None) -> Optional[List[Row]]:
|
||||
if season is None:
|
||||
sql = select(trophy).where(trophy.c.user == user_id)
|
||||
else:
|
||||
@@ -180,12 +180,12 @@ class WaccaItemData(BaseData):
|
||||
and_(trophy.c.user == user_id, trophy.c.season == season)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def update_trophy(
|
||||
async def update_trophy(
|
||||
self, user_id: int, trophy_id: int, season: int, progress: int, badge_type: int
|
||||
) -> Optional[int]:
|
||||
sql = insert(trophy).values(
|
||||
@@ -198,7 +198,7 @@ class WaccaItemData(BaseData):
|
||||
|
||||
conflict = sql.on_duplicate_key_update(progress=progress)
|
||||
|
||||
result = self.execute(conflict)
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"update_trophy: Failed to insert wacca trophy! user_id: {user_id} trophy_id: {trophy_id} progress {progress}"
|
||||
|
||||
@@ -139,7 +139,7 @@ gate = Table(
|
||||
|
||||
|
||||
class WaccaProfileData(BaseData):
|
||||
def create_profile(
|
||||
async def create_profile(
|
||||
self, aime_id: int, username: str, version: int
|
||||
) -> Optional[int]:
|
||||
"""
|
||||
@@ -149,7 +149,7 @@ class WaccaProfileData(BaseData):
|
||||
|
||||
conflict = sql.on_duplicate_key_update(username=sql.inserted.username)
|
||||
|
||||
result = self.execute(conflict)
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"{__name__} Failed to insert wacca profile! aime id: {aime_id} username: {username}"
|
||||
@@ -157,7 +157,7 @@ class WaccaProfileData(BaseData):
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def update_profile_playtype(
|
||||
async def update_profile_playtype(
|
||||
self, profile_id: int, play_type: int, game_version: str
|
||||
) -> None:
|
||||
sql = profile.update(profile.c.id == profile_id).values(
|
||||
@@ -179,14 +179,14 @@ class WaccaProfileData(BaseData):
|
||||
last_game_ver=game_version,
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"update_profile: failed to update profile! profile: {profile_id}"
|
||||
)
|
||||
return None
|
||||
|
||||
def update_profile_lastplayed(
|
||||
async def update_profile_lastplayed(
|
||||
self,
|
||||
profile_id: int,
|
||||
last_song_id: int,
|
||||
@@ -202,21 +202,21 @@ class WaccaProfileData(BaseData):
|
||||
last_folder_id=last_folder_id,
|
||||
last_song_order=last_song_order,
|
||||
)
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"update_profile_lastplayed: failed to update profile! profile: {profile_id}"
|
||||
)
|
||||
return None
|
||||
|
||||
def update_profile_dan(
|
||||
async def update_profile_dan(
|
||||
self, profile_id: int, dan_level: int, dan_type: int
|
||||
) -> Optional[int]:
|
||||
sql = profile.update(profile.c.id == profile_id).values(
|
||||
dan_level=dan_level, dan_type=dan_type
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.warning(
|
||||
f"update_profile_dan: Failed to update! profile {profile_id}"
|
||||
@@ -224,7 +224,7 @@ class WaccaProfileData(BaseData):
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_profile(self, profile_id: int = 0, aime_id: int = None) -> Optional[Row]:
|
||||
async def get_profile(self, profile_id: int = 0, aime_id: int = None) -> Optional[Row]:
|
||||
"""
|
||||
Given a game version and either a profile or aime id, return the profile
|
||||
"""
|
||||
@@ -238,12 +238,12 @@ class WaccaProfileData(BaseData):
|
||||
)
|
||||
return None
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_options(self, user_id: int, option_id: int = None) -> Optional[List[Row]]:
|
||||
async def get_options(self, user_id: int, option_id: int = None) -> Optional[List[Row]]:
|
||||
"""
|
||||
Get a specific user option for a profile, or all of them if none specified
|
||||
"""
|
||||
@@ -254,7 +254,7 @@ class WaccaProfileData(BaseData):
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
if option_id is not None:
|
||||
@@ -262,12 +262,12 @@ class WaccaProfileData(BaseData):
|
||||
else:
|
||||
return result.fetchall()
|
||||
|
||||
def update_option(self, user_id: int, option_id: int, value: int) -> Optional[int]:
|
||||
async def update_option(self, user_id: int, option_id: int, value: int) -> Optional[int]:
|
||||
sql = insert(option).values(user=user_id, opt_id=option_id, value=value)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(value=value)
|
||||
|
||||
result = self.execute(conflict)
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"{__name__} failed to insert option! profile: {user_id}, option: {option_id}, value: {value}"
|
||||
@@ -276,10 +276,10 @@ class WaccaProfileData(BaseData):
|
||||
|
||||
return result.lastrowid
|
||||
|
||||
def add_favorite_song(self, user_id: int, song_id: int) -> Optional[int]:
|
||||
async def add_favorite_song(self, user_id: int, song_id: int) -> Optional[int]:
|
||||
sql = favorite.insert().values(user=user_id, song_id=song_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"{__name__} failed to insert favorite! profile: {user_id}, song_id: {song_id}"
|
||||
@@ -287,35 +287,35 @@ class WaccaProfileData(BaseData):
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def remove_favorite_song(self, user_id: int, song_id: int) -> None:
|
||||
async def remove_favorite_song(self, user_id: int, song_id: int) -> None:
|
||||
sql = favorite.delete(
|
||||
and_(favorite.c.user == user_id, favorite.c.song_id == song_id)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"{__name__} failed to remove favorite! profile: {user_id}, song_id: {song_id}"
|
||||
)
|
||||
return None
|
||||
|
||||
def get_favorite_songs(self, user_id: int) -> Optional[List[Row]]:
|
||||
async def get_favorite_songs(self, user_id: int) -> Optional[List[Row]]:
|
||||
sql = favorite.select(favorite.c.user == user_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_gates(self, user_id: int) -> Optional[List[Row]]:
|
||||
async def get_gates(self, user_id: int) -> Optional[List[Row]]:
|
||||
sql = select(gate).where(gate.c.user == user_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def update_gate(
|
||||
async def update_gate(
|
||||
self,
|
||||
user_id: int,
|
||||
gate_id: int,
|
||||
@@ -343,7 +343,7 @@ class WaccaProfileData(BaseData):
|
||||
total_points=sql.inserted.total_points,
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"{__name__} failed to update gate! user: {user_id}, gate_id: {gate_id}"
|
||||
@@ -351,18 +351,18 @@ class WaccaProfileData(BaseData):
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_friends(self, user_id: int) -> Optional[List[Row]]:
|
||||
async def get_friends(self, user_id: int) -> Optional[List[Row]]:
|
||||
sql = friend.select(friend.c.profile_sender == user_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def profile_to_aime_user(self, profile_id: int) -> Optional[int]:
|
||||
async def profile_to_aime_user(self, profile_id: int) -> Optional[int]:
|
||||
sql = select(profile.c.user).where(profile.c.id == profile_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.info(
|
||||
f"profile_to_aime_user: No user found for profile {profile_id}"
|
||||
@@ -378,7 +378,7 @@ class WaccaProfileData(BaseData):
|
||||
|
||||
return this_profile["user"]
|
||||
|
||||
def session_login(
|
||||
async def session_login(
|
||||
self, profile_id: int, is_new_day: bool, is_consec_day: bool
|
||||
) -> None:
|
||||
# TODO: Reset consec days counter
|
||||
@@ -395,127 +395,127 @@ class WaccaProfileData(BaseData):
|
||||
last_login_date=func.now(),
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"session_login: failed to update profile! profile: {profile_id}"
|
||||
)
|
||||
return None
|
||||
|
||||
def session_logout(self, profile_id: int) -> None:
|
||||
async def session_logout(self, profile_id: int) -> None:
|
||||
sql = profile.update(profile.c.id == id).values(login_count_consec=0)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"{__name__} failed to update profile! profile: {profile_id}"
|
||||
)
|
||||
return None
|
||||
|
||||
def add_xp(self, profile_id: int, xp: int) -> None:
|
||||
async def add_xp(self, profile_id: int, xp: int) -> None:
|
||||
sql = profile.update(profile.c.id == profile_id).values(xp=profile.c.xp + xp)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"add_xp: Failed to update profile! profile_id {profile_id} xp {xp}"
|
||||
)
|
||||
return None
|
||||
|
||||
def add_wp(self, profile_id: int, wp: int) -> None:
|
||||
async def add_wp(self, profile_id: int, wp: int) -> None:
|
||||
sql = profile.update(profile.c.id == profile_id).values(
|
||||
wp=profile.c.wp + wp,
|
||||
wp_total=profile.c.wp_total + wp,
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"add_wp: Failed to update profile! profile_id {profile_id} wp {wp}"
|
||||
)
|
||||
return None
|
||||
|
||||
def spend_wp(self, profile_id: int, wp: int) -> None:
|
||||
async def spend_wp(self, profile_id: int, wp: int) -> None:
|
||||
sql = profile.update(profile.c.id == profile_id).values(
|
||||
wp=profile.c.wp - wp,
|
||||
wp_spent=profile.c.wp_spent + wp,
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"spend_wp: Failed to update profile! profile_id {profile_id} wp {wp}"
|
||||
)
|
||||
return None
|
||||
|
||||
def activate_vip(self, profile_id: int, expire_time) -> None:
|
||||
async def activate_vip(self, profile_id: int, expire_time) -> None:
|
||||
sql = profile.update(profile.c.id == profile_id).values(
|
||||
vip_expire_time=expire_time
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"activate_vip: Failed to update profile! profile_id {profile_id} expire_time {expire_time}"
|
||||
)
|
||||
return None
|
||||
|
||||
def update_user_rating(self, profile_id: int, new_rating: int) -> None:
|
||||
async def update_user_rating(self, profile_id: int, new_rating: int) -> None:
|
||||
sql = profile.update(profile.c.id == profile_id).values(rating=new_rating)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"update_user_rating: Failed to update profile! profile_id {profile_id} new_rating {new_rating}"
|
||||
)
|
||||
return None
|
||||
|
||||
def update_bingo(self, aime_id: int, page: int, progress: int) -> Optional[int]:
|
||||
async def update_bingo(self, aime_id: int, page: int, progress: int) -> Optional[int]:
|
||||
sql = insert(bingo).values(
|
||||
user=aime_id, page_number=page, page_progress=progress
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(page_number=page, page_progress=progress)
|
||||
|
||||
result = self.execute(conflict)
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(f"put_bingo: failed to update! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_bingo(self, aime_id: int) -> Optional[List[Row]]:
|
||||
async def get_bingo(self, aime_id: int) -> Optional[List[Row]]:
|
||||
sql = select(bingo).where(bingo.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_bingo_page(self, aime_id: int, page: Dict) -> Optional[List[Row]]:
|
||||
async def get_bingo_page(self, aime_id: int, page: Dict) -> Optional[List[Row]]:
|
||||
sql = select(bingo).where(
|
||||
and_(bingo.c.user == aime_id, bingo.c.page_number == page)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def update_vip_time(self, profile_id: int, time_left) -> None:
|
||||
async def update_vip_time(self, profile_id: int, time_left) -> None:
|
||||
sql = profile.update(profile.c.id == profile_id).values(
|
||||
vip_expire_time=time_left
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"Failed to update VIP time for profile {profile_id}")
|
||||
|
||||
def update_tutorial_flags(self, profile_id: int, flags: Dict) -> None:
|
||||
async def update_tutorial_flags(self, profile_id: int, flags: Dict) -> None:
|
||||
sql = profile.update(profile.c.id == profile_id).values(
|
||||
gate_tutorial_flags=flags
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"Failed to update tutorial flags for profile {profile_id}"
|
||||
|
||||
@@ -95,7 +95,7 @@ stageup = Table(
|
||||
|
||||
|
||||
class WaccaScoreData(BaseData):
|
||||
def put_best_score(
|
||||
async def put_best_score(
|
||||
self,
|
||||
user_id: int,
|
||||
song_id: int,
|
||||
@@ -164,7 +164,7 @@ class WaccaScoreData(BaseData):
|
||||
lowest_miss_ct=lowest_miss_ct,
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"{__name__}: failed to insert best score! profile: {user_id}, song: {song_id}, chart: {chart_id}"
|
||||
@@ -173,7 +173,7 @@ class WaccaScoreData(BaseData):
|
||||
|
||||
return result.lastrowid
|
||||
|
||||
def put_playlog(
|
||||
async def put_playlog(
|
||||
self,
|
||||
user_id: int,
|
||||
song_id: int,
|
||||
@@ -210,7 +210,7 @@ class WaccaScoreData(BaseData):
|
||||
season=season,
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"{__name__} failed to insert playlog! profile: {user_id}, song: {song_id}, chart: {chart_id}"
|
||||
@@ -219,7 +219,7 @@ class WaccaScoreData(BaseData):
|
||||
|
||||
return result.lastrowid
|
||||
|
||||
def get_best_score(
|
||||
async def get_best_score(
|
||||
self, user_id: int, song_id: int, chart_id: int
|
||||
) -> Optional[Row]:
|
||||
sql = best_score.select(
|
||||
@@ -230,20 +230,20 @@ class WaccaScoreData(BaseData):
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_best_scores(self, user_id: int) -> Optional[List[Row]]:
|
||||
async def get_best_scores(self, user_id: int) -> Optional[List[Row]]:
|
||||
sql = best_score.select(best_score.c.user == user_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def update_song_rating(
|
||||
async def update_song_rating(
|
||||
self, user_id: int, song_id: int, chart_id: int, new_rating: int
|
||||
) -> None:
|
||||
sql = best_score.update(
|
||||
@@ -254,14 +254,14 @@ class WaccaScoreData(BaseData):
|
||||
)
|
||||
).values(rating=new_rating)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(
|
||||
f"update_song_rating: failed to update rating! user_id: {user_id} song_id: {song_id} chart_id {chart_id} new_rating {new_rating}"
|
||||
)
|
||||
return None
|
||||
|
||||
def put_stageup(
|
||||
async def put_stageup(
|
||||
self,
|
||||
user_id: int,
|
||||
version: int,
|
||||
@@ -292,7 +292,7 @@ class WaccaScoreData(BaseData):
|
||||
play_ct=stageup.c.play_ct + 1,
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warning(
|
||||
f"put_stageup: failed to update! user_id: {user_id} version: {version} stage_id: {stage_id}"
|
||||
@@ -300,17 +300,17 @@ class WaccaScoreData(BaseData):
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_stageup(self, user_id: int, version: int) -> Optional[List[Row]]:
|
||||
async def get_stageup(self, user_id: int, version: int) -> Optional[List[Row]]:
|
||||
sql = select(stageup).where(
|
||||
and_(stageup.c.user == user_id, stageup.c.version == version)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_stageup_stage(
|
||||
async def get_stageup_stage(
|
||||
self, user_id: int, version: int, stage_id: int
|
||||
) -> Optional[Row]:
|
||||
sql = select(stageup).where(
|
||||
@@ -321,7 +321,7 @@ class WaccaScoreData(BaseData):
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
@@ -28,7 +28,7 @@ music = Table(
|
||||
|
||||
|
||||
class WaccaStaticData(BaseData):
|
||||
def put_music(
|
||||
async def put_music(
|
||||
self,
|
||||
version: int,
|
||||
song_id: int,
|
||||
@@ -61,13 +61,13 @@ class WaccaStaticData(BaseData):
|
||||
jacketFile=jacket,
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
result = await self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warning(f"Failed to insert music {song_id} chart {chart_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
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(
|
||||
@@ -78,7 +78,7 @@ class WaccaStaticData(BaseData):
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
Reference in New Issue
Block a user