move to async database
This commit is contained in:
+14
-14
@@ -177,9 +177,9 @@ class AimedbServlette():
|
|||||||
|
|
||||||
async def handle_lookup(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
async def handle_lookup(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
||||||
req = ADBLookupRequest(data)
|
req = ADBLookupRequest(data)
|
||||||
user_id = self.data.card.get_user_id_from_card(req.access_code)
|
user_id = await self.data.card.get_user_id_from_card(req.access_code)
|
||||||
is_banned = self.data.card.get_card_banned(req.access_code)
|
is_banned = await self.data.card.get_card_banned(req.access_code)
|
||||||
is_locked = self.data.card.get_card_locked(req.access_code)
|
is_locked = await self.data.card.get_card_locked(req.access_code)
|
||||||
|
|
||||||
ret = ADBLookupResponse.from_req(req.head, user_id)
|
ret = ADBLookupResponse.from_req(req.head, user_id)
|
||||||
if is_banned and is_locked:
|
if is_banned and is_locked:
|
||||||
@@ -196,10 +196,10 @@ class AimedbServlette():
|
|||||||
|
|
||||||
async def handle_lookup_ex(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
async def handle_lookup_ex(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
||||||
req = ADBLookupRequest(data)
|
req = ADBLookupRequest(data)
|
||||||
user_id = self.data.card.get_user_id_from_card(req.access_code)
|
user_id = await self.data.card.get_user_id_from_card(req.access_code)
|
||||||
|
|
||||||
is_banned = self.data.card.get_card_banned(req.access_code)
|
is_banned = await self.data.card.get_card_banned(req.access_code)
|
||||||
is_locked = self.data.card.get_card_locked(req.access_code)
|
is_locked = await self.data.card.get_card_locked(req.access_code)
|
||||||
|
|
||||||
ret = ADBLookupExResponse.from_req(req.head, user_id)
|
ret = ADBLookupExResponse.from_req(req.head, user_id)
|
||||||
if is_banned and is_locked:
|
if is_banned and is_locked:
|
||||||
@@ -233,7 +233,7 @@ class AimedbServlette():
|
|||||||
be fine.
|
be fine.
|
||||||
"""
|
"""
|
||||||
req = ADBFelicaLookupRequest(data)
|
req = ADBFelicaLookupRequest(data)
|
||||||
ac = self.data.card.to_access_code(req.idm)
|
ac = await self.data.card.to_access_code(req.idm)
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
f"idm {req.idm} ipm {req.pmm} -> access_code {ac}"
|
f"idm {req.idm} ipm {req.pmm} -> access_code {ac}"
|
||||||
)
|
)
|
||||||
@@ -244,17 +244,17 @@ class AimedbServlette():
|
|||||||
I've never seen this used.
|
I've never seen this used.
|
||||||
"""
|
"""
|
||||||
req = ADBFelicaLookupRequest(data)
|
req = ADBFelicaLookupRequest(data)
|
||||||
ac = self.data.card.to_access_code(req.idm)
|
ac = await self.data.card.to_access_code(req.idm)
|
||||||
|
|
||||||
if self.config.server.allow_user_registration:
|
if self.config.server.allow_user_registration:
|
||||||
user_id = self.data.user.create_user()
|
user_id = await self.data.user.create_user()
|
||||||
|
|
||||||
if user_id is None:
|
if user_id is None:
|
||||||
self.logger.error("Failed to register user!")
|
self.logger.error("Failed to register user!")
|
||||||
user_id = -1
|
user_id = -1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
card_id = self.data.card.create_card(user_id, ac)
|
card_id = await self.data.card.create_card(user_id, ac)
|
||||||
|
|
||||||
if card_id is None:
|
if card_id is None:
|
||||||
self.logger.error("Failed to register card!")
|
self.logger.error("Failed to register card!")
|
||||||
@@ -273,8 +273,8 @@ class AimedbServlette():
|
|||||||
|
|
||||||
async def handle_felica_lookup_ex(self, data: bytes, resp_code: int) -> bytes:
|
async def handle_felica_lookup_ex(self, data: bytes, resp_code: int) -> bytes:
|
||||||
req = ADBFelicaLookup2Request(data)
|
req = ADBFelicaLookup2Request(data)
|
||||||
access_code = self.data.card.to_access_code(req.idm)
|
access_code = await self.data.card.to_access_code(req.idm)
|
||||||
user_id = self.data.card.get_user_id_from_card(access_code=access_code)
|
user_id = await self.data.card.get_user_id_from_card(access_code=access_code)
|
||||||
|
|
||||||
if user_id is None:
|
if user_id is None:
|
||||||
user_id = -1
|
user_id = -1
|
||||||
@@ -308,14 +308,14 @@ class AimedbServlette():
|
|||||||
user_id = -1
|
user_id = -1
|
||||||
|
|
||||||
if self.config.server.allow_user_registration:
|
if self.config.server.allow_user_registration:
|
||||||
user_id = self.data.user.create_user()
|
user_id = await self.data.user.create_user()
|
||||||
|
|
||||||
if user_id is None:
|
if user_id is None:
|
||||||
self.logger.error("Failed to register user!")
|
self.logger.error("Failed to register user!")
|
||||||
user_id = -1
|
user_id = -1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
card_id = self.data.card.create_card(user_id, req.access_code)
|
card_id = await self.data.card.create_card(user_id, req.access_code)
|
||||||
|
|
||||||
if card_id is None:
|
if card_id is None:
|
||||||
self.logger.error("Failed to register card!")
|
self.logger.error("Failed to register card!")
|
||||||
|
|||||||
+14
-14
@@ -170,10 +170,10 @@ class AllnetServlet:
|
|||||||
|
|
||||||
self.logger.debug(f"Allnet request: {vars(req)}")
|
self.logger.debug(f"Allnet request: {vars(req)}")
|
||||||
|
|
||||||
machine = self.data.arcade.get_machine(req.serial)
|
machine = await self.data.arcade.get_machine(req.serial)
|
||||||
if machine is None and not self.config.server.allow_unregistered_serials:
|
if machine is None and not self.config.server.allow_unregistered_serials:
|
||||||
msg = f"Unrecognised serial {req.serial} attempted allnet auth from {request_ip}."
|
msg = f"Unrecognised serial {req.serial} attempted allnet auth from {request_ip}."
|
||||||
self.data.base.log_event(
|
await self.data.base.log_event(
|
||||||
"allnet", "ALLNET_AUTH_UNKNOWN_SERIAL", logging.WARN, msg
|
"allnet", "ALLNET_AUTH_UNKNOWN_SERIAL", logging.WARN, msg
|
||||||
)
|
)
|
||||||
self.logger.warning(msg)
|
self.logger.warning(msg)
|
||||||
@@ -183,11 +183,11 @@ class AllnetServlet:
|
|||||||
return PlainTextResponse(urllib.parse.unquote(urllib.parse.urlencode(resp_dict)) + "\n")
|
return PlainTextResponse(urllib.parse.unquote(urllib.parse.urlencode(resp_dict)) + "\n")
|
||||||
|
|
||||||
if machine is not None:
|
if machine is not None:
|
||||||
arcade = self.data.arcade.get_arcade(machine["arcade"])
|
arcade = await self.data.arcade.get_arcade(machine["arcade"])
|
||||||
if self.config.server.check_arcade_ip:
|
if self.config.server.check_arcade_ip:
|
||||||
if arcade["ip"] and arcade["ip"] is not None and arcade["ip"] != req.ip:
|
if arcade["ip"] and arcade["ip"] is not None and arcade["ip"] != req.ip:
|
||||||
msg = f"Serial {req.serial} attempted allnet auth from bad IP {req.ip} (expected {arcade['ip']})."
|
msg = f"Serial {req.serial} attempted allnet auth from bad IP {req.ip} (expected {arcade['ip']})."
|
||||||
self.data.base.log_event(
|
await self.data.base.log_event(
|
||||||
"allnet", "ALLNET_AUTH_BAD_IP", logging.ERROR, msg
|
"allnet", "ALLNET_AUTH_BAD_IP", logging.ERROR, msg
|
||||||
)
|
)
|
||||||
self.logger.warning(msg)
|
self.logger.warning(msg)
|
||||||
@@ -198,7 +198,7 @@ class AllnetServlet:
|
|||||||
|
|
||||||
elif (not arcade["ip"] or arcade["ip"] is None) and self.config.server.strict_ip_checking:
|
elif (not arcade["ip"] or arcade["ip"] is None) and self.config.server.strict_ip_checking:
|
||||||
msg = f"Serial {req.serial} attempted allnet auth from bad IP {req.ip}, but arcade {arcade['id']} has no IP set! (strict checking enabled)."
|
msg = f"Serial {req.serial} attempted allnet auth from bad IP {req.ip}, but arcade {arcade['id']} has no IP set! (strict checking enabled)."
|
||||||
self.data.base.log_event(
|
await self.data.base.log_event(
|
||||||
"allnet", "ALLNET_AUTH_NO_SHOP_IP", logging.ERROR, msg
|
"allnet", "ALLNET_AUTH_NO_SHOP_IP", logging.ERROR, msg
|
||||||
)
|
)
|
||||||
self.logger.warning(msg)
|
self.logger.warning(msg)
|
||||||
@@ -242,7 +242,7 @@ class AllnetServlet:
|
|||||||
if req.game_id not in TitleServlet.title_registry:
|
if req.game_id not in TitleServlet.title_registry:
|
||||||
if not self.config.server.is_develop:
|
if not self.config.server.is_develop:
|
||||||
msg = f"Unrecognised game {req.game_id} attempted allnet auth from {request_ip}."
|
msg = f"Unrecognised game {req.game_id} attempted allnet auth from {request_ip}."
|
||||||
self.data.base.log_event(
|
await self.data.base.log_event(
|
||||||
"allnet", "ALLNET_AUTH_UNKNOWN_GAME", logging.WARN, msg
|
"allnet", "ALLNET_AUTH_UNKNOWN_GAME", logging.WARN, msg
|
||||||
)
|
)
|
||||||
self.logger.warning(msg)
|
self.logger.warning(msg)
|
||||||
@@ -269,7 +269,7 @@ class AllnetServlet:
|
|||||||
resp.uri, resp.host = TitleServlet.title_registry[req.game_id].get_allnet_info(req.game_id, int(int_ver), req.serial)
|
resp.uri, resp.host = TitleServlet.title_registry[req.game_id].get_allnet_info(req.game_id, int(int_ver), req.serial)
|
||||||
|
|
||||||
msg = f"{req.serial} authenticated from {request_ip}: {req.game_id} v{req.ver}"
|
msg = f"{req.serial} authenticated from {request_ip}: {req.game_id} v{req.ver}"
|
||||||
self.data.base.log_event("allnet", "ALLNET_AUTH_SUCCESS", logging.INFO, msg)
|
await self.data.base.log_event("allnet", "ALLNET_AUTH_SUCCESS", logging.INFO, msg)
|
||||||
self.logger.info(msg)
|
self.logger.info(msg)
|
||||||
|
|
||||||
resp_dict = {k: v for k, v in vars(resp).items() if v is not None}
|
resp_dict = {k: v for k, v in vars(resp).items() if v is not None}
|
||||||
@@ -335,7 +335,7 @@ class AllnetServlet:
|
|||||||
resp.uri += f"|http://{self.config.server.hostname}:{self.config.server.port}/dl/ini/{req.game_id}-{req.ver.replace('.', '')}-opt.ini"
|
resp.uri += f"|http://{self.config.server.hostname}:{self.config.server.port}/dl/ini/{req.game_id}-{req.ver.replace('.', '')}-opt.ini"
|
||||||
|
|
||||||
self.logger.debug(f"Sending download uri {resp.uri}")
|
self.logger.debug(f"Sending download uri {resp.uri}")
|
||||||
self.data.base.log_event("allnet", "DLORDER_REQ_SUCCESS", logging.INFO, f"{Utils.get_ip_addr(request)} requested DL Order for {req.serial} {req.game_id} v{req.ver}")
|
await self.data.base.log_event("allnet", "DLORDER_REQ_SUCCESS", logging.INFO, f"{Utils.get_ip_addr(request)} requested DL Order for {req.serial} {req.game_id} v{req.ver}")
|
||||||
|
|
||||||
res_str = urllib.parse.unquote(urllib.parse.urlencode(vars(resp))) + "\n"
|
res_str = urllib.parse.unquote(urllib.parse.urlencode(vars(resp))) + "\n"
|
||||||
"""if is_dfi:
|
"""if is_dfi:
|
||||||
@@ -352,7 +352,7 @@ class AllnetServlet:
|
|||||||
|
|
||||||
if path.exists(f"{self.config.allnet.update_cfg_folder}/{req_file}"):
|
if path.exists(f"{self.config.allnet.update_cfg_folder}/{req_file}"):
|
||||||
self.logger.info(f"Request for DL INI file {req_file} from {Utils.get_ip_addr(request)} successful")
|
self.logger.info(f"Request for DL INI file {req_file} from {Utils.get_ip_addr(request)} successful")
|
||||||
self.data.base.log_event("allnet", "DLORDER_INI_SENT", logging.INFO, f"{Utils.get_ip_addr(request)} successfully recieved {req_file}")
|
await self.data.base.log_event("allnet", "DLORDER_INI_SENT", logging.INFO, f"{Utils.get_ip_addr(request)} successfully recieved {req_file}")
|
||||||
|
|
||||||
return PlainTextResponse(open(
|
return PlainTextResponse(open(
|
||||||
f"{self.config.allnet.update_cfg_folder}/{req_file}", "r"
|
f"{self.config.allnet.update_cfg_folder}/{req_file}", "r"
|
||||||
@@ -390,7 +390,7 @@ class AllnetServlet:
|
|||||||
msg = f"{rep.serial} @ {client_ip} reported {rep.rep_type.name} download state {rep.rf_state.name} for {rep.gd} v{rep.dav}:"\
|
msg = f"{rep.serial} @ {client_ip} reported {rep.rep_type.name} download state {rep.rf_state.name} for {rep.gd} v{rep.dav}:"\
|
||||||
f" {rep.tdsc}/{rep.tsc} segments downloaded for working files {rep.wfl} with {rep.dfl if rep.dfl else 'none'} complete."
|
f" {rep.tdsc}/{rep.tsc} segments downloaded for working files {rep.wfl} with {rep.dfl if rep.dfl else 'none'} complete."
|
||||||
|
|
||||||
self.data.base.log_event("allnet", "DL_REPORT", logging.INFO, msg, dl_data)
|
await self.data.base.log_event("allnet", "DL_REPORT", logging.INFO, msg, dl_data)
|
||||||
self.logger.info(msg)
|
self.logger.info(msg)
|
||||||
|
|
||||||
return PlainTextResponse("OK")
|
return PlainTextResponse("OK")
|
||||||
@@ -540,10 +540,10 @@ class BillingServlet:
|
|||||||
kc_serial_bytes = req.keychipid.encode()
|
kc_serial_bytes = req.keychipid.encode()
|
||||||
|
|
||||||
|
|
||||||
machine = self.data.arcade.get_machine(req.keychipid)
|
machine = await self.data.arcade.get_machine(req.keychipid)
|
||||||
if machine is None and not self.config.server.allow_unregistered_serials:
|
if machine is None and not self.config.server.allow_unregistered_serials:
|
||||||
msg = f"Unrecognised serial {req.keychipid} attempted billing checkin from {request_ip} for {req.gameid} v{req.gamever}."
|
msg = f"Unrecognised serial {req.keychipid} attempted billing checkin from {request_ip} for {req.gameid} v{req.gamever}."
|
||||||
self.data.base.log_event(
|
await self.data.base.log_event(
|
||||||
"allnet", "BILLING_CHECKIN_NG_SERIAL", logging.WARN, msg
|
"allnet", "BILLING_CHECKIN_NG_SERIAL", logging.WARN, msg
|
||||||
)
|
)
|
||||||
self.logger.warning(msg)
|
self.logger.warning(msg)
|
||||||
@@ -555,7 +555,7 @@ class BillingServlet:
|
|||||||
f"{req.playcnt} billing_type {req.billingtype.name} nearfull {req.nearfull} playlimit {req.playlimit}"
|
f"{req.playcnt} billing_type {req.billingtype.name} nearfull {req.nearfull} playlimit {req.playlimit}"
|
||||||
)
|
)
|
||||||
self.logger.info(msg)
|
self.logger.info(msg)
|
||||||
self.data.base.log_event("billing", "BILLING_CHECKIN_OK", logging.INFO, msg)
|
await self.data.base.log_event("billing", "BILLING_CHECKIN_OK", logging.INFO, msg)
|
||||||
if req.traceleft > 0:
|
if req.traceleft > 0:
|
||||||
self.logger.warn(f"{req.traceleft} unsent tracelogs")
|
self.logger.warn(f"{req.traceleft} unsent tracelogs")
|
||||||
kc_playlimit = req.playlimit
|
kc_playlimit = req.playlimit
|
||||||
@@ -699,7 +699,7 @@ class BillingInfo:
|
|||||||
self.boardid = str(data.get("boardid", None))
|
self.boardid = str(data.get("boardid", None))
|
||||||
self.tenpoip = str(data.get("tenpoip", None))
|
self.tenpoip = str(data.get("tenpoip", None))
|
||||||
self.libalibver = float(data.get("libalibver", None))
|
self.libalibver = float(data.get("libalibver", None))
|
||||||
self.datamax = int(data.get("datamax", None))
|
self.data.max = int(data.get("datamax", None))
|
||||||
self.billingtype = BillingType(int(data.get("billingtype", None)))
|
self.billingtype = BillingType(int(data.get("billingtype", None)))
|
||||||
self.protocolver = float(data.get("protocolver", None))
|
self.protocolver = float(data.get("protocolver", None))
|
||||||
self.operatingfix = bool(data.get("operatingfix", None))
|
self.operatingfix = bool(data.get("operatingfix", None))
|
||||||
|
|||||||
+27
-27
@@ -69,7 +69,7 @@ arcade_owner = Table(
|
|||||||
|
|
||||||
|
|
||||||
class ArcadeData(BaseData):
|
class ArcadeData(BaseData):
|
||||||
def get_machine(self, serial: str = None, id: int = None) -> Optional[Row]:
|
async def get_machine(self, serial: str = None, id: int = None) -> Optional[Row]:
|
||||||
if serial is not None:
|
if serial is not None:
|
||||||
serial = serial.replace("-", "")
|
serial = serial.replace("-", "")
|
||||||
if len(serial) == 11:
|
if len(serial) == 11:
|
||||||
@@ -89,12 +89,12 @@ class ArcadeData(BaseData):
|
|||||||
self.logger.error(f"{__name__ }: Need either serial or ID to look up!")
|
self.logger.error(f"{__name__ }: Need either serial or ID to look up!")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_machine(
|
async def put_machine(
|
||||||
self,
|
self,
|
||||||
arcade_id: int,
|
arcade_id: int,
|
||||||
serial: str = "",
|
serial: str = "",
|
||||||
@@ -110,13 +110,13 @@ class ArcadeData(BaseData):
|
|||||||
arcade=arcade_id, keychip=serial, board=board, game=game, is_cab=is_cab
|
arcade=arcade_id, keychip=serial, board=board, game=game, is_cab=is_cab
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def set_machine_serial(self, machine_id: int, serial: str) -> None:
|
async def set_machine_serial(self, machine_id: int, serial: str) -> None:
|
||||||
result = self.execute(
|
result = await self.execute(
|
||||||
machine.update(machine.c.id == machine_id).values(keychip=serial)
|
machine.update(machine.c.id == machine_id).values(keychip=serial)
|
||||||
)
|
)
|
||||||
if result is None:
|
if result is None:
|
||||||
@@ -125,8 +125,8 @@ class ArcadeData(BaseData):
|
|||||||
)
|
)
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def set_machine_boardid(self, machine_id: int, boardid: str) -> None:
|
async def set_machine_boardid(self, machine_id: int, boardid: str) -> None:
|
||||||
result = self.execute(
|
result = await self.execute(
|
||||||
machine.update(machine.c.id == machine_id).values(board=boardid)
|
machine.update(machine.c.id == machine_id).values(board=boardid)
|
||||||
)
|
)
|
||||||
if result is None:
|
if result is None:
|
||||||
@@ -134,21 +134,21 @@ class ArcadeData(BaseData):
|
|||||||
f"Failed to update board id for machine {machine_id} -> {boardid}"
|
f"Failed to update board id for machine {machine_id} -> {boardid}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_arcade(self, id: int) -> Optional[Row]:
|
async def get_arcade(self, id: int) -> Optional[Row]:
|
||||||
sql = arcade.select(arcade.c.id == id)
|
sql = arcade.select(arcade.c.id == id)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_arcade_machines(self, id: int) -> Optional[List[Row]]:
|
async def get_arcade_machines(self, id: int) -> Optional[List[Row]]:
|
||||||
sql = machine.select(machine.c.arcade == id)
|
sql = machine.select(machine.c.arcade == id)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_arcade(
|
async def put_arcade(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
nickname: str = None,
|
nickname: str = None,
|
||||||
@@ -171,42 +171,42 @@ class ArcadeData(BaseData):
|
|||||||
regional_id=regional_id,
|
regional_id=regional_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_arcades_managed_by_user(self, user_id: int) -> Optional[List[Row]]:
|
async def get_arcades_managed_by_user(self, user_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(arcade).join(arcade_owner, arcade_owner.c.arcade == arcade.c.id).where(arcade_owner.c.user == user_id)
|
sql = select(arcade).join(arcade_owner, arcade_owner.c.arcade == arcade.c.id).where(arcade_owner.c.user == user_id)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return False
|
return False
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_manager_permissions(self, user_id: int, arcade_id: int) -> Optional[int]:
|
async def get_manager_permissions(self, user_id: int, arcade_id: int) -> Optional[int]:
|
||||||
sql = select(arcade_owner.c.permissions).where(and_(arcade_owner.c.user == user_id, arcade_owner.c.arcade == arcade_id))
|
sql = select(arcade_owner.c.permissions).where(and_(arcade_owner.c.user == user_id, arcade_owner.c.arcade == arcade_id))
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return False
|
return False
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_arcade_owners(self, arcade_id: int) -> Optional[Row]:
|
async def get_arcade_owners(self, arcade_id: int) -> Optional[Row]:
|
||||||
sql = select(arcade_owner).where(arcade_owner.c.arcade == arcade_id)
|
sql = select(arcade_owner).where(arcade_owner.c.arcade == arcade_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def add_arcade_owner(self, arcade_id: int, user_id: int) -> None:
|
async def add_arcade_owner(self, arcade_id: int, user_id: int) -> None:
|
||||||
sql = insert(arcade_owner).values(arcade=arcade_id, user=user_id)
|
sql = insert(arcade_owner).values(arcade=arcade_id, user=user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def format_serial(
|
async def format_serial(
|
||||||
self, platform_code: str, platform_rev: int, serial_num: int, append: int = 4152
|
self, platform_code: str, platform_rev: int, serial_num: int, append: int = 4152
|
||||||
) -> str:
|
) -> str:
|
||||||
return f"{platform_code}{platform_rev:02d}A{serial_num:04d}{append:04d}" # 0x41 = A, 0x52 = R
|
return f"{platform_code}{platform_rev:02d}A{serial_num:04d}{append:04d}" # 0x41 = A, 0x52 = R
|
||||||
@@ -217,16 +217,16 @@ class ArcadeData(BaseData):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_arcade_by_name(self, name: str) -> Optional[List[Row]]:
|
async def get_arcade_by_name(self, name: str) -> Optional[List[Row]]:
|
||||||
sql = arcade.select(or_(arcade.c.name.like(f"%{name}%"), arcade.c.nickname.like(f"%{name}%")))
|
sql = arcade.select(or_(arcade.c.name.like(f"%{name}%"), arcade.c.nickname.like(f"%{name}%")))
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_arcades_by_ip(self, ip: str) -> Optional[List[Row]]:
|
async def get_arcades_by_ip(self, ip: str) -> Optional[List[Row]]:
|
||||||
sql = arcade.select().where(arcade.c.ip == ip)
|
sql = arcade.select().where(arcade.c.ip == ip)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class BaseData:
|
|||||||
message=message,
|
message=message,
|
||||||
details=json.dumps(details),
|
details=json.dumps(details),
|
||||||
)
|
)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
@@ -104,7 +104,7 @@ class BaseData:
|
|||||||
|
|
||||||
async def get_event_log(self, entries: int = 100) -> Optional[List[Dict]]:
|
async def get_event_log(self, entries: int = 100) -> Optional[List[Dict]]:
|
||||||
sql = event_log.select().limit(entries).all()
|
sql = event_log.select().limit(entries).all()
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
|
|||||||
+15
-15
@@ -27,34 +27,34 @@ aime_card = Table(
|
|||||||
|
|
||||||
|
|
||||||
class CardData(BaseData):
|
class CardData(BaseData):
|
||||||
def get_card_by_access_code(self, access_code: str) -> Optional[Row]:
|
async def get_card_by_access_code(self, access_code: str) -> Optional[Row]:
|
||||||
sql = aime_card.select(aime_card.c.access_code == access_code)
|
sql = aime_card.select(aime_card.c.access_code == access_code)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_card_by_id(self, card_id: int) -> Optional[Row]:
|
async def get_card_by_id(self, card_id: int) -> Optional[Row]:
|
||||||
sql = aime_card.select(aime_card.c.id == card_id)
|
sql = aime_card.select(aime_card.c.id == card_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def update_access_code(self, old_ac: str, new_ac: str) -> None:
|
async def update_access_code(self, old_ac: str, new_ac: str) -> None:
|
||||||
sql = aime_card.update(aime_card.c.access_code == old_ac).values(
|
sql = aime_card.update(aime_card.c.access_code == old_ac).values(
|
||||||
access_code=new_ac
|
access_code=new_ac
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"Failed to change card access code from {old_ac} to {new_ac}"
|
f"Failed to change card access code from {old_ac} to {new_ac}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_user_id_from_card(self, access_code: str) -> Optional[int]:
|
async def get_user_id_from_card(self, access_code: str) -> Optional[int]:
|
||||||
"""
|
"""
|
||||||
Given a 20 digit access code as a string, get the user id associated with that card
|
Given a 20 digit access code as a string, get the user id associated with that card
|
||||||
"""
|
"""
|
||||||
@@ -64,7 +64,7 @@ class CardData(BaseData):
|
|||||||
|
|
||||||
return int(card["user"])
|
return int(card["user"])
|
||||||
|
|
||||||
def get_card_banned(self, access_code: str) -> Optional[bool]:
|
async def get_card_banned(self, access_code: str) -> Optional[bool]:
|
||||||
"""
|
"""
|
||||||
Given a 20 digit access code as a string, check if the card is banned
|
Given a 20 digit access code as a string, check if the card is banned
|
||||||
"""
|
"""
|
||||||
@@ -74,7 +74,7 @@ class CardData(BaseData):
|
|||||||
if card["is_banned"]:
|
if card["is_banned"]:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
def get_card_locked(self, access_code: str) -> Optional[bool]:
|
async def get_card_locked(self, access_code: str) -> Optional[bool]:
|
||||||
"""
|
"""
|
||||||
Given a 20 digit access code as a string, check if the card is locked
|
Given a 20 digit access code as a string, check if the card is locked
|
||||||
"""
|
"""
|
||||||
@@ -85,29 +85,29 @@ class CardData(BaseData):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def delete_card(self, card_id: int) -> None:
|
async def delete_card(self, card_id: int) -> None:
|
||||||
sql = aime_card.delete(aime_card.c.id == card_id)
|
sql = aime_card.delete(aime_card.c.id == card_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(f"Failed to delete card with id {card_id}")
|
self.logger.error(f"Failed to delete card with id {card_id}")
|
||||||
|
|
||||||
def get_user_cards(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_user_cards(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
"""
|
"""
|
||||||
Returns all cards owned by a user
|
Returns all cards owned by a user
|
||||||
"""
|
"""
|
||||||
sql = aime_card.select(aime_card.c.user == aime_id)
|
sql = aime_card.select(aime_card.c.user == aime_id)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def create_card(self, user_id: int, access_code: str) -> Optional[int]:
|
async def create_card(self, user_id: int, access_code: str) -> Optional[int]:
|
||||||
"""
|
"""
|
||||||
Given a aime_user id and a 20 digit access code as a string, create a card and return the ID if successful
|
Given a aime_user id and a 20 digit access code as a string, create a card and return the ID if successful
|
||||||
"""
|
"""
|
||||||
sql = aime_card.insert().values(user=user_id, access_code=access_code)
|
sql = aime_card.insert().values(user=user_id, access_code=access_code)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|||||||
+12
-25
@@ -1,4 +1,3 @@
|
|||||||
from enum import Enum
|
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
from sqlalchemy import Table, Column
|
from sqlalchemy import Table, Column
|
||||||
from sqlalchemy.types import Integer, String, TIMESTAMP
|
from sqlalchemy.types import Integer, String, TIMESTAMP
|
||||||
@@ -24,15 +23,8 @@ aime_user = Table(
|
|||||||
mysql_charset="utf8mb4",
|
mysql_charset="utf8mb4",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class PermissionBits(Enum):
|
|
||||||
PermUser = 1
|
|
||||||
PermMod = 2
|
|
||||||
PermSysAdmin = 4
|
|
||||||
|
|
||||||
|
|
||||||
class UserData(BaseData):
|
class UserData(BaseData):
|
||||||
def create_user(
|
async def create_user(
|
||||||
self,
|
self,
|
||||||
id: int = None,
|
id: int = None,
|
||||||
username: str = None,
|
username: str = None,
|
||||||
@@ -60,14 +52,14 @@ class UserData(BaseData):
|
|||||||
username=username, email=email, password=password, permissions=permission
|
username=username, email=email, password=password, permissions=permission
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_user(self, user_id: int) -> Optional[Row]:
|
async def get_user(self, user_id: int) -> Optional[Row]:
|
||||||
sql = select(aime_user).where(aime_user.c.id == user_id)
|
sql = select(aime_user).where(aime_user.c.id == user_id)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return False
|
return False
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
@@ -85,39 +77,34 @@ class UserData(BaseData):
|
|||||||
|
|
||||||
return bcrypt.checkpw(passwd, usr["password"].encode())
|
return bcrypt.checkpw(passwd, usr["password"].encode())
|
||||||
|
|
||||||
def reset_autoincrement(self, ai_value: int) -> None:
|
async def delete_user(self, user_id: int) -> None:
|
||||||
# ALTER TABLE isn't in sqlalchemy so we do this the ugly way
|
|
||||||
sql = f"ALTER TABLE aime_user AUTO_INCREMENT={ai_value}"
|
|
||||||
self.execute(sql)
|
|
||||||
|
|
||||||
def delete_user(self, user_id: int) -> None:
|
|
||||||
sql = aime_user.delete(aime_user.c.id == user_id)
|
sql = aime_user.delete(aime_user.c.id == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(f"Failed to delete user with id {user_id}")
|
self.logger.error(f"Failed to delete user with id {user_id}")
|
||||||
|
|
||||||
def get_unregistered_users(self) -> List[Row]:
|
async def get_unregistered_users(self) -> List[Row]:
|
||||||
"""
|
"""
|
||||||
Returns a list of users who have not registered with the webui. They may or may not have cards.
|
Returns a list of users who have not registered with the webui. They may or may not have cards.
|
||||||
"""
|
"""
|
||||||
sql = select(aime_user).where(aime_user.c.password == None)
|
sql = select(aime_user).where(aime_user.c.password == None)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def find_user_by_email(self, email: str) -> Row:
|
async def find_user_by_email(self, email: str) -> Row:
|
||||||
sql = select(aime_user).where(aime_user.c.email == email)
|
sql = select(aime_user).where(aime_user.c.email == email)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return False
|
return False
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def find_user_by_username(self, username: str) -> List[Row]:
|
async def find_user_by_username(self, username: str) -> List[Row]:
|
||||||
sql = aime_user.select(aime_user.c.username.like(f"%{username}%"))
|
sql = aime_user.select(aime_user.c.username.like(f"%{username}%"))
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return False
|
return False
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|||||||
+31
-31
@@ -110,7 +110,7 @@ class FrontendServlet(resource.Resource):
|
|||||||
async def robots(cls, request: Request) -> PlainTextResponse:
|
async def robots(cls, request: Request) -> PlainTextResponse:
|
||||||
return PlainTextResponse("User-agent: *\nDisallow: /\n\nUser-agent: AdsBot-Google\nDisallow: /")
|
return PlainTextResponse("User-agent: *\nDisallow: /\n\nUser-agent: AdsBot-Google\nDisallow: /")
|
||||||
|
|
||||||
def render_GET(self, request):
|
async def render_GET(self, request):
|
||||||
self.logger.debug(f"{Utils.get_ip_addr(request)} -> {request.uri.decode()}")
|
self.logger.debug(f"{Utils.get_ip_addr(request)} -> {request.uri.decode()}")
|
||||||
template = self.environment.get_template("core/frontend/index.jinja")
|
template = self.environment.get_template("core/frontend/index.jinja")
|
||||||
return template.render(
|
return template.render(
|
||||||
@@ -167,7 +167,7 @@ class FE_Gate(FE_Base):
|
|||||||
sesh=vars(usr_sesh),
|
sesh=vars(usr_sesh),
|
||||||
).encode("utf-16")
|
).encode("utf-16")
|
||||||
|
|
||||||
def render_POST(self, request: Request):
|
async def render_POST(self, request: Request):
|
||||||
uri = request.uri.decode()
|
uri = request.uri.decode()
|
||||||
ip = Utils.get_ip_addr(request)
|
ip = Utils.get_ip_addr(request)
|
||||||
|
|
||||||
@@ -177,13 +177,13 @@ class FE_Gate(FE_Base):
|
|||||||
if passwd == b"":
|
if passwd == b"":
|
||||||
passwd = None
|
passwd = None
|
||||||
|
|
||||||
uid = self.data.card.get_user_id_from_card(access_code)
|
uid = await self.data.card.get_user_id_from_card(access_code)
|
||||||
user = self.data.user.get_user(uid)
|
user = await self.data.user.get_user(uid)
|
||||||
if uid is None:
|
if uid is None:
|
||||||
return redirectTo(b"/gate?e=1", request)
|
return redirectTo(b"/gate?e=1", request)
|
||||||
|
|
||||||
if passwd is None:
|
if passwd is None:
|
||||||
sesh = self.data.user.check_password(uid)
|
sesh = await self.data.user.check_password(uid)
|
||||||
|
|
||||||
if sesh is not None:
|
if sesh is not None:
|
||||||
return redirectTo(
|
return redirectTo(
|
||||||
@@ -210,14 +210,14 @@ class FE_Gate(FE_Base):
|
|||||||
email: str = request.args[b"email"][0].decode()
|
email: str = request.args[b"email"][0].decode()
|
||||||
passwd: bytes = request.args[b"passwd"][0]
|
passwd: bytes = request.args[b"passwd"][0]
|
||||||
|
|
||||||
uid = self.data.card.get_user_id_from_card(access_code)
|
uid = await self.data.card.get_user_id_from_card(access_code)
|
||||||
if uid is None:
|
if uid is None:
|
||||||
return redirectTo(b"/gate?e=1", request)
|
return redirectTo(b"/gate?e=1", request)
|
||||||
|
|
||||||
salt = bcrypt.gensalt()
|
salt = bcrypt.gensalt()
|
||||||
hashed = bcrypt.hashpw(passwd, salt)
|
hashed = bcrypt.hashpw(passwd, salt)
|
||||||
|
|
||||||
result = self.data.user.create_user(
|
result = await self.data.user.create_user(
|
||||||
uid, username, email.lower(), hashed.decode(), 1
|
uid, username, email.lower(), hashed.decode(), 1
|
||||||
)
|
)
|
||||||
if result is None:
|
if result is None:
|
||||||
@@ -231,16 +231,16 @@ class FE_Gate(FE_Base):
|
|||||||
else:
|
else:
|
||||||
return b""
|
return b""
|
||||||
|
|
||||||
def create_user(self, request: Request):
|
async def create_user(self, request: Request):
|
||||||
if b"ac" not in request.args or len(request.args[b"ac"][0].decode()) != 20:
|
if b"ac" not in request.args or len(request.args[b"ac"][0].decode()) != 20:
|
||||||
return redirectTo(b"/gate?e=2", request)
|
return redirectTo(b"/gate?e=2", request)
|
||||||
|
|
||||||
ac = request.args[b"ac"][0].decode()
|
ac = request.args[b"ac"][0].decode()
|
||||||
card = self.data.card.get_card_by_access_code(ac)
|
card = await self.data.card.get_card_by_access_code(ac)
|
||||||
if card is None:
|
if card is None:
|
||||||
return redirectTo(b"/gate?e=1", request)
|
return redirectTo(b"/gate?e=1", request)
|
||||||
|
|
||||||
user = self.data.user.get_user(card['user'])
|
user = await self.data.user.get_user(card['user'])
|
||||||
if user is None:
|
if user is None:
|
||||||
self.logger.warning(f"Card {ac} exists with no/invalid associated user ID {card['user']}")
|
self.logger.warning(f"Card {ac} exists with no/invalid associated user ID {card['user']}")
|
||||||
return redirectTo(b"/gate?e=0", request)
|
return redirectTo(b"/gate?e=0", request)
|
||||||
@@ -257,7 +257,7 @@ class FE_Gate(FE_Base):
|
|||||||
|
|
||||||
|
|
||||||
class FE_User(FE_Base):
|
class FE_User(FE_Base):
|
||||||
def render_GET(self, request: Request):
|
async def render_GET(self, request: Request):
|
||||||
uri = request.uri.decode()
|
uri = request.uri.decode()
|
||||||
template = self.environment.get_template("core/frontend/user/index.jinja")
|
template = self.environment.get_template("core/frontend/user/index.jinja")
|
||||||
|
|
||||||
@@ -276,12 +276,12 @@ class FE_User(FE_Base):
|
|||||||
else:
|
else:
|
||||||
usrid = usr_sesh.userId
|
usrid = usr_sesh.userId
|
||||||
|
|
||||||
user = self.data.user.get_user(usrid)
|
user = await self.data.user.get_user(usrid)
|
||||||
if user is None:
|
if user is None:
|
||||||
return redirectTo(b"/user", request)
|
return redirectTo(b"/user", request)
|
||||||
|
|
||||||
cards = self.data.card.get_user_cards(usrid)
|
cards = await self.data.card.get_user_cards(usrid)
|
||||||
arcades = self.data.arcade.get_arcades_managed_by_user(usrid)
|
arcades = await self.data.arcade.get_arcades_managed_by_user(usrid)
|
||||||
|
|
||||||
card_data = []
|
card_data = []
|
||||||
arcade_data = []
|
arcade_data = []
|
||||||
@@ -307,12 +307,12 @@ class FE_User(FE_Base):
|
|||||||
arcades=arcade_data
|
arcades=arcade_data
|
||||||
).encode("utf-16")
|
).encode("utf-16")
|
||||||
|
|
||||||
def render_POST(self, request: Request):
|
async def render_POST(self, request: Request):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class FE_System(FE_Base):
|
class FE_System(FE_Base):
|
||||||
def render_GET(self, request: Request):
|
async def render_GET(self, request: Request):
|
||||||
uri = request.uri.decode()
|
uri = request.uri.decode()
|
||||||
template = self.environment.get_template("core/frontend/sys/index.jinja")
|
template = self.environment.get_template("core/frontend/sys/index.jinja")
|
||||||
usrlist: List[Dict] = []
|
usrlist: List[Dict] = []
|
||||||
@@ -331,17 +331,17 @@ class FE_System(FE_Base):
|
|||||||
uname_search = uri_parse.get("usrName")
|
uname_search = uri_parse.get("usrName")
|
||||||
|
|
||||||
if uid_search is not None:
|
if uid_search is not None:
|
||||||
u = self.data.user.get_user(uid_search[0])
|
u = await self.data.user.get_user(uid_search[0])
|
||||||
if u is not None:
|
if u is not None:
|
||||||
usrlist.append(u._asdict())
|
usrlist.append(u._asdict())
|
||||||
|
|
||||||
elif email_search is not None:
|
elif email_search is not None:
|
||||||
u = self.data.user.find_user_by_email(email_search[0])
|
u = await self.data.user.find_user_by_email(email_search[0])
|
||||||
if u is not None:
|
if u is not None:
|
||||||
usrlist.append(u._asdict())
|
usrlist.append(u._asdict())
|
||||||
|
|
||||||
elif uname_search is not None:
|
elif uname_search is not None:
|
||||||
ul = self.data.user.find_user_by_username(uname_search[0])
|
ul = await self.data.user.find_user_by_username(uname_search[0])
|
||||||
for u in ul:
|
for u in ul:
|
||||||
usrlist.append(u._asdict())
|
usrlist.append(u._asdict())
|
||||||
|
|
||||||
@@ -353,24 +353,24 @@ class FE_System(FE_Base):
|
|||||||
ac_ip_search = uri_parse.get("arcadeIp")
|
ac_ip_search = uri_parse.get("arcadeIp")
|
||||||
|
|
||||||
if ac_id_search is not None:
|
if ac_id_search is not None:
|
||||||
u = self.data.arcade.get_arcade(ac_id_search[0])
|
u = await self.data.arcade.get_arcade(ac_id_search[0])
|
||||||
if u is not None:
|
if u is not None:
|
||||||
aclist.append(u._asdict())
|
aclist.append(u._asdict())
|
||||||
|
|
||||||
elif ac_name_search is not None:
|
elif ac_name_search is not None:
|
||||||
ul = self.data.arcade.get_arcade_by_name(ac_name_search[0])
|
ul = await self.data.arcade.get_arcade_by_name(ac_name_search[0])
|
||||||
if ul is not None:
|
if ul is not None:
|
||||||
for u in ul:
|
for u in ul:
|
||||||
aclist.append(u._asdict())
|
aclist.append(u._asdict())
|
||||||
|
|
||||||
elif ac_user_search is not None:
|
elif ac_user_search is not None:
|
||||||
ul = self.data.arcade.get_arcades_managed_by_user(ac_user_search[0])
|
ul = await self.data.arcade.get_arcades_managed_by_user(ac_user_search[0])
|
||||||
if ul is not None:
|
if ul is not None:
|
||||||
for u in ul:
|
for u in ul:
|
||||||
aclist.append(u._asdict())
|
aclist.append(u._asdict())
|
||||||
|
|
||||||
elif ac_ip_search is not None:
|
elif ac_ip_search is not None:
|
||||||
ul = self.data.arcade.get_arcades_by_ip(ac_ip_search[0])
|
ul = await self.data.arcade.get_arcades_by_ip(ac_ip_search[0])
|
||||||
if ul is not None:
|
if ul is not None:
|
||||||
for u in ul:
|
for u in ul:
|
||||||
aclist.append(u._asdict())
|
aclist.append(u._asdict())
|
||||||
@@ -382,17 +382,17 @@ class FE_System(FE_Base):
|
|||||||
cab_acid_search = uri_parse.get("cabAcId")
|
cab_acid_search = uri_parse.get("cabAcId")
|
||||||
|
|
||||||
if cab_id_search is not None:
|
if cab_id_search is not None:
|
||||||
u = self.data.arcade.get_machine(id=cab_id_search[0])
|
u = await self.data.arcade.get_machine(id=cab_id_search[0])
|
||||||
if u is not None:
|
if u is not None:
|
||||||
cablist.append(u._asdict())
|
cablist.append(u._asdict())
|
||||||
|
|
||||||
elif cab_serial_search is not None:
|
elif cab_serial_search is not None:
|
||||||
u = self.data.arcade.get_machine(serial=cab_serial_search[0])
|
u = await self.data.arcade.get_machine(serial=cab_serial_search[0])
|
||||||
if u is not None:
|
if u is not None:
|
||||||
cablist.append(u._asdict())
|
cablist.append(u._asdict())
|
||||||
|
|
||||||
elif cab_acid_search is not None:
|
elif cab_acid_search is not None:
|
||||||
ul = self.data.arcade.get_arcade_machines(cab_acid_search[0])
|
ul = await self.data.arcade.get_arcade_machines(cab_acid_search[0])
|
||||||
for u in ul:
|
for u in ul:
|
||||||
cablist.append(u._asdict())
|
cablist.append(u._asdict())
|
||||||
|
|
||||||
@@ -414,12 +414,12 @@ class FE_Game(FE_Base):
|
|||||||
return self
|
return self
|
||||||
return resource.Resource.getChild(self, name, request)
|
return resource.Resource.getChild(self, name, request)
|
||||||
|
|
||||||
def render_GET(self, request: Request) -> bytes:
|
async def render_GET(self, request: Request) -> bytes:
|
||||||
return redirectTo(b"/user", request)
|
return redirectTo(b"/user", request)
|
||||||
|
|
||||||
|
|
||||||
class FE_Arcade(FE_Base):
|
class FE_Arcade(FE_Base):
|
||||||
def render_GET(self, request: Request):
|
async def render_GET(self, request: Request):
|
||||||
uri = request.uri.decode()
|
uri = request.uri.decode()
|
||||||
template = self.environment.get_template("core/frontend/arcade/index.jinja")
|
template = self.environment.get_template("core/frontend/arcade/index.jinja")
|
||||||
managed = []
|
managed = []
|
||||||
@@ -433,8 +433,8 @@ class FE_Arcade(FE_Base):
|
|||||||
|
|
||||||
if m is not None:
|
if m is not None:
|
||||||
arcadeid = m.group(1)
|
arcadeid = m.group(1)
|
||||||
perms = self.data.arcade.get_manager_permissions(usr_sesh.userId, arcadeid)
|
perms = await self.data.arcade.get_manager_permissions(usr_sesh.userId, arcadeid)
|
||||||
arcade = self.data.arcade.get_arcade(arcadeid)
|
arcade = await self.data.arcade.get_arcade(arcadeid)
|
||||||
|
|
||||||
if perms is None:
|
if perms is None:
|
||||||
perms = 0
|
perms = 0
|
||||||
@@ -452,7 +452,7 @@ class FE_Arcade(FE_Base):
|
|||||||
|
|
||||||
|
|
||||||
class FE_Machine(FE_Base):
|
class FE_Machine(FE_Base):
|
||||||
def render_GET(self, request: Request):
|
async def render_GET(self, request: Request):
|
||||||
uri = request.uri.decode()
|
uri = request.uri.decode()
|
||||||
template = self.environment.get_template("core/frontend/machine/index.jinja")
|
template = self.environment.get_template("core/frontend/machine/index.jinja")
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ title:
|
|||||||
loglevel: "info"
|
loglevel: "info"
|
||||||
reboot_start_time: "04:00"
|
reboot_start_time: "04:00"
|
||||||
reboot_end_time: "05:00"
|
reboot_end_time: "05:00"
|
||||||
ssl_key: "cert/title.key"
|
|
||||||
|
|
||||||
database:
|
database:
|
||||||
host: "localhost"
|
host: "localhost"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import yaml
|
|||||||
from os import path
|
from os import path
|
||||||
import logging
|
import logging
|
||||||
import coloredlogs
|
import coloredlogs
|
||||||
|
import asyncio
|
||||||
|
|
||||||
from logging.handlers import TimedRotatingFileHandler
|
from logging.handlers import TimedRotatingFileHandler
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
@@ -39,6 +40,9 @@ class BaseReader:
|
|||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
async def read(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(description="Import Game Information")
|
parser = argparse.ArgumentParser(description="Import Game Information")
|
||||||
@@ -136,6 +140,8 @@ if __name__ == "__main__":
|
|||||||
for dir, mod in titles.items():
|
for dir, mod in titles.items():
|
||||||
if args.game in mod.game_codes:
|
if args.game in mod.game_codes:
|
||||||
handler = mod.reader(config, args.version, bin_arg, opt_arg, args.extra)
|
handler = mod.reader(config, args.version, bin_arg, opt_arg, args.extra)
|
||||||
handler.read()
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.run_until_complete(handler.read())
|
||||||
|
|
||||||
|
|
||||||
logger.info("Done")
|
logger.info("Done")
|
||||||
|
|||||||
+54
-54
@@ -38,20 +38,20 @@ class ChuniBase:
|
|||||||
return {"returnCode": 1}
|
return {"returnCode": 1}
|
||||||
|
|
||||||
user_id = data["userId"]
|
user_id = data["userId"]
|
||||||
login_bonus_presets = self.data.static.get_login_bonus_presets(self.version)
|
login_bonus_presets = await self.data.static.get_login_bonus_presets(self.version)
|
||||||
|
|
||||||
for preset in login_bonus_presets:
|
for preset in login_bonus_presets:
|
||||||
# check if a user already has some pogress and if not add the
|
# check if a user already has some pogress and if not add the
|
||||||
# login bonus entry
|
# login bonus entry
|
||||||
user_login_bonus = self.data.item.get_login_bonus(
|
user_login_bonus = await self.data.item.get_login_bonus(
|
||||||
user_id, self.version, preset["presetId"]
|
user_id, self.version, preset["presetId"]
|
||||||
)
|
)
|
||||||
if user_login_bonus is None:
|
if user_login_bonus is None:
|
||||||
self.data.item.put_login_bonus(
|
await self.data.item.put_login_bonus(
|
||||||
user_id, self.version, preset["presetId"]
|
user_id, self.version, preset["presetId"]
|
||||||
)
|
)
|
||||||
# yeah i'm lazy
|
# yeah i'm lazy
|
||||||
user_login_bonus = self.data.item.get_login_bonus(
|
user_login_bonus = await self.data.item.get_login_bonus(
|
||||||
user_id, self.version, preset["presetId"]
|
user_id, self.version, preset["presetId"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ class ChuniBase:
|
|||||||
bonus_count = user_login_bonus["bonusCount"] + 1
|
bonus_count = user_login_bonus["bonusCount"] + 1
|
||||||
last_update_date = datetime.now()
|
last_update_date = datetime.now()
|
||||||
|
|
||||||
all_login_boni = self.data.static.get_login_bonus(
|
all_login_boni = await self.data.static.get_login_bonus(
|
||||||
self.version, preset["presetId"]
|
self.version, preset["presetId"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -91,13 +91,13 @@ class ChuniBase:
|
|||||||
is_finished = True
|
is_finished = True
|
||||||
|
|
||||||
# grab the item for the corresponding day
|
# grab the item for the corresponding day
|
||||||
login_item = self.data.static.get_login_bonus_by_required_days(
|
login_item = await self.data.static.get_login_bonus_by_required_days(
|
||||||
self.version, preset["presetId"], bonus_count
|
self.version, preset["presetId"], bonus_count
|
||||||
)
|
)
|
||||||
if login_item is not None:
|
if login_item is not None:
|
||||||
# now add the present to the database so the
|
# now add the present to the database so the
|
||||||
# handle_get_user_item_api_request can grab them
|
# handle_get_user_item_api_request can grab them
|
||||||
self.data.item.put_item(
|
await self.data.item.put_item(
|
||||||
user_id,
|
user_id,
|
||||||
{
|
{
|
||||||
"itemId": login_item["presentId"],
|
"itemId": login_item["presentId"],
|
||||||
@@ -107,7 +107,7 @@ class ChuniBase:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.data.item.put_login_bonus(
|
await self.data.item.put_login_bonus(
|
||||||
user_id,
|
user_id,
|
||||||
self.version,
|
self.version,
|
||||||
preset["presetId"],
|
preset["presetId"],
|
||||||
@@ -124,7 +124,7 @@ class ChuniBase:
|
|||||||
return {"returnCode": 1}
|
return {"returnCode": 1}
|
||||||
|
|
||||||
async def handle_get_game_charge_api_request(self, data: Dict) -> Dict:
|
async def handle_get_game_charge_api_request(self, data: Dict) -> Dict:
|
||||||
game_charge_list = self.data.static.get_enabled_charges(self.version)
|
game_charge_list = await self.data.static.get_enabled_charges(self.version)
|
||||||
|
|
||||||
if game_charge_list is None or len(game_charge_list) == 0:
|
if game_charge_list is None or len(game_charge_list) == 0:
|
||||||
return {"length": 0, "gameChargeList": []}
|
return {"length": 0, "gameChargeList": []}
|
||||||
@@ -146,7 +146,7 @@ class ChuniBase:
|
|||||||
return {"length": len(charges), "gameChargeList": charges}
|
return {"length": len(charges), "gameChargeList": charges}
|
||||||
|
|
||||||
async def handle_get_game_event_api_request(self, data: Dict) -> Dict:
|
async def handle_get_game_event_api_request(self, data: Dict) -> Dict:
|
||||||
game_events = self.data.static.get_enabled_events(self.version)
|
game_events = await self.data.static.get_enabled_events(self.version)
|
||||||
|
|
||||||
if game_events is None or len(game_events) == 0:
|
if game_events is None or len(game_events) == 0:
|
||||||
self.logger.warning("No enabled events, did you run the reader?")
|
self.logger.warning("No enabled events, did you run the reader?")
|
||||||
@@ -194,7 +194,7 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_game_ranking_api_request(self, data: Dict) -> Dict:
|
async def handle_get_game_ranking_api_request(self, data: Dict) -> Dict:
|
||||||
rankings = self.data.score.get_rankings(self.version)
|
rankings = await self.data.score.get_rankings(self.version)
|
||||||
return {"type": data["type"], "gameRankingList": rankings}
|
return {"type": data["type"], "gameRankingList": rankings}
|
||||||
|
|
||||||
async def handle_get_game_sale_api_request(self, data: Dict) -> Dict:
|
async def handle_get_game_sale_api_request(self, data: Dict) -> Dict:
|
||||||
@@ -241,7 +241,7 @@ class ChuniBase:
|
|||||||
"isAou": "false",
|
"isAou": "false",
|
||||||
}
|
}
|
||||||
async def handle_get_user_activity_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_activity_api_request(self, data: Dict) -> Dict:
|
||||||
user_activity_list = self.data.profile.get_profile_activity(
|
user_activity_list = await self.data.profile.get_profile_activity(
|
||||||
data["userId"], data["kind"]
|
data["userId"], data["kind"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_character_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_character_api_request(self, data: Dict) -> Dict:
|
||||||
characters = self.data.item.get_characters(data["userId"])
|
characters = await self.data.item.get_characters(data["userId"])
|
||||||
if characters is None:
|
if characters is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -297,7 +297,7 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_charge_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_charge_api_request(self, data: Dict) -> Dict:
|
||||||
user_charge_list = self.data.profile.get_profile_charge(data["userId"])
|
user_charge_list = await self.data.profile.get_profile_charge(data["userId"])
|
||||||
|
|
||||||
charge_list = []
|
charge_list = []
|
||||||
for charge in user_charge_list:
|
for charge in user_charge_list:
|
||||||
@@ -320,7 +320,7 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_course_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_course_api_request(self, data: Dict) -> Dict:
|
||||||
user_course_list = self.data.score.get_courses(data["userId"])
|
user_course_list = await self.data.score.get_courses(data["userId"])
|
||||||
if user_course_list is None:
|
if user_course_list is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -355,7 +355,7 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_data_api_request(self, data: Dict) -> Dict:
|
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:
|
if p is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ class ChuniBase:
|
|||||||
return {"userId": data["userId"], "userData": profile}
|
return {"userId": data["userId"], "userData": profile}
|
||||||
|
|
||||||
async def handle_get_user_data_ex_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_data_ex_api_request(self, data: Dict) -> Dict:
|
||||||
p = self.data.profile.get_profile_data_ex(data["userId"], self.version)
|
p = await self.data.profile.get_profile_data_ex(data["userId"], self.version)
|
||||||
if p is None:
|
if p is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ class ChuniBase:
|
|||||||
return {"userId": data["userId"], "userDataEx": profile}
|
return {"userId": data["userId"], "userDataEx": profile}
|
||||||
|
|
||||||
async def handle_get_user_duel_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_duel_api_request(self, data: Dict) -> Dict:
|
||||||
user_duel_list = self.data.item.get_duels(data["userId"])
|
user_duel_list = await self.data.item.get_duels(data["userId"])
|
||||||
if user_duel_list is None:
|
if user_duel_list is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -397,7 +397,7 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_rival_data_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_rival_data_api_request(self, data: Dict) -> Dict:
|
||||||
p = self.data.profile.get_rival(data["rivalId"])
|
p = await self.data.profile.get_rival(data["rivalId"])
|
||||||
if p is None:
|
if p is None:
|
||||||
return {}
|
return {}
|
||||||
userRivalData = {
|
userRivalData = {
|
||||||
@@ -416,7 +416,7 @@ class ChuniBase:
|
|||||||
user_rival_music_list = []
|
user_rival_music_list = []
|
||||||
|
|
||||||
# Fetch all the rival music entries for the user
|
# Fetch all the rival music entries for the user
|
||||||
all_entries = self.data.score.get_rival_music(rival_id)
|
all_entries = await self.data.score.get_rival_music(rival_id)
|
||||||
|
|
||||||
# Process the entries based on max_count and nextIndex
|
# Process the entries based on max_count and nextIndex
|
||||||
for music in all_entries:
|
for music in all_entries:
|
||||||
@@ -467,7 +467,7 @@ class ChuniBase:
|
|||||||
|
|
||||||
# still needs to be implemented on WebUI
|
# still needs to be implemented on WebUI
|
||||||
# 1: Music, 2: User, 3: Character
|
# 1: Music, 2: User, 3: Character
|
||||||
fav_list = self.data.item.get_all_favorites(
|
fav_list = await self.data.item.get_all_favorites(
|
||||||
data["userId"], self.version, fav_kind=int(data["kind"])
|
data["userId"], self.version, fav_kind=int(data["kind"])
|
||||||
)
|
)
|
||||||
if fav_list is not None:
|
if fav_list is not None:
|
||||||
@@ -492,7 +492,7 @@ class ChuniBase:
|
|||||||
async def handle_get_user_item_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_item_api_request(self, data: Dict) -> Dict:
|
||||||
kind = int(int(data["nextIndex"]) / 10000000000)
|
kind = int(int(data["nextIndex"]) / 10000000000)
|
||||||
next_idx = int(int(data["nextIndex"]) % 10000000000)
|
next_idx = int(int(data["nextIndex"]) % 10000000000)
|
||||||
user_item_list = self.data.item.get_items(data["userId"], kind)
|
user_item_list = await self.data.item.get_items(data["userId"], kind)
|
||||||
|
|
||||||
if user_item_list is None or len(user_item_list) == 0:
|
if user_item_list is None or len(user_item_list) == 0:
|
||||||
return {
|
return {
|
||||||
@@ -528,7 +528,7 @@ class ChuniBase:
|
|||||||
|
|
||||||
async def handle_get_user_login_bonus_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_login_bonus_api_request(self, data: Dict) -> Dict:
|
||||||
user_id = data["userId"]
|
user_id = data["userId"]
|
||||||
user_login_bonus = self.data.item.get_all_login_bonus(user_id, self.version)
|
user_login_bonus = await self.data.item.get_all_login_bonus(user_id, self.version)
|
||||||
# ignore the loginBonus request if its disabled in config
|
# ignore the loginBonus request if its disabled in config
|
||||||
if user_login_bonus is None or not self.game_cfg.mods.use_login_bonus:
|
if user_login_bonus is None or not self.game_cfg.mods.use_login_bonus:
|
||||||
return {"userId": user_id, "length": 0, "userLoginBonusList": []}
|
return {"userId": user_id, "length": 0, "userLoginBonusList": []}
|
||||||
@@ -553,7 +553,7 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_map_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_map_api_request(self, data: Dict) -> Dict:
|
||||||
user_map_list = self.data.item.get_maps(data["userId"])
|
user_map_list = await self.data.item.get_maps(data["userId"])
|
||||||
if user_map_list is None:
|
if user_map_list is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -571,7 +571,7 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_music_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_music_api_request(self, data: Dict) -> Dict:
|
||||||
music_detail = self.data.score.get_scores(data["userId"])
|
music_detail = await self.data.score.get_scores(data["userId"])
|
||||||
if music_detail is None:
|
if music_detail is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -630,7 +630,7 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_option_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_option_api_request(self, data: Dict) -> Dict:
|
||||||
p = self.data.profile.get_profile_option(data["userId"])
|
p = await self.data.profile.get_profile_option(data["userId"])
|
||||||
|
|
||||||
option = p._asdict()
|
option = p._asdict()
|
||||||
option.pop("id")
|
option.pop("id")
|
||||||
@@ -639,7 +639,7 @@ class ChuniBase:
|
|||||||
return {"userId": data["userId"], "userGameOption": option}
|
return {"userId": data["userId"], "userGameOption": option}
|
||||||
|
|
||||||
async def handle_get_user_option_ex_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_option_ex_api_request(self, data: Dict) -> Dict:
|
||||||
p = self.data.profile.get_profile_option_ex(data["userId"])
|
p = await self.data.profile.get_profile_option_ex(data["userId"])
|
||||||
|
|
||||||
option = p._asdict()
|
option = p._asdict()
|
||||||
option.pop("id")
|
option.pop("id")
|
||||||
@@ -651,10 +651,10 @@ class ChuniBase:
|
|||||||
return bytes([ord(c) for c in src]).decode("utf-8")
|
return bytes([ord(c) for c in src]).decode("utf-8")
|
||||||
|
|
||||||
async def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
|
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:
|
if profile is None:
|
||||||
return None
|
return None
|
||||||
profile_character = self.data.item.get_character(
|
profile_character = await self.data.item.get_character(
|
||||||
data["userId"], profile["characterId"]
|
data["userId"], profile["characterId"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -693,7 +693,7 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_recent_rating_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_recent_rating_api_request(self, data: Dict) -> Dict:
|
||||||
recent_rating_list = self.data.profile.get_profile_recent_rating(data["userId"])
|
recent_rating_list = await self.data.profile.get_profile_recent_rating(data["userId"])
|
||||||
if recent_rating_list is None:
|
if recent_rating_list is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -722,15 +722,15 @@ class ChuniBase:
|
|||||||
team_rank = 0
|
team_rank = 0
|
||||||
|
|
||||||
# Get user profile
|
# Get user profile
|
||||||
profile = self.data.profile.get_profile_data(data["userId"], self.version)
|
profile = await self.data.profile.get_profile_data(data["userId"], self.version)
|
||||||
if profile and profile["teamId"]:
|
if profile and profile["teamId"]:
|
||||||
# Get team by id
|
# Get team by id
|
||||||
team = self.data.profile.get_team_by_id(profile["teamId"])
|
team = await self.data.profile.get_team_by_id(profile["teamId"])
|
||||||
|
|
||||||
if team:
|
if team:
|
||||||
team_id = team["id"]
|
team_id = team["id"]
|
||||||
team_name = team["teamName"]
|
team_name = team["teamName"]
|
||||||
team_rank = self.data.profile.get_team_rank(team["id"])
|
team_rank = await self.data.profile.get_team_rank(team["id"])
|
||||||
|
|
||||||
# Don't return anything if no team name has been defined for defaults and there is no team set for the player
|
# Don't return anything if no team name has been defined for defaults and there is no team set for the player
|
||||||
if not profile["teamId"] and team_name == "":
|
if not profile["teamId"] and team_name == "":
|
||||||
@@ -819,58 +819,58 @@ class ChuniBase:
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.data.profile.put_profile_data(
|
await self.data.profile.put_profile_data(
|
||||||
user_id, self.version, upsert["userData"][0]
|
user_id, self.version, upsert["userData"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userDataEx" in upsert:
|
if "userDataEx" in upsert:
|
||||||
self.data.profile.put_profile_data_ex(
|
await self.data.profile.put_profile_data_ex(
|
||||||
user_id, self.version, upsert["userDataEx"][0]
|
user_id, self.version, upsert["userDataEx"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userGameOption" in upsert:
|
if "userGameOption" in upsert:
|
||||||
self.data.profile.put_profile_option(user_id, upsert["userGameOption"][0])
|
await self.data.profile.put_profile_option(user_id, upsert["userGameOption"][0])
|
||||||
|
|
||||||
if "userGameOptionEx" in upsert:
|
if "userGameOptionEx" in upsert:
|
||||||
self.data.profile.put_profile_option_ex(
|
await self.data.profile.put_profile_option_ex(
|
||||||
user_id, upsert["userGameOptionEx"][0]
|
user_id, upsert["userGameOptionEx"][0]
|
||||||
)
|
)
|
||||||
if "userRecentRatingList" in upsert:
|
if "userRecentRatingList" in upsert:
|
||||||
self.data.profile.put_profile_recent_rating(
|
await self.data.profile.put_profile_recent_rating(
|
||||||
user_id, upsert["userRecentRatingList"]
|
user_id, upsert["userRecentRatingList"]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userCharacterList" in upsert:
|
if "userCharacterList" in upsert:
|
||||||
for character in upsert["userCharacterList"]:
|
for character in upsert["userCharacterList"]:
|
||||||
self.data.item.put_character(user_id, character)
|
await self.data.item.put_character(user_id, character)
|
||||||
|
|
||||||
if "userMapList" in upsert:
|
if "userMapList" in upsert:
|
||||||
for map in upsert["userMapList"]:
|
for map in upsert["userMapList"]:
|
||||||
self.data.item.put_map(user_id, map)
|
await self.data.item.put_map(user_id, map)
|
||||||
|
|
||||||
if "userCourseList" in upsert:
|
if "userCourseList" in upsert:
|
||||||
for course in upsert["userCourseList"]:
|
for course in upsert["userCourseList"]:
|
||||||
self.data.score.put_course(user_id, course)
|
await self.data.score.put_course(user_id, course)
|
||||||
|
|
||||||
if "userDuelList" in upsert:
|
if "userDuelList" in upsert:
|
||||||
for duel in upsert["userDuelList"]:
|
for duel in upsert["userDuelList"]:
|
||||||
self.data.item.put_duel(user_id, duel)
|
await self.data.item.put_duel(user_id, duel)
|
||||||
|
|
||||||
if "userItemList" in upsert:
|
if "userItemList" in upsert:
|
||||||
for item in upsert["userItemList"]:
|
for item in upsert["userItemList"]:
|
||||||
self.data.item.put_item(user_id, item)
|
await self.data.item.put_item(user_id, item)
|
||||||
|
|
||||||
if "userActivityList" in upsert:
|
if "userActivityList" in upsert:
|
||||||
for activity in upsert["userActivityList"]:
|
for activity in upsert["userActivityList"]:
|
||||||
self.data.profile.put_profile_activity(user_id, activity)
|
await self.data.profile.put_profile_activity(user_id, activity)
|
||||||
|
|
||||||
if "userChargeList" in upsert:
|
if "userChargeList" in upsert:
|
||||||
for charge in upsert["userChargeList"]:
|
for charge in upsert["userChargeList"]:
|
||||||
self.data.profile.put_profile_charge(user_id, charge)
|
await self.data.profile.put_profile_charge(user_id, charge)
|
||||||
|
|
||||||
if "userMusicDetailList" in upsert:
|
if "userMusicDetailList" in upsert:
|
||||||
for song in upsert["userMusicDetailList"]:
|
for song in upsert["userMusicDetailList"]:
|
||||||
self.data.score.put_score(user_id, song)
|
await self.data.score.put_score(user_id, song)
|
||||||
|
|
||||||
if "userPlaylogList" in upsert:
|
if "userPlaylogList" in upsert:
|
||||||
for playlog in upsert["userPlaylogList"]:
|
for playlog in upsert["userPlaylogList"]:
|
||||||
@@ -881,7 +881,7 @@ class ChuniBase:
|
|||||||
playlog["playedUserName2"] = self.read_wtf8(playlog["playedUserName2"])
|
playlog["playedUserName2"] = self.read_wtf8(playlog["playedUserName2"])
|
||||||
if playlog["playedUserName3"] is not None:
|
if playlog["playedUserName3"] is not None:
|
||||||
playlog["playedUserName3"] = self.read_wtf8(playlog["playedUserName3"])
|
playlog["playedUserName3"] = self.read_wtf8(playlog["playedUserName3"])
|
||||||
self.data.score.put_playlog(user_id, playlog, self.version)
|
await self.data.score.put_playlog(user_id, playlog, self.version)
|
||||||
|
|
||||||
if "userTeamPoint" in upsert:
|
if "userTeamPoint" in upsert:
|
||||||
team_points = upsert["userTeamPoint"]
|
team_points = upsert["userTeamPoint"]
|
||||||
@@ -889,7 +889,7 @@ class ChuniBase:
|
|||||||
for tp in team_points:
|
for tp in team_points:
|
||||||
if tp["teamId"] != '65535':
|
if tp["teamId"] != '65535':
|
||||||
# Fetch the current team data
|
# Fetch the current team data
|
||||||
current_team = self.data.profile.get_team_by_id(tp["teamId"])
|
current_team = await self.data.profile.get_team_by_id(tp["teamId"])
|
||||||
|
|
||||||
# Calculate the new teamPoint
|
# Calculate the new teamPoint
|
||||||
new_team_point = int(tp["teamPoint"]) + current_team["teamPoint"]
|
new_team_point = int(tp["teamPoint"]) + current_team["teamPoint"]
|
||||||
@@ -900,24 +900,24 @@ class ChuniBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Update the team data
|
# Update the team data
|
||||||
self.data.profile.update_team(tp["teamId"], team_data)
|
await self.data.profile.update_team(tp["teamId"], team_data)
|
||||||
except:
|
except:
|
||||||
pass # Probably a better way to catch if the team is not set yet (new profiles), but let's just pass
|
pass # Probably a better way to catch if the team is not set yet (new profiles), but let's just pass
|
||||||
if "userMapAreaList" in upsert:
|
if "userMapAreaList" in upsert:
|
||||||
for map_area in upsert["userMapAreaList"]:
|
for map_area in upsert["userMapAreaList"]:
|
||||||
self.data.item.put_map_area(user_id, map_area)
|
await self.data.item.put_map_area(user_id, map_area)
|
||||||
|
|
||||||
if "userOverPowerList" in upsert:
|
if "userOverPowerList" in upsert:
|
||||||
for overpower in upsert["userOverPowerList"]:
|
for overpower in upsert["userOverPowerList"]:
|
||||||
self.data.profile.put_profile_overpower(user_id, overpower)
|
await self.data.profile.put_profile_overpower(user_id, overpower)
|
||||||
|
|
||||||
if "userEmoneyList" in upsert:
|
if "userEmoneyList" in upsert:
|
||||||
for emoney in upsert["userEmoneyList"]:
|
for emoney in upsert["userEmoneyList"]:
|
||||||
self.data.profile.put_profile_emoney(user_id, emoney)
|
await self.data.profile.put_profile_emoney(user_id, emoney)
|
||||||
|
|
||||||
if "userLoginBonusList" in upsert:
|
if "userLoginBonusList" in upsert:
|
||||||
for login in upsert["userLoginBonusList"]:
|
for login in upsert["userLoginBonusList"]:
|
||||||
self.data.item.put_login_bonus(
|
await self.data.item.put_login_bonus(
|
||||||
user_id, self.version, login["presetId"], isWatched=True
|
user_id, self.version, login["presetId"], isWatched=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -930,7 +930,7 @@ class ChuniBase:
|
|||||||
async def handle_upsert_user_chargelog_api_request(self, data: Dict) -> Dict:
|
async def handle_upsert_user_chargelog_api_request(self, data: Dict) -> Dict:
|
||||||
# add tickets after they got bought, this makes sure the tickets are
|
# add tickets after they got bought, this makes sure the tickets are
|
||||||
# still valid after an unsuccessful logout
|
# still valid after an unsuccessful logout
|
||||||
self.data.profile.put_profile_charge(data["userId"], data["userCharge"])
|
await self.data.profile.put_profile_charge(data["userId"], data["userCharge"])
|
||||||
return {"returnCode": "1"}
|
return {"returnCode": "1"}
|
||||||
|
|
||||||
async def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict:
|
async def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict:
|
||||||
|
|||||||
+33
-33
@@ -102,7 +102,7 @@ class ChuniNew(ChuniBase):
|
|||||||
return {"returnCode": "1"}
|
return {"returnCode": "1"}
|
||||||
|
|
||||||
async def handle_get_user_map_area_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_map_area_api_request(self, data: Dict) -> Dict:
|
||||||
user_map_areas = self.data.item.get_map_areas(data["userId"])
|
user_map_areas = await self.data.item.get_map_areas(data["userId"])
|
||||||
|
|
||||||
map_areas = []
|
map_areas = []
|
||||||
for map_area in user_map_areas:
|
for map_area in user_map_areas:
|
||||||
@@ -117,10 +117,10 @@ class ChuniNew(ChuniBase):
|
|||||||
return {"userId": data["userId"], "symbolCharInfoList": []}
|
return {"userId": data["userId"], "symbolCharInfoList": []}
|
||||||
|
|
||||||
async def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
|
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:
|
if profile is None:
|
||||||
return None
|
return None
|
||||||
profile_character = self.data.item.get_character(
|
profile_character = await self.data.item.get_character(
|
||||||
data["userId"], profile["characterId"]
|
data["userId"], profile["characterId"]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ class ChuniNew(ChuniBase):
|
|||||||
return data1
|
return data1
|
||||||
|
|
||||||
async def handle_cm_get_user_preview_api_request(self, data: Dict) -> Dict:
|
async def handle_cm_get_user_preview_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:
|
if p is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ class ChuniNew(ChuniBase):
|
|||||||
"""
|
"""
|
||||||
returns all current active banners (gachas)
|
returns all current active banners (gachas)
|
||||||
"""
|
"""
|
||||||
game_gachas = self.data.static.get_gachas(self.version)
|
game_gachas = await self.data.static.get_gachas(self.version)
|
||||||
|
|
||||||
# clean the database rows
|
# clean the database rows
|
||||||
game_gacha_list = []
|
game_gacha_list = []
|
||||||
@@ -217,7 +217,7 @@ class ChuniNew(ChuniBase):
|
|||||||
"""
|
"""
|
||||||
returns all valid cards for a given gachaId
|
returns all valid cards for a given gachaId
|
||||||
"""
|
"""
|
||||||
game_gacha_cards = self.data.static.get_gacha_cards(data["gachaId"])
|
game_gacha_cards = await self.data.static.get_gacha_cards(data["gachaId"])
|
||||||
|
|
||||||
game_gacha_card_list = []
|
game_gacha_card_list = []
|
||||||
for gacha_card in game_gacha_cards:
|
for gacha_card in game_gacha_cards:
|
||||||
@@ -238,7 +238,7 @@ class ChuniNew(ChuniBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_cm_get_user_data_api_request(self, data: Dict) -> Dict:
|
async def handle_cm_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:
|
if p is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ class ChuniNew(ChuniBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_gacha_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_gachas is None:
|
||||||
return {"userId": data["userId"], "length": 0, "userGachaList": []}
|
return {"userId": data["userId"], "length": 0, "userGachaList": []}
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ class ChuniNew(ChuniBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_printed_card_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_printed_card_api_request(self, data: Dict) -> Dict:
|
||||||
user_print_list = self.data.item.get_user_print_states(
|
user_print_list = await self.data.item.get_user_print_states(
|
||||||
data["userId"], has_completed=True
|
data["userId"], has_completed=True
|
||||||
)
|
)
|
||||||
if user_print_list is None:
|
if user_print_list is None:
|
||||||
@@ -319,7 +319,7 @@ class ChuniNew(ChuniBase):
|
|||||||
async def handle_get_user_card_print_error_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_card_print_error_api_request(self, data: Dict) -> Dict:
|
||||||
user_id = data["userId"]
|
user_id = data["userId"]
|
||||||
|
|
||||||
user_print_states = self.data.item.get_user_print_states(
|
user_print_states = await self.data.item.get_user_print_states(
|
||||||
user_id, has_completed=False
|
user_id, has_completed=False
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -362,14 +362,14 @@ class ChuniNew(ChuniBase):
|
|||||||
# characterId should be returned
|
# characterId should be returned
|
||||||
if chara_id != -1:
|
if chara_id != -1:
|
||||||
# get the
|
# get the
|
||||||
card = self.data.static.get_gacha_card_by_character(gacha_id, chara_id)
|
card = await self.data.static.get_gacha_card_by_character(gacha_id, chara_id)
|
||||||
|
|
||||||
tmp = card._asdict()
|
tmp = card._asdict()
|
||||||
tmp.pop("id")
|
tmp.pop("id")
|
||||||
|
|
||||||
rolled_cards.append(tmp)
|
rolled_cards.append(tmp)
|
||||||
else:
|
else:
|
||||||
gacha_cards = self.data.static.get_gacha_cards(gacha_id)
|
gacha_cards = await self.data.static.get_gacha_cards(gacha_id)
|
||||||
|
|
||||||
# get the card id for each roll
|
# get the card id for each roll
|
||||||
for _ in range(num_rolls):
|
for _ in range(num_rolls):
|
||||||
@@ -396,7 +396,7 @@ class ChuniNew(ChuniBase):
|
|||||||
user_data.pop("rankUpChallengeResults")
|
user_data.pop("rankUpChallengeResults")
|
||||||
user_data.pop("userEmoney")
|
user_data.pop("userEmoney")
|
||||||
|
|
||||||
self.data.profile.put_profile_data(user_id, self.version, user_data)
|
await self.data.profile.put_profile_data(user_id, self.version, user_data)
|
||||||
|
|
||||||
# save the user gacha
|
# save the user gacha
|
||||||
user_gacha = upsert["userGacha"]
|
user_gacha = upsert["userGacha"]
|
||||||
@@ -404,16 +404,16 @@ class ChuniNew(ChuniBase):
|
|||||||
user_gacha.pop("gachaId")
|
user_gacha.pop("gachaId")
|
||||||
user_gacha.pop("dailyGachaDate")
|
user_gacha.pop("dailyGachaDate")
|
||||||
|
|
||||||
self.data.item.put_user_gacha(user_id, gacha_id, user_gacha)
|
await self.data.item.put_user_gacha(user_id, gacha_id, user_gacha)
|
||||||
|
|
||||||
# save all user items
|
# save all user items
|
||||||
if "userItemList" in upsert:
|
if "userItemList" in upsert:
|
||||||
for item in upsert["userItemList"]:
|
for item in upsert["userItemList"]:
|
||||||
self.data.item.put_item(user_id, item)
|
await self.data.item.put_item(user_id, item)
|
||||||
|
|
||||||
# add every gamegachaCard to database
|
# add every gamegachaCard to database
|
||||||
for card in upsert["gameGachaCardList"]:
|
for card in upsert["gameGachaCardList"]:
|
||||||
self.data.item.put_user_print_state(
|
await self.data.item.put_user_print_state(
|
||||||
user_id,
|
user_id,
|
||||||
hasCompleted=False,
|
hasCompleted=False,
|
||||||
placeId=place_id,
|
placeId=place_id,
|
||||||
@@ -423,7 +423,7 @@ class ChuniNew(ChuniBase):
|
|||||||
|
|
||||||
# retrieve every game gacha card which has been added in order to get
|
# retrieve every game gacha card which has been added in order to get
|
||||||
# the orderId for the next request
|
# the orderId for the next request
|
||||||
user_print_states = self.data.item.get_user_print_states_by_gacha(
|
user_print_states = await self.data.item.get_user_print_states_by_gacha(
|
||||||
user_id, gacha_id, has_completed=False
|
user_id, gacha_id, has_completed=False
|
||||||
)
|
)
|
||||||
card_print_state_list = []
|
card_print_state_list = []
|
||||||
@@ -465,7 +465,7 @@ class ChuniNew(ChuniBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# add the entry to the user print table with the random serialId
|
# add the entry to the user print table with the random serialId
|
||||||
self.data.item.put_user_print_detail(user_id, serial_id, user_print_detail)
|
await self.data.item.put_user_print_detail(user_id, serial_id, user_print_detail)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"returnCode": 1,
|
"returnCode": 1,
|
||||||
@@ -482,10 +482,10 @@ class ChuniNew(ChuniBase):
|
|||||||
# save all user items
|
# save all user items
|
||||||
if "userItemList" in data:
|
if "userItemList" in data:
|
||||||
for item in data["userItemList"]:
|
for item in data["userItemList"]:
|
||||||
self.data.item.put_item(user_id, item)
|
await self.data.item.put_item(user_id, item)
|
||||||
|
|
||||||
# set the card print state to success and use the orderId as the key
|
# set the card print state to success and use the orderId as the key
|
||||||
self.data.item.put_user_print_state(
|
await self.data.item.put_user_print_state(
|
||||||
user_id, id=upsert["orderId"], hasCompleted=True
|
user_id, id=upsert["orderId"], hasCompleted=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -497,7 +497,7 @@ class ChuniNew(ChuniBase):
|
|||||||
|
|
||||||
# set the card print state to success and use the orderId as the key
|
# set the card print state to success and use the orderId as the key
|
||||||
for order_id in order_ids:
|
for order_id in order_ids:
|
||||||
self.data.item.put_user_print_state(user_id, id=order_id, hasCompleted=True)
|
await self.data.item.put_user_print_state(user_id, id=order_id, hasCompleted=True)
|
||||||
|
|
||||||
return {"returnCode": "1", "apiName": "CMUpsertUserPrintCancelApi"}
|
return {"returnCode": "1", "apiName": "CMUpsertUserPrintCancelApi"}
|
||||||
|
|
||||||
@@ -508,11 +508,11 @@ class ChuniNew(ChuniBase):
|
|||||||
async def handle_begin_matching_api_request(self, data: Dict) -> Dict:
|
async def handle_begin_matching_api_request(self, data: Dict) -> Dict:
|
||||||
room_id = 1
|
room_id = 1
|
||||||
# check if there is a free matching room
|
# check if there is a free matching room
|
||||||
matching_room = self.data.item.get_oldest_free_matching(self.version)
|
matching_room = await self.data.item.get_oldest_free_matching(self.version)
|
||||||
|
|
||||||
if matching_room is None:
|
if matching_room is None:
|
||||||
# grab the latest roomId and add 1 for the new room
|
# grab the latest roomId and add 1 for the new room
|
||||||
newest_matching = self.data.item.get_newest_matching(self.version)
|
newest_matching = await self.data.item.get_newest_matching(self.version)
|
||||||
if newest_matching is not None:
|
if newest_matching is not None:
|
||||||
room_id = newest_matching["roomId"] + 1
|
room_id = newest_matching["roomId"] + 1
|
||||||
|
|
||||||
@@ -522,12 +522,12 @@ class ChuniNew(ChuniBase):
|
|||||||
|
|
||||||
# create the new room with room_id and the current user id (host)
|
# create the new room with room_id and the current user id (host)
|
||||||
# user id is required for the countdown later on
|
# user id is required for the countdown later on
|
||||||
self.data.item.put_matching(
|
await self.data.item.put_matching(
|
||||||
self.version, room_id, [new_member], user_id=new_member["userId"]
|
self.version, room_id, [new_member], user_id=new_member["userId"]
|
||||||
)
|
)
|
||||||
|
|
||||||
# get the newly created matching room
|
# get the newly created matching room
|
||||||
matching_room = self.data.item.get_matching(self.version, room_id)
|
matching_room = await self.data.item.get_matching(self.version, room_id)
|
||||||
else:
|
else:
|
||||||
# a room already exists, so just add the new member to it
|
# a room already exists, so just add the new member to it
|
||||||
matching_member_list = matching_room["matchingMemberInfoList"]
|
matching_member_list = matching_room["matchingMemberInfoList"]
|
||||||
@@ -537,7 +537,7 @@ class ChuniNew(ChuniBase):
|
|||||||
matching_member_list.append(new_member)
|
matching_member_list.append(new_member)
|
||||||
|
|
||||||
# add the updated room to the database, make sure to set isFull correctly!
|
# add the updated room to the database, make sure to set isFull correctly!
|
||||||
self.data.item.put_matching(
|
await self.data.item.put_matching(
|
||||||
self.version,
|
self.version,
|
||||||
matching_room["roomId"],
|
matching_room["roomId"],
|
||||||
matching_member_list,
|
matching_member_list,
|
||||||
@@ -555,7 +555,7 @@ class ChuniNew(ChuniBase):
|
|||||||
return {"roomId": 1, "matchingWaitState": matching_wait}
|
return {"roomId": 1, "matchingWaitState": matching_wait}
|
||||||
|
|
||||||
async def handle_end_matching_api_request(self, data: Dict) -> Dict:
|
async def handle_end_matching_api_request(self, data: Dict) -> Dict:
|
||||||
matching_room = self.data.item.get_matching(self.version, data["roomId"])
|
matching_room = await self.data.item.get_matching(self.version, data["roomId"])
|
||||||
members = matching_room["matchingMemberInfoList"]
|
members = matching_room["matchingMemberInfoList"]
|
||||||
|
|
||||||
# only set the host user to role 1 every other to 0?
|
# only set the host user to role 1 every other to 0?
|
||||||
@@ -564,7 +564,7 @@ class ChuniNew(ChuniBase):
|
|||||||
for m in members
|
for m in members
|
||||||
]
|
]
|
||||||
|
|
||||||
self.data.item.put_matching(
|
await self.data.item.put_matching(
|
||||||
self.version,
|
self.version,
|
||||||
matching_room["roomId"],
|
matching_room["roomId"],
|
||||||
members,
|
members,
|
||||||
@@ -585,7 +585,7 @@ class ChuniNew(ChuniBase):
|
|||||||
async def handle_remove_matching_member_api_request(self, data: Dict) -> Dict:
|
async def handle_remove_matching_member_api_request(self, data: Dict) -> Dict:
|
||||||
# get all matching rooms, because Chuni only returns the userId
|
# get all matching rooms, because Chuni only returns the userId
|
||||||
# not the actual roomId
|
# not the actual roomId
|
||||||
matching_rooms = self.data.item.get_all_matchings(self.version)
|
matching_rooms = await self.data.item.get_all_matchings(self.version)
|
||||||
if matching_rooms is None:
|
if matching_rooms is None:
|
||||||
return {"returnCode": "1"}
|
return {"returnCode": "1"}
|
||||||
|
|
||||||
@@ -599,10 +599,10 @@ class ChuniNew(ChuniBase):
|
|||||||
|
|
||||||
# if the last user got removed, delete the matching room
|
# if the last user got removed, delete the matching room
|
||||||
if len(new_members) <= 0:
|
if len(new_members) <= 0:
|
||||||
self.data.item.delete_matching(self.version, room["roomId"])
|
await self.data.item.delete_matching(self.version, room["roomId"])
|
||||||
else:
|
else:
|
||||||
# remove the user from the room
|
# remove the user from the room
|
||||||
self.data.item.put_matching(
|
await self.data.item.put_matching(
|
||||||
self.version,
|
self.version,
|
||||||
room["roomId"],
|
room["roomId"],
|
||||||
new_members,
|
new_members,
|
||||||
@@ -615,7 +615,7 @@ class ChuniNew(ChuniBase):
|
|||||||
async def handle_get_matching_state_api_request(self, data: Dict) -> Dict:
|
async def handle_get_matching_state_api_request(self, data: Dict) -> Dict:
|
||||||
polling_interval = 1
|
polling_interval = 1
|
||||||
# get the current active room
|
# get the current active room
|
||||||
matching_room = self.data.item.get_matching(self.version, data["roomId"])
|
matching_room = await self.data.item.get_matching(self.version, data["roomId"])
|
||||||
members = matching_room["matchingMemberInfoList"]
|
members = matching_room["matchingMemberInfoList"]
|
||||||
rest_sec = matching_room["restMSec"]
|
rest_sec = matching_room["restMSec"]
|
||||||
|
|
||||||
@@ -638,7 +638,7 @@ class ChuniNew(ChuniBase):
|
|||||||
current_member["userName"] = self.read_wtf8(current_member["userName"])
|
current_member["userName"] = self.read_wtf8(current_member["userName"])
|
||||||
members[i] = current_member
|
members[i] = current_member
|
||||||
|
|
||||||
self.data.item.put_matching(
|
await self.data.item.put_matching(
|
||||||
self.version,
|
self.version,
|
||||||
data["roomId"],
|
data["roomId"],
|
||||||
members,
|
members,
|
||||||
|
|||||||
+17
-17
@@ -28,7 +28,7 @@ class ChuniReader(BaseReader):
|
|||||||
self.logger.error(f"Invalid chunithm version {version}")
|
self.logger.error(f"Invalid chunithm version {version}")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def read(self) -> None:
|
async def read(self) -> None:
|
||||||
data_dirs = []
|
data_dirs = []
|
||||||
if self.bin_dir is not None:
|
if self.bin_dir is not None:
|
||||||
data_dirs += self.get_data_directories(self.bin_dir)
|
data_dirs += self.get_data_directories(self.bin_dir)
|
||||||
@@ -38,13 +38,13 @@ class ChuniReader(BaseReader):
|
|||||||
|
|
||||||
for dir in data_dirs:
|
for dir in data_dirs:
|
||||||
self.logger.info(f"Read from {dir}")
|
self.logger.info(f"Read from {dir}")
|
||||||
self.read_events(f"{dir}/event")
|
await self.read_events(f"{dir}/event")
|
||||||
self.read_music(f"{dir}/music")
|
await self.read_music(f"{dir}/music")
|
||||||
self.read_charges(f"{dir}/chargeItem")
|
await self.read_charges(f"{dir}/chargeItem")
|
||||||
self.read_avatar(f"{dir}/avatarAccessory")
|
await self.read_avatar(f"{dir}/avatarAccessory")
|
||||||
self.read_login_bonus(f"{dir}/")
|
await self.read_login_bonus(f"{dir}/")
|
||||||
|
|
||||||
def read_login_bonus(self, root_dir: str) -> None:
|
async def read_login_bonus(self, root_dir: str) -> None:
|
||||||
for root, dirs, files in walk(f"{root_dir}loginBonusPreset"):
|
for root, dirs, files in walk(f"{root_dir}loginBonusPreset"):
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
if path.exists(f"{root}/{dir}/LoginBonusPreset.xml"):
|
if path.exists(f"{root}/{dir}/LoginBonusPreset.xml"):
|
||||||
@@ -60,7 +60,7 @@ class ChuniReader(BaseReader):
|
|||||||
True if xml_root.find("disableFlag").text == "false" else False
|
True if xml_root.find("disableFlag").text == "false" else False
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.data.static.put_login_bonus_preset(
|
result = await self.data.static.put_login_bonus_preset(
|
||||||
self.version, id, name, is_enabled
|
self.version, id, name, is_enabled
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ class ChuniReader(BaseReader):
|
|||||||
bonus_root.find("loginBonusCategoryType").text
|
bonus_root.find("loginBonusCategoryType").text
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.data.static.put_login_bonus(
|
result = await self.data.static.put_login_bonus(
|
||||||
self.version,
|
self.version,
|
||||||
id,
|
id,
|
||||||
bonus_id,
|
bonus_id,
|
||||||
@@ -117,7 +117,7 @@ class ChuniReader(BaseReader):
|
|||||||
f"Failed to insert login bonus {bonus_id}"
|
f"Failed to insert login bonus {bonus_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def read_events(self, evt_dir: str) -> None:
|
async def read_events(self, evt_dir: str) -> None:
|
||||||
for root, dirs, files in walk(evt_dir):
|
for root, dirs, files in walk(evt_dir):
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
if path.exists(f"{root}/{dir}/Event.xml"):
|
if path.exists(f"{root}/{dir}/Event.xml"):
|
||||||
@@ -132,7 +132,7 @@ class ChuniReader(BaseReader):
|
|||||||
for substances in xml_root.findall("substances"):
|
for substances in xml_root.findall("substances"):
|
||||||
event_type = substances.find("type").text
|
event_type = substances.find("type").text
|
||||||
|
|
||||||
result = self.data.static.put_event(
|
result = await self.data.static.put_event(
|
||||||
self.version, id, event_type, name
|
self.version, id, event_type, name
|
||||||
)
|
)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
@@ -140,7 +140,7 @@ class ChuniReader(BaseReader):
|
|||||||
else:
|
else:
|
||||||
self.logger.warning(f"Failed to insert event {id}")
|
self.logger.warning(f"Failed to insert event {id}")
|
||||||
|
|
||||||
def read_music(self, music_dir: str) -> None:
|
async def read_music(self, music_dir: str) -> None:
|
||||||
for root, dirs, files in walk(music_dir):
|
for root, dirs, files in walk(music_dir):
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
if path.exists(f"{root}/{dir}/Music.xml"):
|
if path.exists(f"{root}/{dir}/Music.xml"):
|
||||||
@@ -185,7 +185,7 @@ class ChuniReader(BaseReader):
|
|||||||
)
|
)
|
||||||
we_chara = None
|
we_chara = None
|
||||||
|
|
||||||
result = self.data.static.put_music(
|
result = await self.data.static.put_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
chart_id,
|
chart_id,
|
||||||
@@ -206,7 +206,7 @@ class ChuniReader(BaseReader):
|
|||||||
f"Failed to insert music {song_id} chart {chart_id}"
|
f"Failed to insert music {song_id} chart {chart_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def read_charges(self, charge_dir: str) -> None:
|
async def read_charges(self, charge_dir: str) -> None:
|
||||||
for root, dirs, files in walk(charge_dir):
|
for root, dirs, files in walk(charge_dir):
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
if path.exists(f"{root}/{dir}/ChargeItem.xml"):
|
if path.exists(f"{root}/{dir}/ChargeItem.xml"):
|
||||||
@@ -222,7 +222,7 @@ class ChuniReader(BaseReader):
|
|||||||
consumeType = xml_root.find("consumeType").text
|
consumeType = xml_root.find("consumeType").text
|
||||||
sellingAppeal = bool(xml_root.find("sellingAppeal").text)
|
sellingAppeal = bool(xml_root.find("sellingAppeal").text)
|
||||||
|
|
||||||
result = self.data.static.put_charge(
|
result = await self.data.static.put_charge(
|
||||||
self.version,
|
self.version,
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
@@ -236,7 +236,7 @@ class ChuniReader(BaseReader):
|
|||||||
else:
|
else:
|
||||||
self.logger.warning(f"Failed to insert charge {id}")
|
self.logger.warning(f"Failed to insert charge {id}")
|
||||||
|
|
||||||
def read_avatar(self, avatar_dir: str) -> None:
|
async def read_avatar(self, avatar_dir: str) -> None:
|
||||||
for root, dirs, files in walk(avatar_dir):
|
for root, dirs, files in walk(avatar_dir):
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
if path.exists(f"{root}/{dir}/AvatarAccessory.xml"):
|
if path.exists(f"{root}/{dir}/AvatarAccessory.xml"):
|
||||||
@@ -254,7 +254,7 @@ class ChuniReader(BaseReader):
|
|||||||
for texture in xml_root.findall("texture"):
|
for texture in xml_root.findall("texture"):
|
||||||
texturePath = texture.find("path").text
|
texturePath = texture.find("path").text
|
||||||
|
|
||||||
result = self.data.static.put_avatar(
|
result = await self.data.static.put_avatar(
|
||||||
self.version, id, name, category, iconPath, texturePath
|
self.version, id, name, category, iconPath, texturePath
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+54
-54
@@ -245,7 +245,7 @@ matching = Table(
|
|||||||
|
|
||||||
|
|
||||||
class ChuniItemData(BaseData):
|
class ChuniItemData(BaseData):
|
||||||
def get_oldest_free_matching(self, version: int) -> Optional[Row]:
|
async def get_oldest_free_matching(self, version: int) -> Optional[Row]:
|
||||||
sql = matching.select(
|
sql = matching.select(
|
||||||
and_(
|
and_(
|
||||||
matching.c.version == version,
|
matching.c.version == version,
|
||||||
@@ -253,46 +253,46 @@ class ChuniItemData(BaseData):
|
|||||||
)
|
)
|
||||||
).order_by(matching.c.roomId.asc())
|
).order_by(matching.c.roomId.asc())
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_newest_matching(self, version: int) -> Optional[Row]:
|
async def get_newest_matching(self, version: int) -> Optional[Row]:
|
||||||
sql = matching.select(
|
sql = matching.select(
|
||||||
and_(
|
and_(
|
||||||
matching.c.version == version
|
matching.c.version == version
|
||||||
)
|
)
|
||||||
).order_by(matching.c.roomId.desc())
|
).order_by(matching.c.roomId.desc())
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_all_matchings(self, version: int) -> Optional[List[Row]]:
|
async def get_all_matchings(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = matching.select(
|
sql = matching.select(
|
||||||
and_(
|
and_(
|
||||||
matching.c.version == version
|
matching.c.version == version
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_matching(self, version: int, room_id: int) -> Optional[Row]:
|
async def get_matching(self, version: int, room_id: int) -> Optional[Row]:
|
||||||
sql = matching.select(
|
sql = matching.select(
|
||||||
and_(matching.c.version == version, matching.c.roomId == room_id)
|
and_(matching.c.version == version, matching.c.roomId == room_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_matching(
|
async def put_matching(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
room_id: int,
|
room_id: int,
|
||||||
@@ -314,22 +314,22 @@ class ChuniItemData(BaseData):
|
|||||||
restMSec=rest_sec, matchingMemberInfoList=matching_member_info_list
|
restMSec=rest_sec, matchingMemberInfoList=matching_member_info_list
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def delete_matching(self, version: int, room_id: int):
|
async def delete_matching(self, version: int, room_id: int):
|
||||||
sql = delete(matching).where(
|
sql = delete(matching).where(
|
||||||
and_(matching.c.roomId == room_id, matching.c.version == version)
|
and_(matching.c.roomId == room_id, matching.c.version == version)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_all_favorites(
|
async def get_all_favorites(
|
||||||
self, user_id: int, version: int, fav_kind: int = 1
|
self, user_id: int, version: int, fav_kind: int = 1
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = favorite.select(
|
sql = favorite.select(
|
||||||
@@ -340,12 +340,12 @@ class ChuniItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_login_bonus(
|
async def put_login_bonus(
|
||||||
self, user_id: int, version: int, preset_id: int, **login_bonus_data
|
self, user_id: int, version: int, preset_id: int, **login_bonus_data
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(login_bonus).values(
|
sql = insert(login_bonus).values(
|
||||||
@@ -354,12 +354,12 @@ class ChuniItemData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(presetId=preset_id, **login_bonus_data)
|
conflict = sql.on_duplicate_key_update(presetId=preset_id, **login_bonus_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_all_login_bonus(
|
async def get_all_login_bonus(
|
||||||
self, user_id: int, version: int, is_finished: bool = False
|
self, user_id: int, version: int, is_finished: bool = False
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = login_bonus.select(
|
sql = login_bonus.select(
|
||||||
@@ -370,12 +370,12 @@ class ChuniItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_login_bonus(
|
async def get_login_bonus(
|
||||||
self, user_id: int, version: int, preset_id: int
|
self, user_id: int, version: int, preset_id: int
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
sql = login_bonus.select(
|
sql = login_bonus.select(
|
||||||
@@ -386,12 +386,12 @@ class ChuniItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_character(self, user_id: int, character_data: Dict) -> Optional[int]:
|
async def put_character(self, user_id: int, character_data: Dict) -> Optional[int]:
|
||||||
character_data["user"] = user_id
|
character_data["user"] = user_id
|
||||||
|
|
||||||
character_data = self.fix_bools(character_data)
|
character_data = self.fix_bools(character_data)
|
||||||
@@ -399,30 +399,30 @@ class ChuniItemData(BaseData):
|
|||||||
sql = insert(character).values(**character_data)
|
sql = insert(character).values(**character_data)
|
||||||
conflict = sql.on_duplicate_key_update(**character_data)
|
conflict = sql.on_duplicate_key_update(**character_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_character(self, user_id: int, character_id: int) -> Optional[Dict]:
|
async def get_character(self, user_id: int, character_id: int) -> Optional[Dict]:
|
||||||
sql = select(character).where(
|
sql = select(character).where(
|
||||||
and_(character.c.user == user_id, character.c.characterId == character_id)
|
and_(character.c.user == user_id, character.c.characterId == character_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_characters(self, user_id: int) -> Optional[List[Row]]:
|
async def get_characters(self, user_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(character).where(character.c.user == user_id)
|
sql = select(character).where(character.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_item(self, user_id: int, item_data: Dict) -> Optional[int]:
|
async def put_item(self, user_id: int, item_data: Dict) -> Optional[int]:
|
||||||
item_data["user"] = user_id
|
item_data["user"] = user_id
|
||||||
|
|
||||||
item_data = self.fix_bools(item_data)
|
item_data = self.fix_bools(item_data)
|
||||||
@@ -430,12 +430,12 @@ class ChuniItemData(BaseData):
|
|||||||
sql = insert(item).values(**item_data)
|
sql = insert(item).values(**item_data)
|
||||||
conflict = sql.on_duplicate_key_update(**item_data)
|
conflict = sql.on_duplicate_key_update(**item_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_items(self, user_id: int, kind: int = None) -> Optional[List[Row]]:
|
async def get_items(self, user_id: int, kind: int = None) -> Optional[List[Row]]:
|
||||||
if kind is None:
|
if kind is None:
|
||||||
sql = select(item).where(item.c.user == user_id)
|
sql = select(item).where(item.c.user == user_id)
|
||||||
else:
|
else:
|
||||||
@@ -443,12 +443,12 @@ class ChuniItemData(BaseData):
|
|||||||
and_(item.c.user == user_id, item.c.itemKind == kind)
|
and_(item.c.user == user_id, item.c.itemKind == kind)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_duel(self, user_id: int, duel_data: Dict) -> Optional[int]:
|
async def put_duel(self, user_id: int, duel_data: Dict) -> Optional[int]:
|
||||||
duel_data["user"] = user_id
|
duel_data["user"] = user_id
|
||||||
|
|
||||||
duel_data = self.fix_bools(duel_data)
|
duel_data = self.fix_bools(duel_data)
|
||||||
@@ -456,20 +456,20 @@ class ChuniItemData(BaseData):
|
|||||||
sql = insert(duel).values(**duel_data)
|
sql = insert(duel).values(**duel_data)
|
||||||
conflict = sql.on_duplicate_key_update(**duel_data)
|
conflict = sql.on_duplicate_key_update(**duel_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_duels(self, user_id: int) -> Optional[List[Row]]:
|
async def get_duels(self, user_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(duel).where(duel.c.user == user_id)
|
sql = select(duel).where(duel.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_map(self, user_id: int, map_data: Dict) -> Optional[int]:
|
async def put_map(self, user_id: int, map_data: Dict) -> Optional[int]:
|
||||||
map_data["user"] = user_id
|
map_data["user"] = user_id
|
||||||
|
|
||||||
map_data = self.fix_bools(map_data)
|
map_data = self.fix_bools(map_data)
|
||||||
@@ -477,20 +477,20 @@ class ChuniItemData(BaseData):
|
|||||||
sql = insert(map).values(**map_data)
|
sql = insert(map).values(**map_data)
|
||||||
conflict = sql.on_duplicate_key_update(**map_data)
|
conflict = sql.on_duplicate_key_update(**map_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_maps(self, user_id: int) -> Optional[List[Row]]:
|
async def get_maps(self, user_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(map).where(map.c.user == user_id)
|
sql = select(map).where(map.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_map_area(self, user_id: int, map_area_data: Dict) -> Optional[int]:
|
async def put_map_area(self, user_id: int, map_area_data: Dict) -> Optional[int]:
|
||||||
map_area_data["user"] = user_id
|
map_area_data["user"] = user_id
|
||||||
|
|
||||||
map_area_data = self.fix_bools(map_area_data)
|
map_area_data = self.fix_bools(map_area_data)
|
||||||
@@ -498,28 +498,28 @@ class ChuniItemData(BaseData):
|
|||||||
sql = insert(map_area).values(**map_area_data)
|
sql = insert(map_area).values(**map_area_data)
|
||||||
conflict = sql.on_duplicate_key_update(**map_area_data)
|
conflict = sql.on_duplicate_key_update(**map_area_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_map_areas(self, user_id: int) -> Optional[List[Row]]:
|
async def get_map_areas(self, user_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(map_area).where(map_area.c.user == user_id)
|
sql = select(map_area).where(map_area.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
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)
|
sql = gacha.select(gacha.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_user_gacha(
|
async def put_user_gacha(
|
||||||
self, aime_id: int, gacha_id: int, gacha_data: Dict
|
self, aime_id: int, gacha_id: int, gacha_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(gacha).values(user=aime_id, gachaId=gacha_id, **gacha_data)
|
sql = insert(gacha).values(user=aime_id, gachaId=gacha_id, **gacha_data)
|
||||||
@@ -527,14 +527,14 @@ class ChuniItemData(BaseData):
|
|||||||
conflict = sql.on_duplicate_key_update(
|
conflict = sql.on_duplicate_key_update(
|
||||||
user=aime_id, gachaId=gacha_id, **gacha_data
|
user=aime_id, gachaId=gacha_id, **gacha_data
|
||||||
)
|
)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"put_user_gacha: Failed to insert! aime_id: {aime_id}")
|
self.logger.warning(f"put_user_gacha: Failed to insert! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_user_print_states(
|
async def get_user_print_states(
|
||||||
self, aime_id: int, has_completed: bool = False
|
self, aime_id: int, has_completed: bool = False
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = print_state.select(
|
sql = print_state.select(
|
||||||
@@ -544,12 +544,12 @@ class ChuniItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_user_print_states_by_gacha(
|
async def get_user_print_states_by_gacha(
|
||||||
self, aime_id: int, gacha_id: int, has_completed: bool = False
|
self, aime_id: int, gacha_id: int, has_completed: bool = False
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = print_state.select(
|
sql = print_state.select(
|
||||||
@@ -560,16 +560,16 @@ class ChuniItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_user_print_state(self, aime_id: int, **print_data) -> Optional[int]:
|
async def put_user_print_state(self, aime_id: int, **print_data) -> Optional[int]:
|
||||||
sql = insert(print_state).values(user=aime_id, **print_data)
|
sql = insert(print_state).values(user=aime_id, **print_data)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(user=aime_id, **print_data)
|
conflict = sql.on_duplicate_key_update(user=aime_id, **print_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
@@ -578,7 +578,7 @@ class ChuniItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
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
|
self, aime_id: int, serial_id: str, user_print_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(print_detail).values(
|
sql = insert(print_detail).values(
|
||||||
@@ -586,7 +586,7 @@ class ChuniItemData(BaseData):
|
|||||||
)
|
)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(user=aime_id, **user_print_data)
|
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:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ team = Table(
|
|||||||
|
|
||||||
|
|
||||||
class ChuniProfileData(BaseData):
|
class ChuniProfileData(BaseData):
|
||||||
def put_profile_data(
|
async def put_profile_data(
|
||||||
self, aime_id: int, version: int, profile_data: Dict
|
self, aime_id: int, version: int, profile_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
profile_data["user"] = aime_id
|
profile_data["user"] = aime_id
|
||||||
@@ -407,26 +407,26 @@ class ChuniProfileData(BaseData):
|
|||||||
|
|
||||||
sql = insert(profile).values(**profile_data)
|
sql = insert(profile).values(**profile_data)
|
||||||
conflict = sql.on_duplicate_key_update(**profile_data)
|
conflict = sql.on_duplicate_key_update(**profile_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"put_profile_data: Failed to update! aime_id: {aime_id}")
|
self.logger.warning(f"put_profile_data: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
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 = (
|
sql = (
|
||||||
select([profile, option])
|
select([profile, option])
|
||||||
.join(option, profile.c.user == option.c.user)
|
.join(option, profile.c.user == option.c.user)
|
||||||
.filter(and_(profile.c.user == aime_id, profile.c.version <= version))
|
.filter(and_(profile.c.user == aime_id, profile.c.version <= version))
|
||||||
).order_by(profile.c.version.desc())
|
).order_by(profile.c.version.desc())
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
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(
|
sql = select(profile).where(
|
||||||
and_(
|
and_(
|
||||||
profile.c.user == aime_id,
|
profile.c.user == aime_id,
|
||||||
@@ -434,12 +434,12 @@ class ChuniProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
).order_by(profile.c.version.desc())
|
).order_by(profile.c.version.desc())
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_profile_data_ex(
|
async def put_profile_data_ex(
|
||||||
self, aime_id: int, version: int, profile_ex_data: Dict
|
self, aime_id: int, version: int, profile_ex_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
profile_ex_data["user"] = aime_id
|
profile_ex_data["user"] = aime_id
|
||||||
@@ -449,7 +449,7 @@ class ChuniProfileData(BaseData):
|
|||||||
|
|
||||||
sql = insert(profile_ex).values(**profile_ex_data)
|
sql = insert(profile_ex).values(**profile_ex_data)
|
||||||
conflict = sql.on_duplicate_key_update(**profile_ex_data)
|
conflict = sql.on_duplicate_key_update(**profile_ex_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
@@ -458,7 +458,7 @@ class ChuniProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_data_ex(self, aime_id: int, version: int) -> Optional[Row]:
|
async def get_profile_data_ex(self, aime_id: int, version: int) -> Optional[Row]:
|
||||||
sql = select(profile_ex).where(
|
sql = select(profile_ex).where(
|
||||||
and_(
|
and_(
|
||||||
profile_ex.c.user == aime_id,
|
profile_ex.c.user == aime_id,
|
||||||
@@ -466,17 +466,17 @@ class ChuniProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
).order_by(profile_ex.c.version.desc())
|
).order_by(profile_ex.c.version.desc())
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_profile_option(self, aime_id: int, option_data: Dict) -> Optional[int]:
|
async def put_profile_option(self, aime_id: int, option_data: Dict) -> Optional[int]:
|
||||||
option_data["user"] = aime_id
|
option_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(option).values(**option_data)
|
sql = insert(option).values(**option_data)
|
||||||
conflict = sql.on_duplicate_key_update(**option_data)
|
conflict = sql.on_duplicate_key_update(**option_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
@@ -485,22 +485,22 @@ class ChuniProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_option(self, aime_id: int) -> Optional[Row]:
|
async def get_profile_option(self, aime_id: int) -> Optional[Row]:
|
||||||
sql = select(option).where(option.c.user == aime_id)
|
sql = select(option).where(option.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_profile_option_ex(
|
async def put_profile_option_ex(
|
||||||
self, aime_id: int, option_ex_data: Dict
|
self, aime_id: int, option_ex_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
option_ex_data["user"] = aime_id
|
option_ex_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(option_ex).values(**option_ex_data)
|
sql = insert(option_ex).values(**option_ex_data)
|
||||||
conflict = sql.on_duplicate_key_update(**option_ex_data)
|
conflict = sql.on_duplicate_key_update(**option_ex_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
@@ -509,15 +509,15 @@ class ChuniProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_option_ex(self, aime_id: int) -> Optional[Row]:
|
async def get_profile_option_ex(self, aime_id: int) -> Optional[Row]:
|
||||||
sql = select(option_ex).where(option_ex.c.user == aime_id)
|
sql = select(option_ex).where(option_ex.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_profile_recent_rating(
|
async def put_profile_recent_rating(
|
||||||
self, aime_id: int, recent_rating_data: List[Dict]
|
self, aime_id: int, recent_rating_data: List[Dict]
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(recent_rating).values(
|
sql = insert(recent_rating).values(
|
||||||
@@ -525,7 +525,7 @@ class ChuniProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
conflict = sql.on_duplicate_key_update(recentRating=recent_rating_data)
|
conflict = sql.on_duplicate_key_update(recentRating=recent_rating_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_profile_recent_rating: Failed to update! aime_id: {aime_id}"
|
f"put_profile_recent_rating: Failed to update! aime_id: {aime_id}"
|
||||||
@@ -533,15 +533,15 @@ class ChuniProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_recent_rating(self, aime_id: int) -> Optional[Row]:
|
async def get_profile_recent_rating(self, aime_id: int) -> Optional[Row]:
|
||||||
sql = select(recent_rating).where(recent_rating.c.user == aime_id)
|
sql = select(recent_rating).where(recent_rating.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_profile_activity(self, aime_id: int, activity_data: Dict) -> Optional[int]:
|
async def put_profile_activity(self, aime_id: int, activity_data: Dict) -> Optional[int]:
|
||||||
# The game just uses "id" but we need to distinguish that from the db column "id"
|
# The game just uses "id" but we need to distinguish that from the db column "id"
|
||||||
activity_data["user"] = aime_id
|
activity_data["user"] = aime_id
|
||||||
activity_data["activityId"] = activity_data["id"]
|
activity_data["activityId"] = activity_data["id"]
|
||||||
@@ -549,7 +549,7 @@ class ChuniProfileData(BaseData):
|
|||||||
|
|
||||||
sql = insert(activity).values(**activity_data)
|
sql = insert(activity).values(**activity_data)
|
||||||
conflict = sql.on_duplicate_key_update(**activity_data)
|
conflict = sql.on_duplicate_key_update(**activity_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
@@ -558,24 +558,24 @@ class ChuniProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_activity(self, aime_id: int, kind: int) -> Optional[List[Row]]:
|
async def get_profile_activity(self, aime_id: int, kind: int) -> Optional[List[Row]]:
|
||||||
sql = (
|
sql = (
|
||||||
select(activity)
|
select(activity)
|
||||||
.where(and_(activity.c.user == aime_id, activity.c.kind == kind))
|
.where(and_(activity.c.user == aime_id, activity.c.kind == kind))
|
||||||
.order_by(activity.c.sortNumber.desc()) # to get the last played track
|
.order_by(activity.c.sortNumber.desc()) # to get the last played track
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_profile_charge(self, aime_id: int, charge_data: Dict) -> Optional[int]:
|
async def put_profile_charge(self, aime_id: int, charge_data: Dict) -> Optional[int]:
|
||||||
charge_data["user"] = aime_id
|
charge_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(charge).values(**charge_data)
|
sql = insert(charge).values(**charge_data)
|
||||||
conflict = sql.on_duplicate_key_update(**charge_data)
|
conflict = sql.on_duplicate_key_update(**charge_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
@@ -584,40 +584,40 @@ class ChuniProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_charge(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_profile_charge(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(charge).where(charge.c.user == aime_id)
|
sql = select(charge).where(charge.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def add_profile_region(self, aime_id: int, region_id: int) -> Optional[int]:
|
async def add_profile_region(self, aime_id: int, region_id: int) -> Optional[int]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_profile_regions(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_profile_regions(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def put_profile_emoney(self, aime_id: int, emoney_data: Dict) -> Optional[int]:
|
async def put_profile_emoney(self, aime_id: int, emoney_data: Dict) -> Optional[int]:
|
||||||
emoney_data["user"] = aime_id
|
emoney_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(emoney).values(**emoney_data)
|
sql = insert(emoney).values(**emoney_data)
|
||||||
conflict = sql.on_duplicate_key_update(**emoney_data)
|
conflict = sql.on_duplicate_key_update(**emoney_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_emoney(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_profile_emoney(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(emoney).where(emoney.c.user == aime_id)
|
sql = select(emoney).where(emoney.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_profile_overpower(
|
async def put_profile_overpower(
|
||||||
self, aime_id: int, overpower_data: Dict
|
self, aime_id: int, overpower_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
overpower_data["user"] = aime_id
|
overpower_data["user"] = aime_id
|
||||||
@@ -625,31 +625,31 @@ class ChuniProfileData(BaseData):
|
|||||||
sql = insert(overpower).values(**overpower_data)
|
sql = insert(overpower).values(**overpower_data)
|
||||||
conflict = sql.on_duplicate_key_update(**overpower_data)
|
conflict = sql.on_duplicate_key_update(**overpower_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_overpower(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_profile_overpower(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(overpower).where(overpower.c.user == aime_id)
|
sql = select(overpower).where(overpower.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_team_by_id(self, team_id: int) -> Optional[Row]:
|
async def get_team_by_id(self, team_id: int) -> Optional[Row]:
|
||||||
sql = select(team).where(team.c.id == team_id)
|
sql = select(team).where(team.c.id == team_id)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_team_rank(self, team_id: int) -> int:
|
async def get_team_rank(self, team_id: int) -> int:
|
||||||
# Normal ranking system, likely the one used in the real servers
|
# Normal ranking system, likely the one used in the real servers
|
||||||
# Query all teams sorted by 'teamPoint'
|
# Query all teams sorted by 'teamPoint'
|
||||||
result = self.execute(
|
result = await self.execute(
|
||||||
select(team.c.id).order_by(team.c.teamPoint.desc())
|
select(team.c.id).order_by(team.c.teamPoint.desc())
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -666,13 +666,13 @@ class ChuniProfileData(BaseData):
|
|||||||
# RIP scaled team ranking. Gone, but forgotten
|
# RIP scaled team ranking. Gone, but forgotten
|
||||||
# def get_team_rank_scaled(self, team_id: int) -> int:
|
# def get_team_rank_scaled(self, team_id: int) -> int:
|
||||||
|
|
||||||
def update_team(self, team_id: int, team_data: Dict) -> bool:
|
async def update_team(self, team_id: int, team_data: Dict) -> bool:
|
||||||
team_data["id"] = team_id
|
team_data["id"] = team_id
|
||||||
|
|
||||||
sql = insert(team).values(**team_data)
|
sql = insert(team).values(**team_data)
|
||||||
conflict = sql.on_duplicate_key_update(**team_data)
|
conflict = sql.on_duplicate_key_update(**team_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
@@ -680,16 +680,16 @@ class ChuniProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
def get_rival(self, rival_id: int) -> Optional[Row]:
|
async def get_rival(self, rival_id: int) -> Optional[Row]:
|
||||||
sql = select(profile).where(profile.c.user == rival_id)
|
sql = select(profile).where(profile.c.user == rival_id)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
def get_overview(self) -> Dict:
|
async def get_overview(self) -> Dict:
|
||||||
# Fetch and add up all the playcounts
|
# Fetch and add up all the playcounts
|
||||||
playcount_sql = self.execute(select(profile.c.playCount))
|
playcount_sql = await self.execute(select(profile.c.playCount))
|
||||||
|
|
||||||
if playcount_sql is None:
|
if playcount_sql is None:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
|
|||||||
@@ -142,55 +142,55 @@ playlog = Table(
|
|||||||
|
|
||||||
|
|
||||||
class ChuniScoreData(BaseData):
|
class ChuniScoreData(BaseData):
|
||||||
def get_courses(self, aime_id: int) -> Optional[Row]:
|
async def get_courses(self, aime_id: int) -> Optional[Row]:
|
||||||
sql = select(course).where(course.c.user == aime_id)
|
sql = select(course).where(course.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_course(self, aime_id: int, course_data: Dict) -> Optional[int]:
|
async def put_course(self, aime_id: int, course_data: Dict) -> Optional[int]:
|
||||||
course_data["user"] = aime_id
|
course_data["user"] = aime_id
|
||||||
course_data = self.fix_bools(course_data)
|
course_data = self.fix_bools(course_data)
|
||||||
|
|
||||||
sql = insert(course).values(**course_data)
|
sql = insert(course).values(**course_data)
|
||||||
conflict = sql.on_duplicate_key_update(**course_data)
|
conflict = sql.on_duplicate_key_update(**course_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_scores(self, aime_id: int) -> Optional[Row]:
|
async def get_scores(self, aime_id: int) -> Optional[Row]:
|
||||||
sql = select(best_score).where(best_score.c.user == aime_id)
|
sql = select(best_score).where(best_score.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_score(self, aime_id: int, score_data: Dict) -> Optional[int]:
|
async def put_score(self, aime_id: int, score_data: Dict) -> Optional[int]:
|
||||||
score_data["user"] = aime_id
|
score_data["user"] = aime_id
|
||||||
score_data = self.fix_bools(score_data)
|
score_data = self.fix_bools(score_data)
|
||||||
|
|
||||||
sql = insert(best_score).values(**score_data)
|
sql = insert(best_score).values(**score_data)
|
||||||
conflict = sql.on_duplicate_key_update(**score_data)
|
conflict = sql.on_duplicate_key_update(**score_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_playlogs(self, aime_id: int) -> Optional[Row]:
|
async def get_playlogs(self, aime_id: int) -> Optional[Row]:
|
||||||
sql = select(playlog).where(playlog.c.user == aime_id)
|
sql = select(playlog).where(playlog.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_playlog(self, aime_id: int, playlog_data: Dict, version: int) -> Optional[int]:
|
async def put_playlog(self, aime_id: int, playlog_data: Dict, version: int) -> Optional[int]:
|
||||||
# Calculate the ROM version that should be inserted into the DB, based on the version of the ggame being inserted
|
# Calculate the ROM version that should be inserted into the DB, based on the version of the ggame being inserted
|
||||||
# We only need from Version 10 (Plost) and back, as newer versions include romVersion in their upsert
|
# We only need from Version 10 (Plost) and back, as newer versions include romVersion in their upsert
|
||||||
# This matters both for gameRankings, as well as a future DB update to keep version data separate
|
# This matters both for gameRankings, as well as a future DB update to keep version data separate
|
||||||
@@ -216,12 +216,12 @@ class ChuniScoreData(BaseData):
|
|||||||
sql = insert(playlog).values(**playlog_data)
|
sql = insert(playlog).values(**playlog_data)
|
||||||
conflict = sql.on_duplicate_key_update(**playlog_data)
|
conflict = sql.on_duplicate_key_update(**playlog_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_rankings(self, version: int) -> Optional[List[Dict]]:
|
async def get_rankings(self, version: int) -> Optional[List[Dict]]:
|
||||||
# Calculates the ROM version that should be fetched for rankings, based on the game version being retrieved
|
# Calculates the ROM version that should be fetched for rankings, based on the game version being retrieved
|
||||||
# This prevents tracks that are not accessible in your version from counting towards the 10 results
|
# This prevents tracks that are not accessible in your version from counting towards the 10 results
|
||||||
romVer = {
|
romVer = {
|
||||||
@@ -241,7 +241,7 @@ class ChuniScoreData(BaseData):
|
|||||||
0: "1.00%"
|
0: "1.00%"
|
||||||
}
|
}
|
||||||
sql = select([playlog.c.musicId.label('id'), func.count(playlog.c.musicId).label('point')]).where((playlog.c.level != 4) & (playlog.c.romVersion.like(romVer.get(version, "%")))).group_by(playlog.c.musicId).order_by(func.count(playlog.c.musicId).desc()).limit(10)
|
sql = select([playlog.c.musicId.label('id'), func.count(playlog.c.musicId).label('point')]).where((playlog.c.level != 4) & (playlog.c.romVersion.like(romVer.get(version, "%")))).group_by(playlog.c.musicId).order_by(func.count(playlog.c.musicId).desc()).limit(10)
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
@@ -249,10 +249,10 @@ class ChuniScoreData(BaseData):
|
|||||||
rows = result.fetchall()
|
rows = result.fetchall()
|
||||||
return [dict(row) for row in rows]
|
return [dict(row) for row in rows]
|
||||||
|
|
||||||
def get_rival_music(self, rival_id: int) -> Optional[List[Dict]]:
|
async def get_rival_music(self, rival_id: int) -> Optional[List[Dict]]:
|
||||||
sql = select(best_score).where(best_score.c.user == rival_id)
|
sql = select(best_score).where(best_score.c.user == rival_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ login_bonus = Table(
|
|||||||
|
|
||||||
|
|
||||||
class ChuniStaticData(BaseData):
|
class ChuniStaticData(BaseData):
|
||||||
def put_login_bonus(
|
async def put_login_bonus(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
preset_id: int,
|
preset_id: int,
|
||||||
@@ -207,12 +207,12 @@ class ChuniStaticData(BaseData):
|
|||||||
loginBonusCategoryType=login_bonus_category_type,
|
loginBonusCategoryType=login_bonus_category_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_login_bonus(
|
async def get_login_bonus(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
preset_id: int,
|
preset_id: int,
|
||||||
@@ -224,12 +224,12 @@ class ChuniStaticData(BaseData):
|
|||||||
)
|
)
|
||||||
).order_by(login_bonus.c.needLoginDayCount.desc())
|
).order_by(login_bonus.c.needLoginDayCount.desc())
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_login_bonus_by_required_days(
|
async def get_login_bonus_by_required_days(
|
||||||
self, version: int, preset_id: int, need_login_day_count: int
|
self, version: int, preset_id: int, need_login_day_count: int
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
sql = login_bonus.select(
|
sql = login_bonus.select(
|
||||||
@@ -240,12 +240,12 @@ class ChuniStaticData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_login_bonus_preset(
|
async def put_login_bonus_preset(
|
||||||
self, version: int, preset_id: int, preset_name: str, is_enabled: bool
|
self, version: int, preset_id: int, preset_name: str, is_enabled: bool
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(login_bonus_preset).values(
|
sql = insert(login_bonus_preset).values(
|
||||||
@@ -259,12 +259,12 @@ class ChuniStaticData(BaseData):
|
|||||||
presetName=preset_name, isEnabled=is_enabled
|
presetName=preset_name, isEnabled=is_enabled
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_login_bonus_presets(
|
async def get_login_bonus_presets(
|
||||||
self, version: int, is_enabled: bool = True
|
self, version: int, is_enabled: bool = True
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = login_bonus_preset.select(
|
sql = login_bonus_preset.select(
|
||||||
@@ -274,12 +274,12 @@ class ChuniStaticData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_event(
|
async def put_event(
|
||||||
self, version: int, event_id: int, type: int, name: str
|
self, version: int, event_id: int, type: int, name: str
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(events).values(
|
sql = insert(events).values(
|
||||||
@@ -288,19 +288,19 @@ class ChuniStaticData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(name=name)
|
conflict = sql.on_duplicate_key_update(name=name)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def update_event(
|
async def update_event(
|
||||||
self, version: int, event_id: int, enabled: bool
|
self, version: int, event_id: int, enabled: bool
|
||||||
) -> Optional[bool]:
|
) -> Optional[bool]:
|
||||||
sql = events.update(
|
sql = events.update(
|
||||||
and_(events.c.version == version, events.c.eventId == event_id)
|
and_(events.c.version == version, events.c.eventId == event_id)
|
||||||
).values(enabled=enabled)
|
).values(enabled=enabled)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"update_event: failed to update event! version: {version}, event_id: {event_id}, enabled: {enabled}"
|
f"update_event: failed to update event! version: {version}, event_id: {event_id}, enabled: {enabled}"
|
||||||
@@ -315,35 +315,35 @@ class ChuniStaticData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return event["enabled"]
|
return event["enabled"]
|
||||||
|
|
||||||
def get_event(self, version: int, event_id: int) -> Optional[Row]:
|
async def get_event(self, version: int, event_id: int) -> Optional[Row]:
|
||||||
sql = select(events).where(
|
sql = select(events).where(
|
||||||
and_(events.c.version == version, events.c.eventId == event_id)
|
and_(events.c.version == version, events.c.eventId == event_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_enabled_events(self, version: int) -> Optional[List[Row]]:
|
async def get_enabled_events(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = select(events).where(
|
sql = select(events).where(
|
||||||
and_(events.c.version == version, events.c.enabled == True)
|
and_(events.c.version == version, events.c.enabled == True)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_events(self, version: int) -> Optional[List[Row]]:
|
async def get_events(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = select(events).where(events.c.version == version)
|
sql = select(events).where(events.c.version == version)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_music(
|
async def put_music(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
song_id: int,
|
song_id: int,
|
||||||
@@ -376,12 +376,12 @@ class ChuniStaticData(BaseData):
|
|||||||
worldsEndTag=we_tag,
|
worldsEndTag=we_tag,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_charge(
|
async def put_charge(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
charge_id: int,
|
charge_id: int,
|
||||||
@@ -406,38 +406,38 @@ class ChuniStaticData(BaseData):
|
|||||||
sellingAppeal=selling_appeal,
|
sellingAppeal=selling_appeal,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_enabled_charges(self, version: int) -> Optional[List[Row]]:
|
async def get_enabled_charges(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = select(charge).where(
|
sql = select(charge).where(
|
||||||
and_(charge.c.version == version, charge.c.enabled == True)
|
and_(charge.c.version == version, charge.c.enabled == True)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_charges(self, version: int) -> Optional[List[Row]]:
|
async def get_charges(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = select(charge).where(charge.c.version == version)
|
sql = select(charge).where(charge.c.version == version)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_music(self, version: int) -> Optional[List[Row]]:
|
async def get_music(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = music.select(music.c.version <= version)
|
sql = music.select(music.c.version <= version)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_music_chart(
|
async def get_music_chart(
|
||||||
self, version: int, song_id: int, chart_id: int
|
self, version: int, song_id: int, chart_id: int
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = select(music).where(
|
sql = select(music).where(
|
||||||
@@ -448,21 +448,21 @@ class ChuniStaticData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_song(self, music_id: int) -> Optional[Row]:
|
async def get_song(self, music_id: int) -> Optional[Row]:
|
||||||
sql = music.select(music.c.id == music_id)
|
sql = music.select(music.c.id == music_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
|
|
||||||
def put_avatar(
|
async def put_avatar(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
avatarAccessoryId: int,
|
avatarAccessoryId: int,
|
||||||
@@ -487,12 +487,12 @@ class ChuniStaticData(BaseData):
|
|||||||
texturePath=texturePath,
|
texturePath=texturePath,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_gacha(
|
async def put_gacha(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
gacha_id: int,
|
gacha_id: int,
|
||||||
@@ -513,33 +513,33 @@ class ChuniStaticData(BaseData):
|
|||||||
**gacha_data,
|
**gacha_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"Failed to insert gacha! gacha_id {gacha_id}")
|
self.logger.warning(f"Failed to insert gacha! gacha_id {gacha_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
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(
|
sql = gachas.select(gachas.c.version <= version).order_by(
|
||||||
gachas.c.gachaId.asc()
|
gachas.c.gachaId.asc()
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
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(
|
sql = gachas.select(
|
||||||
and_(gachas.c.version <= version, gachas.c.gachaId == gacha_id)
|
and_(gachas.c.version <= version, gachas.c.gachaId == gacha_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_gacha_card(
|
async def put_gacha_card(
|
||||||
self, gacha_id: int, card_id: int, **gacha_card
|
self, gacha_id: int, card_id: int, **gacha_card
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(gacha_cards).values(gachaId=gacha_id, cardId=card_id, **gacha_card)
|
sql = insert(gacha_cards).values(gachaId=gacha_id, cardId=card_id, **gacha_card)
|
||||||
@@ -548,21 +548,21 @@ class ChuniStaticData(BaseData):
|
|||||||
gachaId=gacha_id, cardId=card_id, **gacha_card
|
gachaId=gacha_id, cardId=card_id, **gacha_card
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"Failed to insert gacha card! gacha_id {gacha_id}")
|
self.logger.warning(f"Failed to insert gacha card! gacha_id {gacha_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
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)
|
sql = gacha_cards.select(gacha_cards.c.gachaId == gacha_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_gacha_card_by_character(
|
async def get_gacha_card_by_character(
|
||||||
self, gacha_id: int, chara_id: int
|
self, gacha_id: int, chara_id: int
|
||||||
) -> Optional[Dict]:
|
) -> Optional[Dict]:
|
||||||
sql_sub = (
|
sql_sub = (
|
||||||
@@ -574,26 +574,26 @@ class ChuniStaticData(BaseData):
|
|||||||
and_(gacha_cards.c.gachaId == gacha_id, gacha_cards.c.cardId == sql_sub)
|
and_(gacha_cards.c.gachaId == gacha_id, gacha_cards.c.cardId == sql_sub)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
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)
|
sql = insert(cards).values(version=version, cardId=card_id, **card_data)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**card_data)
|
conflict = sql.on_duplicate_key_update(**card_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"Failed to insert card! card_id {card_id}")
|
self.logger.warning(f"Failed to insert card! card_id {card_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
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))
|
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:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
+20
-20
@@ -50,7 +50,7 @@ class CardMakerReader(BaseReader):
|
|||||||
):
|
):
|
||||||
return f"{root}/{dir}"
|
return f"{root}/{dir}"
|
||||||
|
|
||||||
def read(self) -> None:
|
async def read(self) -> None:
|
||||||
static_datas = {
|
static_datas = {
|
||||||
"static_gachas.csv": "read_ongeki_gacha_csv",
|
"static_gachas.csv": "read_ongeki_gacha_csv",
|
||||||
"static_gacha_cards.csv": "read_ongeki_gacha_card_csv",
|
"static_gacha_cards.csv": "read_ongeki_gacha_card_csv",
|
||||||
@@ -66,7 +66,7 @@ class CardMakerReader(BaseReader):
|
|||||||
for file, func in static_datas.items():
|
for file, func in static_datas.items():
|
||||||
if os.path.exists(f"{self.bin_dir}/MU3/{file}"):
|
if os.path.exists(f"{self.bin_dir}/MU3/{file}"):
|
||||||
read_csv = getattr(CardMakerReader, func)
|
read_csv = getattr(CardMakerReader, func)
|
||||||
read_csv(self, f"{self.bin_dir}/MU3/{file}")
|
await read_csv(self, f"{self.bin_dir}/MU3/{file}")
|
||||||
else:
|
else:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"Couldn't find {file} file in {self.bin_dir}, skipping"
|
f"Couldn't find {file} file in {self.bin_dir}, skipping"
|
||||||
@@ -78,12 +78,12 @@ class CardMakerReader(BaseReader):
|
|||||||
# ONGEKI (MU3) cnnot easily access the bin data(A000.pac)
|
# ONGEKI (MU3) cnnot easily access the bin data(A000.pac)
|
||||||
# so only opt_dir will work for now
|
# so only opt_dir will work for now
|
||||||
for dir in data_dirs:
|
for dir in data_dirs:
|
||||||
self.read_chuni_card(f"{dir}/CHU/card")
|
await self.read_chuni_card(f"{dir}/CHU/card")
|
||||||
self.read_chuni_gacha(f"{dir}/CHU/gacha")
|
await self.read_chuni_gacha(f"{dir}/CHU/gacha")
|
||||||
self.read_mai2_card(f"{dir}/MAI/card")
|
await self.read_mai2_card(f"{dir}/MAI/card")
|
||||||
self.read_ongeki_gacha(f"{dir}/MU3/gacha")
|
await self.read_ongeki_gacha(f"{dir}/MU3/gacha")
|
||||||
|
|
||||||
def read_chuni_card(self, base_dir: str) -> None:
|
async def read_chuni_card(self, base_dir: str) -> None:
|
||||||
self.logger.info(f"Reading cards from {base_dir}...")
|
self.logger.info(f"Reading cards from {base_dir}...")
|
||||||
|
|
||||||
version_ids = {
|
version_ids = {
|
||||||
@@ -114,7 +114,7 @@ class CardMakerReader(BaseReader):
|
|||||||
chain = int(troot.find("chain").text)
|
chain = int(troot.find("chain").text)
|
||||||
skill_name = troot.find("skillName").text
|
skill_name = troot.find("skillName").text
|
||||||
|
|
||||||
self.chuni_data.static.put_card(
|
await self.chuni_data.static.put_card(
|
||||||
version,
|
version,
|
||||||
card_id,
|
card_id,
|
||||||
charaName=chara_name,
|
charaName=chara_name,
|
||||||
@@ -131,7 +131,7 @@ class CardMakerReader(BaseReader):
|
|||||||
|
|
||||||
self.logger.info(f"Added chuni card {card_id}")
|
self.logger.info(f"Added chuni card {card_id}")
|
||||||
|
|
||||||
def read_chuni_gacha(self, base_dir: str) -> None:
|
async def read_chuni_gacha(self, base_dir: str) -> None:
|
||||||
self.logger.info(f"Reading gachas from {base_dir}...")
|
self.logger.info(f"Reading gachas from {base_dir}...")
|
||||||
|
|
||||||
version_ids = {
|
version_ids = {
|
||||||
@@ -158,7 +158,7 @@ class CardMakerReader(BaseReader):
|
|||||||
True if troot.find("ceilingType").text == "1" else False
|
True if troot.find("ceilingType").text == "1" else False
|
||||||
)
|
)
|
||||||
|
|
||||||
self.chuni_data.static.put_gacha(
|
await self.chuni_data.static.put_gacha(
|
||||||
version,
|
version,
|
||||||
gacha_id,
|
gacha_id,
|
||||||
name,
|
name,
|
||||||
@@ -181,7 +181,7 @@ class CardMakerReader(BaseReader):
|
|||||||
True if gacha_card.find("pickup").text == "1" else False
|
True if gacha_card.find("pickup").text == "1" else False
|
||||||
)
|
)
|
||||||
|
|
||||||
self.chuni_data.static.put_gacha_card(
|
await self.chuni_data.static.put_gacha_card(
|
||||||
gacha_id,
|
gacha_id,
|
||||||
card_id,
|
card_id,
|
||||||
weight=weight,
|
weight=weight,
|
||||||
@@ -193,7 +193,7 @@ class CardMakerReader(BaseReader):
|
|||||||
f"Added chuni card {card_id} to gacha {gacha_id}"
|
f"Added chuni card {card_id} to gacha {gacha_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def read_mai2_card(self, base_dir: str) -> None:
|
async def read_mai2_card(self, base_dir: str) -> None:
|
||||||
self.logger.info(f"Reading cards from {base_dir}...")
|
self.logger.info(f"Reading cards from {base_dir}...")
|
||||||
|
|
||||||
version_ids = {
|
version_ids = {
|
||||||
@@ -231,18 +231,18 @@ class CardMakerReader(BaseReader):
|
|||||||
False if re.search(r"\d{2}/\d{2}/\d{2}", name) else enabled
|
False if re.search(r"\d{2}/\d{2}/\d{2}", name) else enabled
|
||||||
)
|
)
|
||||||
|
|
||||||
self.mai2_data.static.put_card(
|
await self.mai2_data.static.put_card(
|
||||||
version, card_id, name, enabled=enabled
|
version, card_id, name, enabled=enabled
|
||||||
)
|
)
|
||||||
self.logger.info(f"Added mai2 card {card_id}")
|
self.logger.info(f"Added mai2 card {card_id}")
|
||||||
|
|
||||||
def read_ongeki_gacha_csv(self, file_path: str) -> None:
|
async def read_ongeki_gacha_csv(self, file_path: str) -> None:
|
||||||
self.logger.info(f"Reading gachas from {file_path}...")
|
self.logger.info(f"Reading gachas from {file_path}...")
|
||||||
|
|
||||||
with open(file_path, encoding="utf-8") as f:
|
with open(file_path, encoding="utf-8") as f:
|
||||||
reader = csv.DictReader(f)
|
reader = csv.DictReader(f)
|
||||||
for row in reader:
|
for row in reader:
|
||||||
self.ongeki_data.static.put_gacha(
|
await self.ongeki_data.static.put_gacha(
|
||||||
row["version"],
|
row["version"],
|
||||||
row["gachaId"],
|
row["gachaId"],
|
||||||
row["gachaName"],
|
row["gachaName"],
|
||||||
@@ -254,13 +254,13 @@ class CardMakerReader(BaseReader):
|
|||||||
|
|
||||||
self.logger.info(f"Added ongeki gacha {row['gachaId']}")
|
self.logger.info(f"Added ongeki gacha {row['gachaId']}")
|
||||||
|
|
||||||
def read_ongeki_gacha_card_csv(self, file_path: str) -> None:
|
async def read_ongeki_gacha_card_csv(self, file_path: str) -> None:
|
||||||
self.logger.info(f"Reading gacha cards from {file_path}...")
|
self.logger.info(f"Reading gacha cards from {file_path}...")
|
||||||
|
|
||||||
with open(file_path, encoding="utf-8") as f:
|
with open(file_path, encoding="utf-8") as f:
|
||||||
reader = csv.DictReader(f)
|
reader = csv.DictReader(f)
|
||||||
for row in reader:
|
for row in reader:
|
||||||
self.ongeki_data.static.put_gacha_card(
|
await self.ongeki_data.static.put_gacha_card(
|
||||||
row["gachaId"],
|
row["gachaId"],
|
||||||
row["cardId"],
|
row["cardId"],
|
||||||
rarity=row["rarity"],
|
rarity=row["rarity"],
|
||||||
@@ -271,7 +271,7 @@ class CardMakerReader(BaseReader):
|
|||||||
|
|
||||||
self.logger.info(f"Added ongeki card {row['cardId']} to gacha")
|
self.logger.info(f"Added ongeki card {row['cardId']} to gacha")
|
||||||
|
|
||||||
def read_ongeki_gacha(self, base_dir: str) -> None:
|
async def read_ongeki_gacha(self, base_dir: str) -> None:
|
||||||
self.logger.info(f"Reading gachas from {base_dir}...")
|
self.logger.info(f"Reading gachas from {base_dir}...")
|
||||||
|
|
||||||
# assuming some GachaKinds based on the GachaType
|
# assuming some GachaKinds based on the GachaType
|
||||||
@@ -294,7 +294,7 @@ class CardMakerReader(BaseReader):
|
|||||||
|
|
||||||
# skip already existing gachas
|
# skip already existing gachas
|
||||||
if (
|
if (
|
||||||
self.ongeki_data.static.get_gacha(
|
await self.ongeki_data.static.get_gacha(
|
||||||
OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY, gacha_id
|
OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY, gacha_id
|
||||||
)
|
)
|
||||||
is not None
|
is not None
|
||||||
@@ -320,7 +320,7 @@ class CardMakerReader(BaseReader):
|
|||||||
is_ceiling = 1
|
is_ceiling = 1
|
||||||
max_select_point = 33
|
max_select_point = 33
|
||||||
|
|
||||||
self.ongeki_data.static.put_gacha(
|
await self.ongeki_data.static.put_gacha(
|
||||||
version,
|
version,
|
||||||
gacha_id,
|
gacha_id,
|
||||||
name,
|
name,
|
||||||
|
|||||||
+23
-23
@@ -35,7 +35,7 @@ class CxbBase:
|
|||||||
return {"data": []}
|
return {"data": []}
|
||||||
|
|
||||||
async def handle_auth_usercheck_request(self, data: Dict) -> Dict:
|
async def handle_auth_usercheck_request(self, data: Dict) -> Dict:
|
||||||
profile = self.data.profile.get_profile_index(
|
profile = await self.data.profile.get_profile_index(
|
||||||
0, data["usercheck"]["authid"], self.version
|
0, data["usercheck"]["authid"], self.version
|
||||||
)
|
)
|
||||||
if profile is not None:
|
if profile is not None:
|
||||||
@@ -50,7 +50,7 @@ class CxbBase:
|
|||||||
return {"token": data["entry"]["authid"], "uid": data["entry"]["authid"]}
|
return {"token": data["entry"]["authid"], "uid": data["entry"]["authid"]}
|
||||||
|
|
||||||
async def handle_auth_login_request(self, data: Dict) -> Dict:
|
async def handle_auth_login_request(self, data: Dict) -> Dict:
|
||||||
profile = self.data.profile.get_profile_index(
|
profile = await self.data.profile.get_profile_index(
|
||||||
0, data["login"]["authid"], self.version
|
0, data["login"]["authid"], self.version
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -204,8 +204,8 @@ class CxbBase:
|
|||||||
uid = data["loadrange"]["uid"]
|
uid = data["loadrange"]["uid"]
|
||||||
|
|
||||||
self.logger.info(f"Load data for {uid}")
|
self.logger.info(f"Load data for {uid}")
|
||||||
profile = self.data.profile.get_profile(uid, self.version)
|
profile = await self.data.profile.get_profile(uid, self.version)
|
||||||
songs = self.data.score.get_best_scores(uid)
|
songs = await self.data.score.get_best_scores(uid)
|
||||||
|
|
||||||
data1 = []
|
data1 = []
|
||||||
index = []
|
index = []
|
||||||
@@ -271,7 +271,7 @@ class CxbBase:
|
|||||||
thread_ScoreData = Thread(target=CxbBase.task_generateScoreData(song, index, data1))
|
thread_ScoreData = Thread(target=CxbBase.task_generateScoreData(song, index, data1))
|
||||||
thread_ScoreData.start()
|
thread_ScoreData.start()
|
||||||
|
|
||||||
v_profile = self.data.profile.get_profile_index(0, uid, self.version)
|
v_profile = await self.data.profile.get_profile_index(0, uid, self.version)
|
||||||
v_profile_data = v_profile["data"]
|
v_profile_data = v_profile["data"]
|
||||||
|
|
||||||
for _, data in enumerate(profile):
|
for _, data in enumerate(profile):
|
||||||
@@ -300,11 +300,11 @@ class CxbBase:
|
|||||||
|
|
||||||
for value in data["saveindex"]["data"]:
|
for value in data["saveindex"]["data"]:
|
||||||
if "playedUserId" in value[1]:
|
if "playedUserId" in value[1]:
|
||||||
self.data.profile.put_profile(
|
await self.data.profile.put_profile(
|
||||||
data["saveindex"]["uid"], self.version, value[0], value[1]
|
data["saveindex"]["uid"], self.version, value[0], value[1]
|
||||||
)
|
)
|
||||||
if "mcode" not in value[1]:
|
if "mcode" not in value[1]:
|
||||||
self.data.profile.put_profile(
|
await self.data.profile.put_profile(
|
||||||
data["saveindex"]["uid"], self.version, value[0], value[1]
|
data["saveindex"]["uid"], self.version, value[0], value[1]
|
||||||
)
|
)
|
||||||
if "shopId" in value:
|
if "shopId" in value:
|
||||||
@@ -335,7 +335,7 @@ class CxbBase:
|
|||||||
"index": value[0],
|
"index": value[0],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.data.score.put_best_score(
|
await self.data.score.put_best_score(
|
||||||
data["saveindex"]["uid"],
|
data["saveindex"]["uid"],
|
||||||
song_json["mcode"],
|
song_json["mcode"],
|
||||||
self.version,
|
self.version,
|
||||||
@@ -360,32 +360,32 @@ class CxbBase:
|
|||||||
|
|
||||||
for index, value in enumerate(data["saveindex"]["data"]):
|
for index, value in enumerate(data["saveindex"]["data"]):
|
||||||
if int(data["saveindex"]["index"][index]) == 101:
|
if int(data["saveindex"]["index"][index]) == 101:
|
||||||
self.data.profile.put_profile(
|
await self.data.profile.put_profile(
|
||||||
aimeId, self.version, data["saveindex"]["index"][index], value
|
aimeId, self.version, data["saveindex"]["index"][index], value
|
||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
int(data["saveindex"]["index"][index]) >= 700000
|
int(data["saveindex"]["index"][index]) >= 700000
|
||||||
and int(data["saveindex"]["index"][index]) <= 701000
|
and int(data["saveindex"]["index"][index]) <= 701000
|
||||||
):
|
):
|
||||||
self.data.profile.put_profile(
|
await self.data.profile.put_profile(
|
||||||
aimeId, self.version, data["saveindex"]["index"][index], value
|
aimeId, self.version, data["saveindex"]["index"][index], value
|
||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
int(data["saveindex"]["index"][index]) >= 500
|
int(data["saveindex"]["index"][index]) >= 500
|
||||||
and int(data["saveindex"]["index"][index]) <= 510
|
and int(data["saveindex"]["index"][index]) <= 510
|
||||||
):
|
):
|
||||||
self.data.profile.put_profile(
|
await self.data.profile.put_profile(
|
||||||
aimeId, self.version, data["saveindex"]["index"][index], value
|
aimeId, self.version, data["saveindex"]["index"][index], value
|
||||||
)
|
)
|
||||||
if "playedUserId" in value:
|
if "playedUserId" in value:
|
||||||
self.data.profile.put_profile(
|
await self.data.profile.put_profile(
|
||||||
aimeId,
|
aimeId,
|
||||||
self.version,
|
self.version,
|
||||||
data["saveindex"]["index"][index],
|
data["saveindex"]["index"][index],
|
||||||
json.loads(value),
|
json.loads(value),
|
||||||
)
|
)
|
||||||
if "mcode" not in value and "normalCR" not in value:
|
if "mcode" not in value and "normalCR" not in value:
|
||||||
self.data.profile.put_profile(
|
await self.data.profile.put_profile(
|
||||||
aimeId,
|
aimeId,
|
||||||
self.version,
|
self.version,
|
||||||
data["saveindex"]["index"][index],
|
data["saveindex"]["index"][index],
|
||||||
@@ -437,7 +437,7 @@ class CxbBase:
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
self.data.score.put_best_score(
|
await self.data.score.put_best_score(
|
||||||
aimeId, data1["mcode"], self.version, indexSongList[i], songCode[0]
|
aimeId, data1["mcode"], self.version, indexSongList[i], songCode[0]
|
||||||
)
|
)
|
||||||
i += 1
|
i += 1
|
||||||
@@ -446,7 +446,7 @@ class CxbBase:
|
|||||||
async def handle_action_sprankreq_request(self, data: Dict) -> Dict:
|
async def handle_action_sprankreq_request(self, data: Dict) -> Dict:
|
||||||
uid = data["sprankreq"]["uid"]
|
uid = data["sprankreq"]["uid"]
|
||||||
self.logger.info(f"Get best rankings for {uid}")
|
self.logger.info(f"Get best rankings for {uid}")
|
||||||
p = self.data.score.get_best_rankings(uid)
|
p = await self.data.score.get_best_rankings(uid)
|
||||||
|
|
||||||
rankList: List[Dict[str, Any]] = []
|
rankList: List[Dict[str, Any]] = []
|
||||||
|
|
||||||
@@ -492,7 +492,7 @@ class CxbBase:
|
|||||||
# REV S2
|
# REV S2
|
||||||
if "clear" in rid:
|
if "clear" in rid:
|
||||||
try:
|
try:
|
||||||
self.data.score.put_ranking(
|
await self.data.score.put_ranking(
|
||||||
user_id=uid,
|
user_id=uid,
|
||||||
rev_id=int(rid["rid"]),
|
rev_id=int(rid["rid"]),
|
||||||
song_id=int(rid["sc"][1]),
|
song_id=int(rid["sc"][1]),
|
||||||
@@ -500,7 +500,7 @@ class CxbBase:
|
|||||||
clear=rid["clear"],
|
clear=rid["clear"],
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.data.score.put_ranking(
|
await self.data.score.put_ranking(
|
||||||
user_id=uid,
|
user_id=uid,
|
||||||
rev_id=int(rid["rid"]),
|
rev_id=int(rid["rid"]),
|
||||||
song_id=0,
|
song_id=0,
|
||||||
@@ -510,7 +510,7 @@ class CxbBase:
|
|||||||
# REV
|
# REV
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.data.score.put_ranking(
|
await self.data.score.put_ranking(
|
||||||
user_id=uid,
|
user_id=uid,
|
||||||
rev_id=int(rid["rid"]),
|
rev_id=int(rid["rid"]),
|
||||||
song_id=int(rid["sc"][1]),
|
song_id=int(rid["sc"][1]),
|
||||||
@@ -518,7 +518,7 @@ class CxbBase:
|
|||||||
clear=0,
|
clear=0,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.data.score.put_ranking(
|
await self.data.score.put_ranking(
|
||||||
user_id=uid,
|
user_id=uid,
|
||||||
rev_id=int(rid["rid"]),
|
rev_id=int(rid["rid"]),
|
||||||
song_id=0,
|
song_id=0,
|
||||||
@@ -530,12 +530,12 @@ class CxbBase:
|
|||||||
async def handle_action_addenergy_request(self, data: Dict) -> Dict:
|
async def handle_action_addenergy_request(self, data: Dict) -> Dict:
|
||||||
uid = data["addenergy"]["uid"]
|
uid = data["addenergy"]["uid"]
|
||||||
self.logger.info(f"Add energy to user {uid}")
|
self.logger.info(f"Add energy to user {uid}")
|
||||||
profile = self.data.profile.get_profile_index(0, uid, self.version)
|
profile = await self.data.profile.get_profile_index(0, uid, self.version)
|
||||||
data1 = profile["data"]
|
data1 = profile["data"]
|
||||||
p = self.data.item.get_energy(uid)
|
p = await self.data.item.get_energy(uid)
|
||||||
|
|
||||||
if not p:
|
if not p:
|
||||||
self.data.item.put_energy(uid, 5)
|
await self.data.item.put_energy(uid, 5)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"class": data1["myClass"],
|
"class": data1["myClass"],
|
||||||
@@ -548,7 +548,7 @@ class CxbBase:
|
|||||||
energy = p["energy"]
|
energy = p["energy"]
|
||||||
|
|
||||||
newenergy = int(energy) + 5
|
newenergy = int(energy) + 5
|
||||||
self.data.item.put_energy(uid, newenergy)
|
await self.data.item.put_energy(uid, newenergy)
|
||||||
|
|
||||||
if int(energy) <= 995:
|
if int(energy) <= 995:
|
||||||
array.append(
|
array.append(
|
||||||
|
|||||||
+13
-18
@@ -1,6 +1,5 @@
|
|||||||
from typing import Optional, Dict, List
|
from typing import Optional
|
||||||
from os import walk, path
|
from os import path
|
||||||
import urllib
|
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
from read import BaseReader
|
from read import BaseReader
|
||||||
@@ -8,7 +7,6 @@ from core.config import CoreConfig
|
|||||||
from titles.cxb.database import CxbData
|
from titles.cxb.database import CxbData
|
||||||
from titles.cxb.const import CxbConstants
|
from titles.cxb.const import CxbConstants
|
||||||
|
|
||||||
|
|
||||||
class CxbReader(BaseReader):
|
class CxbReader(BaseReader):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -29,17 +27,14 @@ class CxbReader(BaseReader):
|
|||||||
self.logger.error(f"Invalid project cxb version {version}")
|
self.logger.error(f"Invalid project cxb version {version}")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def read(self) -> None:
|
async def read(self) -> None:
|
||||||
pull_bin_ram = True
|
if path.exists(self.bin_dir):
|
||||||
|
await self.read_csv(self.bin_dir)
|
||||||
|
|
||||||
if not path.exists(f"{self.bin_dir}"):
|
else:
|
||||||
self.logger.warning(f"Couldn't find csv file in {self.bin_dir}, skipping")
|
self.logger.warn(f"{self.bin_dir} does not exist, nothing to import")
|
||||||
pull_bin_ram = False
|
|
||||||
|
|
||||||
if pull_bin_ram:
|
async def read_csv(self, bin_dir: str) -> None:
|
||||||
self.read_csv(f"{self.bin_dir}")
|
|
||||||
|
|
||||||
def read_csv(self, bin_dir: str) -> None:
|
|
||||||
self.logger.info(f"Read csv from {bin_dir}")
|
self.logger.info(f"Read csv from {bin_dir}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -55,7 +50,7 @@ class CxbReader(BaseReader):
|
|||||||
|
|
||||||
if not "N/A" in row["standard"]:
|
if not "N/A" in row["standard"]:
|
||||||
self.logger.info(f"Added song {song_id} chart 0")
|
self.logger.info(f"Added song {song_id} chart 0")
|
||||||
self.data.static.put_music(
|
await self.data.static.put_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
index,
|
index,
|
||||||
@@ -71,7 +66,7 @@ class CxbReader(BaseReader):
|
|||||||
)
|
)
|
||||||
if not "N/A" in row["hard"]:
|
if not "N/A" in row["hard"]:
|
||||||
self.logger.info(f"Added song {song_id} chart 1")
|
self.logger.info(f"Added song {song_id} chart 1")
|
||||||
self.data.static.put_music(
|
await self.data.static.put_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
index,
|
index,
|
||||||
@@ -83,7 +78,7 @@ class CxbReader(BaseReader):
|
|||||||
)
|
)
|
||||||
if not "N/A" in row["master"]:
|
if not "N/A" in row["master"]:
|
||||||
self.logger.info(f"Added song {song_id} chart 2")
|
self.logger.info(f"Added song {song_id} chart 2")
|
||||||
self.data.static.put_music(
|
await self.data.static.put_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
index,
|
index,
|
||||||
@@ -97,7 +92,7 @@ class CxbReader(BaseReader):
|
|||||||
)
|
)
|
||||||
if not "N/A" in row["unlimited"]:
|
if not "N/A" in row["unlimited"]:
|
||||||
self.logger.info(f"Added song {song_id} chart 3")
|
self.logger.info(f"Added song {song_id} chart 3")
|
||||||
self.data.static.put_music(
|
await self.data.static.put_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
index,
|
index,
|
||||||
@@ -113,7 +108,7 @@ class CxbReader(BaseReader):
|
|||||||
)
|
)
|
||||||
if not "N/A" in row["easy"]:
|
if not "N/A" in row["easy"]:
|
||||||
self.logger.info(f"Added song {song_id} chart 4")
|
self.logger.info(f"Added song {song_id} chart 4")
|
||||||
self.data.static.put_music(
|
await self.data.static.put_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
index,
|
index,
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ class CxbRev(CxbBase):
|
|||||||
score_data = json.loads(data["putlog"]["data"])
|
score_data = json.loads(data["putlog"]["data"])
|
||||||
userid = score_data["usid"]
|
userid = score_data["usid"]
|
||||||
|
|
||||||
self.data.score.put_playlog(
|
await self.data.score.put_playlog(
|
||||||
userid,
|
userid,
|
||||||
score_data["mcode"],
|
score_data["mcode"],
|
||||||
score_data["difficulty"],
|
score_data["difficulty"],
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ energy = Table(
|
|||||||
|
|
||||||
|
|
||||||
class CxbItemData(BaseData):
|
class CxbItemData(BaseData):
|
||||||
def put_energy(self, user_id: int, rev_energy: int) -> Optional[int]:
|
async def put_energy(self, user_id: int, rev_energy: int) -> Optional[int]:
|
||||||
sql = insert(energy).values(user=user_id, energy=rev_energy)
|
sql = insert(energy).values(user=user_id, energy=rev_energy)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(energy=rev_energy)
|
conflict = sql.on_duplicate_key_update(energy=rev_energy)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} failed to insert item! user: {user_id}, energy: {rev_energy}"
|
f"{__name__} failed to insert item! user: {user_id}, energy: {rev_energy}"
|
||||||
@@ -33,10 +33,10 @@ class CxbItemData(BaseData):
|
|||||||
|
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_energy(self, user_id: int) -> Optional[Dict]:
|
async def get_energy(self, user_id: int) -> Optional[Dict]:
|
||||||
sql = energy.select(and_(energy.c.user == user_id))
|
sql = energy.select(and_(energy.c.user == user_id))
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ profile = Table(
|
|||||||
|
|
||||||
|
|
||||||
class CxbProfileData(BaseData):
|
class CxbProfileData(BaseData):
|
||||||
def put_profile(
|
async def put_profile(
|
||||||
self, user_id: int, version: int, index: int, data: JSON
|
self, user_id: int, version: int, index: int, data: JSON
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(profile).values(
|
sql = insert(profile).values(
|
||||||
@@ -30,7 +30,7 @@ class CxbProfileData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(index=index, data=data)
|
conflict = sql.on_duplicate_key_update(index=index, data=data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} failed to update! user: {user_id}, index: {index}, data: {data}"
|
f"{__name__} failed to update! user: {user_id}, index: {index}, data: {data}"
|
||||||
@@ -39,7 +39,7 @@ class CxbProfileData(BaseData):
|
|||||||
|
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
async def get_profile(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
||||||
"""
|
"""
|
||||||
Given a game version and either a profile or aime id, return the profile
|
Given a game version and either a profile or aime id, return the profile
|
||||||
"""
|
"""
|
||||||
@@ -47,12 +47,12 @@ class CxbProfileData(BaseData):
|
|||||||
and_(profile.c.version == version, profile.c.user == aime_id)
|
and_(profile.c.version == version, profile.c.user == aime_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_profile_index(
|
async def get_profile_index(
|
||||||
self, index: int, aime_id: int = None, version: int = None
|
self, index: int, aime_id: int = None, version: int = None
|
||||||
) -> Optional[Dict]:
|
) -> Optional[Dict]:
|
||||||
"""
|
"""
|
||||||
@@ -72,7 +72,7 @@ class CxbProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|||||||
+12
-12
@@ -58,7 +58,7 @@ ranking = Table(
|
|||||||
|
|
||||||
|
|
||||||
class CxbScoreData(BaseData):
|
class CxbScoreData(BaseData):
|
||||||
def put_best_score(
|
async def put_best_score(
|
||||||
self,
|
self,
|
||||||
user_id: int,
|
user_id: int,
|
||||||
song_mcode: str,
|
song_mcode: str,
|
||||||
@@ -79,7 +79,7 @@ class CxbScoreData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(data=sql.inserted.data)
|
conflict = sql.on_duplicate_key_update(data=sql.inserted.data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} failed to insert best score! profile: {user_id}, song: {song_mcode}, data: {data}"
|
f"{__name__} failed to insert best score! profile: {user_id}, song: {song_mcode}, data: {data}"
|
||||||
@@ -88,7 +88,7 @@ class CxbScoreData(BaseData):
|
|||||||
|
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_playlog(
|
async def put_playlog(
|
||||||
self,
|
self,
|
||||||
user_id: int,
|
user_id: int,
|
||||||
song_mcode: str,
|
song_mcode: str,
|
||||||
@@ -125,7 +125,7 @@ class CxbScoreData(BaseData):
|
|||||||
combo=combo,
|
combo=combo,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} failed to insert playlog! profile: {user_id}, song: {song_mcode}, chart: {chart_id}"
|
f"{__name__} failed to insert playlog! profile: {user_id}, song: {song_mcode}, chart: {chart_id}"
|
||||||
@@ -134,7 +134,7 @@ class CxbScoreData(BaseData):
|
|||||||
|
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_ranking(
|
async def put_ranking(
|
||||||
self, user_id: int, rev_id: int, song_id: int, score: int, clear: int
|
self, user_id: int, rev_id: int, song_id: int, score: int, clear: int
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
"""
|
"""
|
||||||
@@ -151,7 +151,7 @@ class CxbScoreData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(score=score)
|
conflict = sql.on_duplicate_key_update(score=score)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} failed to insert ranking log! profile: {user_id}, score: {score}, clear: {clear}"
|
f"{__name__} failed to insert ranking log! profile: {user_id}, score: {score}, clear: {clear}"
|
||||||
@@ -160,28 +160,28 @@ class CxbScoreData(BaseData):
|
|||||||
|
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_best_score(self, user_id: int, song_mcode: int) -> Optional[Dict]:
|
async def get_best_score(self, user_id: int, song_mcode: int) -> Optional[Dict]:
|
||||||
sql = score.select(
|
sql = score.select(
|
||||||
and_(score.c.user == user_id, score.c.song_mcode == song_mcode)
|
and_(score.c.user == user_id, score.c.song_mcode == song_mcode)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_best_scores(self, user_id: int) -> Optional[Dict]:
|
async def get_best_scores(self, user_id: int) -> Optional[Dict]:
|
||||||
sql = score.select(score.c.user == user_id)
|
sql = score.select(score.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_best_rankings(self, user_id: int) -> Optional[List[Dict]]:
|
async def get_best_rankings(self, user_id: int) -> Optional[List[Dict]]:
|
||||||
sql = ranking.select(ranking.c.user == user_id)
|
sql = ranking.select(ranking.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ music = Table(
|
|||||||
|
|
||||||
|
|
||||||
class CxbStaticData(BaseData):
|
class CxbStaticData(BaseData):
|
||||||
def put_music(
|
async def put_music(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
mcode: str,
|
mcode: str,
|
||||||
@@ -55,12 +55,12 @@ class CxbStaticData(BaseData):
|
|||||||
title=title, artist=artist, category=category, level=level
|
title=title, artist=artist, category=category, level=level
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_music(
|
async def get_music(
|
||||||
self, version: int, song_id: Optional[int] = None
|
self, version: int, song_id: Optional[int] = None
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
if song_id is None:
|
if song_id is None:
|
||||||
@@ -73,12 +73,12 @@ class CxbStaticData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_music_chart(
|
async def get_music_chart(
|
||||||
self, version: int, song_id: int, chart_id: int
|
self, version: int, song_id: int, chart_id: int
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = select(music).where(
|
sql = select(music).where(
|
||||||
@@ -89,7 +89,7 @@ class CxbStaticData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|||||||
+48
-48
@@ -128,7 +128,7 @@ class DivaBase:
|
|||||||
async def handle_shop_catalog_request(self, data: Dict) -> Dict:
|
async def handle_shop_catalog_request(self, data: Dict) -> Dict:
|
||||||
catalog = ""
|
catalog = ""
|
||||||
|
|
||||||
shopList = self.data.static.get_enabled_shops(self.version)
|
shopList = await self.data.static.get_enabled_shops(self.version)
|
||||||
if not shopList:
|
if not shopList:
|
||||||
with open(r"titles/diva/data/ShopCatalog.dat", encoding="utf-8") as shop:
|
with open(r"titles/diva/data/ShopCatalog.dat", encoding="utf-8") as shop:
|
||||||
lines = shop.readlines()
|
lines = shop.readlines()
|
||||||
@@ -164,8 +164,8 @@ class DivaBase:
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
async def handle_buy_module_request(self, data: Dict) -> Dict:
|
async def handle_buy_module_request(self, data: Dict) -> Dict:
|
||||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
profile = await self.data.profile.get_profile(data["pd_id"], self.version)
|
||||||
module = self.data.static.get_enabled_shop(self.version, int(data["mdl_id"]))
|
module = await self.data.static.get_enabled_shop(self.version, int(data["mdl_id"]))
|
||||||
|
|
||||||
# make sure module is available to purchase
|
# make sure module is available to purchase
|
||||||
if not module:
|
if not module:
|
||||||
@@ -177,11 +177,11 @@ class DivaBase:
|
|||||||
|
|
||||||
new_vcld_pts = profile["vcld_pts"] - int(data["mdl_price"])
|
new_vcld_pts = profile["vcld_pts"] - int(data["mdl_price"])
|
||||||
|
|
||||||
self.data.profile.update_profile(profile["user"], vcld_pts=new_vcld_pts)
|
await self.data.profile.update_profile(profile["user"], vcld_pts=new_vcld_pts)
|
||||||
self.data.module.put_module(data["pd_id"], self.version, data["mdl_id"])
|
await self.data.module.put_module(data["pd_id"], self.version, data["mdl_id"])
|
||||||
|
|
||||||
# generate the mdl_have string
|
# generate the mdl_have string
|
||||||
mdl_have = self.data.module.get_modules_have_string(data["pd_id"], self.version)
|
mdl_have = await self.data.module.get_modules_have_string(data["pd_id"], self.version)
|
||||||
|
|
||||||
response = "&shp_rslt=1"
|
response = "&shp_rslt=1"
|
||||||
response += f"&mdl_id={data['mdl_id']}"
|
response += f"&mdl_id={data['mdl_id']}"
|
||||||
@@ -193,7 +193,7 @@ class DivaBase:
|
|||||||
async def handle_cstmz_itm_ctlg_request(self, data: Dict) -> Dict:
|
async def handle_cstmz_itm_ctlg_request(self, data: Dict) -> Dict:
|
||||||
catalog = ""
|
catalog = ""
|
||||||
|
|
||||||
itemList = self.data.static.get_enabled_items(self.version)
|
itemList = await self.data.static.get_enabled_items(self.version)
|
||||||
if not itemList:
|
if not itemList:
|
||||||
with open(r"titles/diva/data/ItemCatalog.dat", encoding="utf-8") as item:
|
with open(r"titles/diva/data/ItemCatalog.dat", encoding="utf-8") as item:
|
||||||
lines = item.readlines()
|
lines = item.readlines()
|
||||||
@@ -229,8 +229,8 @@ class DivaBase:
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
async def handle_buy_cstmz_itm_request(self, data: Dict) -> Dict:
|
async def handle_buy_cstmz_itm_request(self, data: Dict) -> Dict:
|
||||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
profile = await self.data.profile.get_profile(data["pd_id"], self.version)
|
||||||
item = self.data.static.get_enabled_item(
|
item = await self.data.static.get_enabled_item(
|
||||||
self.version, int(data["cstmz_itm_id"])
|
self.version, int(data["cstmz_itm_id"])
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -245,14 +245,14 @@ class DivaBase:
|
|||||||
new_vcld_pts = profile["vcld_pts"] - int(data["cstmz_itm_price"])
|
new_vcld_pts = profile["vcld_pts"] - int(data["cstmz_itm_price"])
|
||||||
|
|
||||||
# save new Vocaloid Points balance
|
# save new Vocaloid Points balance
|
||||||
self.data.profile.update_profile(profile["user"], vcld_pts=new_vcld_pts)
|
await self.data.profile.update_profile(profile["user"], vcld_pts=new_vcld_pts)
|
||||||
|
|
||||||
self.data.customize.put_customize_item(
|
await self.data.customize.put_customize_item(
|
||||||
data["pd_id"], self.version, data["cstmz_itm_id"]
|
data["pd_id"], self.version, data["cstmz_itm_id"]
|
||||||
)
|
)
|
||||||
|
|
||||||
# generate the cstmz_itm_have string
|
# generate the cstmz_itm_have string
|
||||||
cstmz_itm_have = self.data.customize.get_customize_items_have_string(
|
cstmz_itm_have = await self.data.customize.get_customize_items_have_string(
|
||||||
data["pd_id"], self.version
|
data["pd_id"], self.version
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -297,7 +297,7 @@ class DivaBase:
|
|||||||
async def handle_qst_inf_request(self, data: Dict) -> Dict:
|
async def handle_qst_inf_request(self, data: Dict) -> Dict:
|
||||||
quest = ""
|
quest = ""
|
||||||
|
|
||||||
questList = self.data.static.get_enabled_quests(self.version)
|
questList = await self.data.static.get_enabled_quests(self.version)
|
||||||
if not questList:
|
if not questList:
|
||||||
with open(r"titles/diva/data/QuestInfo.dat", encoding="utf-8") as shop:
|
with open(r"titles/diva/data/QuestInfo.dat", encoding="utf-8") as shop:
|
||||||
lines = shop.readlines()
|
lines = shop.readlines()
|
||||||
@@ -381,8 +381,8 @@ class DivaBase:
|
|||||||
return f""
|
return f""
|
||||||
|
|
||||||
async def handle_pre_start_request(self, data: Dict) -> str:
|
async def handle_pre_start_request(self, data: Dict) -> str:
|
||||||
profile = self.data.profile.get_profile(data["aime_id"], self.version)
|
profile = await self.data.profile.get_profile(data["aime_id"], self.version)
|
||||||
profile_shop = self.data.item.get_shop(data["aime_id"], self.version)
|
profile_shop = await self.data.item.get_shop(data["aime_id"], self.version)
|
||||||
|
|
||||||
if profile is None:
|
if profile is None:
|
||||||
return f"&ps_result=-3"
|
return f"&ps_result=-3"
|
||||||
@@ -422,28 +422,28 @@ class DivaBase:
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
async def handle_registration_request(self, data: Dict) -> Dict:
|
async def handle_registration_request(self, data: Dict) -> Dict:
|
||||||
self.data.profile.create_profile(
|
await self.data.profile.create_profile(
|
||||||
self.version, data["aime_id"], data["player_name"]
|
self.version, data["aime_id"], data["player_name"]
|
||||||
)
|
)
|
||||||
return f"&cd_adm_result=1&pd_id={data['aime_id']}"
|
return f"&cd_adm_result=1&pd_id={data['aime_id']}"
|
||||||
|
|
||||||
async def handle_start_request(self, data: Dict) -> Dict:
|
async def handle_start_request(self, data: Dict) -> Dict:
|
||||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
profile = await self.data.profile.get_profile(data["pd_id"], self.version)
|
||||||
profile_shop = self.data.item.get_shop(data["pd_id"], self.version)
|
profile_shop = await self.data.item.get_shop(data["pd_id"], self.version)
|
||||||
if profile is None:
|
if profile is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
mdl_have = "F" * 250
|
mdl_have = "F" * 250
|
||||||
# generate the mdl_have string if "unlock_all_modules" is disabled
|
# generate the mdl_have string if "unlock_all_modules" is disabled
|
||||||
if not self.game_config.mods.unlock_all_modules:
|
if not self.game_config.mods.unlock_all_modules:
|
||||||
mdl_have = self.data.module.get_modules_have_string(
|
mdl_have = await self.data.module.get_modules_have_string(
|
||||||
data["pd_id"], self.version
|
data["pd_id"], self.version
|
||||||
)
|
)
|
||||||
|
|
||||||
cstmz_itm_have = "F" * 250
|
cstmz_itm_have = "F" * 250
|
||||||
# generate the cstmz_itm_have string if "unlock_all_items" is disabled
|
# generate the cstmz_itm_have string if "unlock_all_items" is disabled
|
||||||
if not self.game_config.mods.unlock_all_items:
|
if not self.game_config.mods.unlock_all_items:
|
||||||
cstmz_itm_have = self.data.customize.get_customize_items_have_string(
|
cstmz_itm_have = await self.data.customize.get_customize_items_have_string(
|
||||||
data["pd_id"], self.version
|
data["pd_id"], self.version
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -524,7 +524,7 @@ class DivaBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
# get clear status from user scores
|
# get clear status from user scores
|
||||||
pv_records = self.data.score.get_best_scores(data["pd_id"])
|
pv_records = await self.data.score.get_best_scores(data["pd_id"])
|
||||||
clear_status = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
|
clear_status = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
|
||||||
|
|
||||||
if pv_records is not None:
|
if pv_records is not None:
|
||||||
@@ -586,7 +586,7 @@ class DivaBase:
|
|||||||
return f""
|
return f""
|
||||||
|
|
||||||
async def handle_spend_credit_request(self, data: Dict) -> Dict:
|
async def handle_spend_credit_request(self, data: Dict) -> Dict:
|
||||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
profile = await self.data.profile.get_profile(data["pd_id"], self.version)
|
||||||
if profile is None:
|
if profile is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -663,30 +663,30 @@ class DivaBase:
|
|||||||
|
|
||||||
return pv_result
|
return pv_result
|
||||||
|
|
||||||
def task_generateScoreData(self, data: Dict, pd_by_pv_id, song):
|
async def task_generateScoreData(self, data: Dict, pd_by_pv_id, song):
|
||||||
|
|
||||||
if int(song) > 0:
|
if int(song) > 0:
|
||||||
# the request do not send a edition so just perform a query best score and ranking for each edition.
|
# the request do not send a edition so just perform a query best score and ranking for each edition.
|
||||||
# 0=ORIGINAL, 1=EXTRA
|
# 0=ORIGINAL, 1=EXTRA
|
||||||
pd_db_song_0 = self.data.score.get_best_user_score(
|
pd_db_song_0 = await self.data.score.get_best_user_score(
|
||||||
data["pd_id"], int(song), data["difficulty"], edition=0
|
data["pd_id"], int(song), data["difficulty"], edition=0
|
||||||
)
|
)
|
||||||
pd_db_song_1 = self.data.score.get_best_user_score(
|
pd_db_song_1 = await self.data.score.get_best_user_score(
|
||||||
data["pd_id"], int(song), data["difficulty"], edition=1
|
data["pd_id"], int(song), data["difficulty"], edition=1
|
||||||
)
|
)
|
||||||
|
|
||||||
pd_db_ranking_0, pd_db_ranking_1 = None, None
|
pd_db_ranking_0, pd_db_ranking_1 = None, None
|
||||||
if pd_db_song_0:
|
if pd_db_song_0:
|
||||||
pd_db_ranking_0 = self.data.score.get_global_ranking(
|
pd_db_ranking_0 = await self.data.score.get_global_ranking(
|
||||||
data["pd_id"], int(song), data["difficulty"], edition=0
|
data["pd_id"], int(song), data["difficulty"], edition=0
|
||||||
)
|
)
|
||||||
|
|
||||||
if pd_db_song_1:
|
if pd_db_song_1:
|
||||||
pd_db_ranking_1 = self.data.score.get_global_ranking(
|
pd_db_ranking_1 = await self.data.score.get_global_ranking(
|
||||||
data["pd_id"], int(song), data["difficulty"], edition=1
|
data["pd_id"], int(song), data["difficulty"], edition=1
|
||||||
)
|
)
|
||||||
|
|
||||||
pd_db_customize = self.data.pv_customize.get_pv_customize(
|
pd_db_customize = await self.data.pv_customize.get_pv_customize(
|
||||||
data["pd_id"], int(song)
|
data["pd_id"], int(song)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -712,7 +712,7 @@ class DivaBase:
|
|||||||
pd_by_pv_id = []
|
pd_by_pv_id = []
|
||||||
|
|
||||||
for song in song_id:
|
for song in song_id:
|
||||||
thread_ScoreData = Thread(target=self.task_generateScoreData(data, pd_by_pv_id, song))
|
thread_ScoreData = Thread(target=await self.task_generateScoreData(data, pd_by_pv_id, song))
|
||||||
threads.append(thread_ScoreData)
|
threads.append(thread_ScoreData)
|
||||||
|
|
||||||
for x in threads:
|
for x in threads:
|
||||||
@@ -735,7 +735,7 @@ class DivaBase:
|
|||||||
return f""
|
return f""
|
||||||
|
|
||||||
async def handle_stage_result_request(self, data: Dict) -> Dict:
|
async def handle_stage_result_request(self, data: Dict) -> Dict:
|
||||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
profile = await self.data.profile.get_profile(data["pd_id"], self.version)
|
||||||
|
|
||||||
pd_song_list = data["stg_ply_pv_id"].split(",")
|
pd_song_list = data["stg_ply_pv_id"].split(",")
|
||||||
pd_song_difficulty = data["stg_difficulty"].split(",")
|
pd_song_difficulty = data["stg_difficulty"].split(",")
|
||||||
@@ -753,14 +753,14 @@ class DivaBase:
|
|||||||
|
|
||||||
for index, value in enumerate(pd_song_list):
|
for index, value in enumerate(pd_song_list):
|
||||||
if "-1" not in pd_song_list[index]:
|
if "-1" not in pd_song_list[index]:
|
||||||
profile_pd_db_song = self.data.score.get_best_user_score(
|
profile_pd_db_song = await self.data.score.get_best_user_score(
|
||||||
data["pd_id"],
|
data["pd_id"],
|
||||||
pd_song_list[index],
|
pd_song_list[index],
|
||||||
pd_song_difficulty[index],
|
pd_song_difficulty[index],
|
||||||
pd_song_edition[index],
|
pd_song_edition[index],
|
||||||
)
|
)
|
||||||
if profile_pd_db_song is None:
|
if profile_pd_db_song is None:
|
||||||
self.data.score.put_best_score(
|
await self.data.score.put_best_score(
|
||||||
data["pd_id"],
|
data["pd_id"],
|
||||||
self.version,
|
self.version,
|
||||||
pd_song_list[index],
|
pd_song_list[index],
|
||||||
@@ -777,7 +777,7 @@ class DivaBase:
|
|||||||
pd_song_worst_cnt[index],
|
pd_song_worst_cnt[index],
|
||||||
pd_song_max_combo[index],
|
pd_song_max_combo[index],
|
||||||
)
|
)
|
||||||
self.data.score.put_playlog(
|
await self.data.score.put_playlog(
|
||||||
data["pd_id"],
|
data["pd_id"],
|
||||||
self.version,
|
self.version,
|
||||||
pd_song_list[index],
|
pd_song_list[index],
|
||||||
@@ -795,7 +795,7 @@ class DivaBase:
|
|||||||
pd_song_max_combo[index],
|
pd_song_max_combo[index],
|
||||||
)
|
)
|
||||||
elif int(pd_song_max_score[index]) >= int(profile_pd_db_song["score"]):
|
elif int(pd_song_max_score[index]) >= int(profile_pd_db_song["score"]):
|
||||||
self.data.score.put_best_score(
|
await self.data.score.put_best_score(
|
||||||
data["pd_id"],
|
data["pd_id"],
|
||||||
self.version,
|
self.version,
|
||||||
pd_song_list[index],
|
pd_song_list[index],
|
||||||
@@ -812,7 +812,7 @@ class DivaBase:
|
|||||||
pd_song_worst_cnt[index],
|
pd_song_worst_cnt[index],
|
||||||
pd_song_max_combo[index],
|
pd_song_max_combo[index],
|
||||||
)
|
)
|
||||||
self.data.score.put_playlog(
|
await self.data.score.put_playlog(
|
||||||
data["pd_id"],
|
data["pd_id"],
|
||||||
self.version,
|
self.version,
|
||||||
pd_song_list[index],
|
pd_song_list[index],
|
||||||
@@ -830,7 +830,7 @@ class DivaBase:
|
|||||||
pd_song_max_combo[index],
|
pd_song_max_combo[index],
|
||||||
)
|
)
|
||||||
elif int(pd_song_max_score[index]) != int(profile_pd_db_song["score"]):
|
elif int(pd_song_max_score[index]) != int(profile_pd_db_song["score"]):
|
||||||
self.data.score.put_playlog(
|
await self.data.score.put_playlog(
|
||||||
data["pd_id"],
|
data["pd_id"],
|
||||||
self.version,
|
self.version,
|
||||||
pd_song_list[index],
|
pd_song_list[index],
|
||||||
@@ -851,7 +851,7 @@ class DivaBase:
|
|||||||
# Profile saving based on registration list
|
# Profile saving based on registration list
|
||||||
|
|
||||||
# Calculate new level
|
# Calculate new level
|
||||||
best_scores = self.data.score.get_best_scores(data["pd_id"])
|
best_scores = await self.data.score.get_best_scores(data["pd_id"])
|
||||||
|
|
||||||
total_atn_pnt = 0
|
total_atn_pnt = 0
|
||||||
for best_score in best_scores:
|
for best_score in best_scores:
|
||||||
@@ -865,7 +865,7 @@ class DivaBase:
|
|||||||
response += f"&lv_pnt_old={int(profile['lv_pnt'])}"
|
response += f"&lv_pnt_old={int(profile['lv_pnt'])}"
|
||||||
|
|
||||||
# update the profile and commit changes to the db
|
# update the profile and commit changes to the db
|
||||||
self.data.profile.update_profile(
|
await self.data.profile.update_profile(
|
||||||
profile["user"],
|
profile["user"],
|
||||||
lv_num=new_level,
|
lv_num=new_level,
|
||||||
lv_pnt=new_level_pnt,
|
lv_pnt=new_level_pnt,
|
||||||
@@ -914,15 +914,15 @@ class DivaBase:
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
async def handle_end_request(self, data: Dict) -> Dict:
|
async def handle_end_request(self, data: Dict) -> Dict:
|
||||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
profile = await self.data.profile.get_profile(data["pd_id"], self.version)
|
||||||
|
|
||||||
self.data.profile.update_profile(
|
await self.data.profile.update_profile(
|
||||||
profile["user"], my_qst_id=data["my_qst_id"], my_qst_sts=data["my_qst_sts"]
|
profile["user"], my_qst_id=data["my_qst_id"], my_qst_sts=data["my_qst_sts"]
|
||||||
)
|
)
|
||||||
return f""
|
return f""
|
||||||
|
|
||||||
async def handle_shop_exit_request(self, data: Dict) -> Dict:
|
async def handle_shop_exit_request(self, data: Dict) -> Dict:
|
||||||
self.data.item.put_shop(
|
await self.data.item.put_shop(
|
||||||
data["pd_id"],
|
data["pd_id"],
|
||||||
self.version,
|
self.version,
|
||||||
data["mdl_eqp_cmn_ary"],
|
data["mdl_eqp_cmn_ary"],
|
||||||
@@ -930,7 +930,7 @@ class DivaBase:
|
|||||||
data["ms_itm_flg_cmn_ary"],
|
data["ms_itm_flg_cmn_ary"],
|
||||||
)
|
)
|
||||||
if int(data["use_pv_mdl_eqp"]) == 1:
|
if int(data["use_pv_mdl_eqp"]) == 1:
|
||||||
self.data.pv_customize.put_pv_customize(
|
await self.data.pv_customize.put_pv_customize(
|
||||||
data["pd_id"],
|
data["pd_id"],
|
||||||
self.version,
|
self.version,
|
||||||
data["ply_pv_id"],
|
data["ply_pv_id"],
|
||||||
@@ -939,7 +939,7 @@ class DivaBase:
|
|||||||
data["ms_itm_flg_pv_ary"],
|
data["ms_itm_flg_pv_ary"],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.data.pv_customize.put_pv_customize(
|
await self.data.pv_customize.put_pv_customize(
|
||||||
data["pd_id"],
|
data["pd_id"],
|
||||||
self.version,
|
self.version,
|
||||||
data["ply_pv_id"],
|
data["ply_pv_id"],
|
||||||
@@ -952,7 +952,7 @@ class DivaBase:
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
async def handle_card_procedure_request(self, data: Dict) -> str:
|
async def handle_card_procedure_request(self, data: Dict) -> str:
|
||||||
profile = self.data.profile.get_profile(data["aime_id"], self.version)
|
profile = await self.data.profile.get_profile(data["aime_id"], self.version)
|
||||||
if profile is None:
|
if profile is None:
|
||||||
return "&cd_adm_result=0"
|
return "&cd_adm_result=0"
|
||||||
|
|
||||||
@@ -972,7 +972,7 @@ class DivaBase:
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
async def handle_change_name_request(self, data: Dict) -> str:
|
async def handle_change_name_request(self, data: Dict) -> str:
|
||||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
profile = await self.data.profile.get_profile(data["pd_id"], self.version)
|
||||||
|
|
||||||
# make sure user has enough Vocaloid Points
|
# make sure user has enough Vocaloid Points
|
||||||
if profile["vcld_pts"] < int(data["chg_name_price"]):
|
if profile["vcld_pts"] < int(data["chg_name_price"]):
|
||||||
@@ -980,7 +980,7 @@ class DivaBase:
|
|||||||
|
|
||||||
# update the vocaloid points and player name
|
# update the vocaloid points and player name
|
||||||
new_vcld_pts = profile["vcld_pts"] - int(data["chg_name_price"])
|
new_vcld_pts = profile["vcld_pts"] - int(data["chg_name_price"])
|
||||||
self.data.profile.update_profile(
|
await self.data.profile.update_profile(
|
||||||
profile["user"], player_name=data["player_name"], vcld_pts=new_vcld_pts
|
profile["user"], player_name=data["player_name"], vcld_pts=new_vcld_pts
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -992,14 +992,14 @@ class DivaBase:
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
async def handle_change_passwd_request(self, data: Dict) -> str:
|
async def handle_change_passwd_request(self, data: Dict) -> str:
|
||||||
profile = self.data.profile.get_profile(data["pd_id"], self.version)
|
profile = await self.data.profile.get_profile(data["pd_id"], self.version)
|
||||||
|
|
||||||
# TODO: return correct error number instead of 0
|
# TODO: return correct error number instead of 0
|
||||||
if data["passwd"] != profile["passwd"]:
|
if data["passwd"] != profile["passwd"]:
|
||||||
return "&cd_adm_result=0"
|
return "&cd_adm_result=0"
|
||||||
|
|
||||||
# set password to true and update the saved password
|
# set password to true and update the saved password
|
||||||
self.data.profile.update_profile(
|
await self.data.profile.update_profile(
|
||||||
profile["user"], passwd_stat=1, passwd=data["new_passwd"]
|
profile["user"], passwd_stat=1, passwd=data["new_passwd"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -28,7 +28,7 @@ class DivaReader(BaseReader):
|
|||||||
self.logger.error(f"Invalid project diva version {version}")
|
self.logger.error(f"Invalid project diva version {version}")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def read(self) -> None:
|
async def read(self) -> None:
|
||||||
pull_bin_ram = True
|
pull_bin_ram = True
|
||||||
pull_bin_rom = True
|
pull_bin_rom = True
|
||||||
pull_opt_rom = True
|
pull_opt_rom = True
|
||||||
@@ -48,14 +48,14 @@ class DivaReader(BaseReader):
|
|||||||
self.logger.warning("No option directory specified, skipping")
|
self.logger.warning("No option directory specified, skipping")
|
||||||
|
|
||||||
if pull_bin_ram:
|
if pull_bin_ram:
|
||||||
self.read_ram(f"{self.bin_dir}/ram")
|
await self.read_ram(f"{self.bin_dir}/ram")
|
||||||
if pull_bin_rom:
|
if pull_bin_rom:
|
||||||
self.read_rom(f"{self.bin_dir}/rom")
|
await self.read_rom(f"{self.bin_dir}/rom")
|
||||||
if pull_opt_rom:
|
if pull_opt_rom:
|
||||||
for dir in opt_dirs:
|
for dir in opt_dirs:
|
||||||
self.read_rom(f"{dir}/rom")
|
await self.read_rom(f"{dir}/rom")
|
||||||
|
|
||||||
def read_ram(self, ram_root_dir: str) -> None:
|
async def read_ram(self, ram_root_dir: str) -> None:
|
||||||
self.logger.info(f"Read RAM from {ram_root_dir}")
|
self.logger.info(f"Read RAM from {ram_root_dir}")
|
||||||
|
|
||||||
if path.exists(f"{ram_root_dir}/databank"):
|
if path.exists(f"{ram_root_dir}/databank"):
|
||||||
@@ -91,7 +91,7 @@ class DivaReader(BaseReader):
|
|||||||
f"Added shop item {split[x+0]}"
|
f"Added shop item {split[x+0]}"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.data.static.put_shop(
|
await self.data.static.put_shop(
|
||||||
self.version,
|
self.version,
|
||||||
split[x + 0],
|
split[x + 0],
|
||||||
split[x + 2],
|
split[x + 2],
|
||||||
@@ -109,7 +109,7 @@ class DivaReader(BaseReader):
|
|||||||
for x in range(0, len(split), 7):
|
for x in range(0, len(split), 7):
|
||||||
self.logger.info(f"Added item {split[x+0]}")
|
self.logger.info(f"Added item {split[x+0]}")
|
||||||
|
|
||||||
self.data.static.put_items(
|
await self.data.static.put_items(
|
||||||
self.version,
|
self.version,
|
||||||
split[x + 0],
|
split[x + 0],
|
||||||
split[x + 2],
|
split[x + 2],
|
||||||
@@ -123,7 +123,7 @@ class DivaReader(BaseReader):
|
|||||||
elif file.startswith("QuestInfo") and len(split) >= 9:
|
elif file.startswith("QuestInfo") and len(split) >= 9:
|
||||||
self.logger.info(f"Added quest {split[0]}")
|
self.logger.info(f"Added quest {split[0]}")
|
||||||
|
|
||||||
self.data.static.put_quests(
|
await self.data.static.put_quests(
|
||||||
self.version,
|
self.version,
|
||||||
split[0],
|
split[0],
|
||||||
split[6],
|
split[6],
|
||||||
@@ -141,7 +141,7 @@ class DivaReader(BaseReader):
|
|||||||
else:
|
else:
|
||||||
self.logger.warning(f"Databank folder not found in {ram_root_dir}, skipping")
|
self.logger.warning(f"Databank folder not found in {ram_root_dir}, skipping")
|
||||||
|
|
||||||
def read_rom(self, rom_root_dir: str) -> None:
|
async def read_rom(self, rom_root_dir: str) -> None:
|
||||||
self.logger.info(f"Read ROM from {rom_root_dir}")
|
self.logger.info(f"Read ROM from {rom_root_dir}")
|
||||||
pv_list: Dict[str, Dict] = {}
|
pv_list: Dict[str, Dict] = {}
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ class DivaReader(BaseReader):
|
|||||||
diff = pv_data["difficulty"]["easy"]["0"]["level"].split("_")
|
diff = pv_data["difficulty"]["easy"]["0"]["level"].split("_")
|
||||||
self.logger.info(f"Added song {song_id} chart 0")
|
self.logger.info(f"Added song {song_id} chart 0")
|
||||||
|
|
||||||
self.data.static.put_music(
|
await self.data.static.put_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
0,
|
0,
|
||||||
@@ -220,7 +220,7 @@ class DivaReader(BaseReader):
|
|||||||
diff = pv_data["difficulty"]["normal"]["0"]["level"].split("_")
|
diff = pv_data["difficulty"]["normal"]["0"]["level"].split("_")
|
||||||
self.logger.info(f"Added song {song_id} chart 1")
|
self.logger.info(f"Added song {song_id} chart 1")
|
||||||
|
|
||||||
self.data.static.put_music(
|
await self.data.static.put_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
1,
|
1,
|
||||||
@@ -238,7 +238,7 @@ class DivaReader(BaseReader):
|
|||||||
diff = pv_data["difficulty"]["hard"]["0"]["level"].split("_")
|
diff = pv_data["difficulty"]["hard"]["0"]["level"].split("_")
|
||||||
self.logger.info(f"Added song {song_id} chart 2")
|
self.logger.info(f"Added song {song_id} chart 2")
|
||||||
|
|
||||||
self.data.static.put_music(
|
await self.data.static.put_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
2,
|
2,
|
||||||
@@ -257,7 +257,7 @@ class DivaReader(BaseReader):
|
|||||||
diff = pv_data["difficulty"]["extreme"]["0"]["level"].split("_")
|
diff = pv_data["difficulty"]["extreme"]["0"]["level"].split("_")
|
||||||
self.logger.info(f"Added song {song_id} chart 3")
|
self.logger.info(f"Added song {song_id} chart 3")
|
||||||
|
|
||||||
self.data.static.put_music(
|
await self.data.static.put_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
3,
|
3,
|
||||||
@@ -275,7 +275,7 @@ class DivaReader(BaseReader):
|
|||||||
diff = pv_data["difficulty"]["extreme"]["1"]["level"].split("_")
|
diff = pv_data["difficulty"]["extreme"]["1"]["level"].split("_")
|
||||||
self.logger.info(f"Added song {song_id} chart 4")
|
self.logger.info(f"Added song {song_id} chart 4")
|
||||||
|
|
||||||
self.data.static.put_music(
|
await self.data.static.put_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
4,
|
4,
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ customize = Table(
|
|||||||
|
|
||||||
|
|
||||||
class DivaCustomizeItemData(BaseData):
|
class DivaCustomizeItemData(BaseData):
|
||||||
def put_customize_item(self, aime_id: int, version: int, item_id: int) -> None:
|
async def put_customize_item(self, aime_id: int, version: int, item_id: int) -> None:
|
||||||
sql = insert(customize).values(version=version, user=aime_id, item_id=item_id)
|
sql = insert(customize).values(version=version, user=aime_id, item_id=item_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} Failed to insert diva profile customize item! aime id: {aime_id} item: {item_id}"
|
f"{__name__} Failed to insert diva profile customize item! aime id: {aime_id} item: {item_id}"
|
||||||
@@ -36,7 +36,7 @@ class DivaCustomizeItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_customize_items(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
async def get_customize_items(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
||||||
"""
|
"""
|
||||||
Given a game version and an aime id, return all the customize items, not used directly
|
Given a game version and an aime id, return all the customize items, not used directly
|
||||||
"""
|
"""
|
||||||
@@ -44,12 +44,12 @@ class DivaCustomizeItemData(BaseData):
|
|||||||
and_(customize.c.version == version, customize.c.user == aime_id)
|
and_(customize.c.version == version, customize.c.user == aime_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_customize_items_have_string(self, aime_id: int, version: int) -> str:
|
async def get_customize_items_have_string(self, aime_id: int, version: int) -> str:
|
||||||
"""
|
"""
|
||||||
Given a game version and an aime id, return the cstmz_itm_have hex string
|
Given a game version and an aime id, return the cstmz_itm_have hex string
|
||||||
required for diva directly
|
required for diva directly
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ shop = Table(
|
|||||||
|
|
||||||
|
|
||||||
class DivaItemData(BaseData):
|
class DivaItemData(BaseData):
|
||||||
def put_shop(
|
async def put_shop(
|
||||||
self,
|
self,
|
||||||
aime_id: int,
|
aime_id: int,
|
||||||
version: int,
|
version: int,
|
||||||
@@ -48,7 +48,7 @@ class DivaItemData(BaseData):
|
|||||||
ms_itm_flg_ary=ms_itm_flg_ary,
|
ms_itm_flg_ary=ms_itm_flg_ary,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} Failed to insert diva profile! aime id: {aime_id} array: {mdl_eqp_ary}"
|
f"{__name__} Failed to insert diva profile! aime id: {aime_id} array: {mdl_eqp_ary}"
|
||||||
@@ -56,13 +56,13 @@ class DivaItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_shop(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
async def get_shop(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
||||||
"""
|
"""
|
||||||
Given a game version and either a profile or aime id, return the profile
|
Given a game version and either a profile or aime id, return the profile
|
||||||
"""
|
"""
|
||||||
sql = shop.select(and_(shop.c.version == version, shop.c.user == aime_id))
|
sql = shop.select(and_(shop.c.version == version, shop.c.user == aime_id))
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ module = Table(
|
|||||||
|
|
||||||
|
|
||||||
class DivaModuleData(BaseData):
|
class DivaModuleData(BaseData):
|
||||||
def put_module(self, aime_id: int, version: int, module_id: int) -> None:
|
async def put_module(self, aime_id: int, version: int, module_id: int) -> None:
|
||||||
sql = insert(module).values(version=version, user=aime_id, module_id=module_id)
|
sql = insert(module).values(version=version, user=aime_id, module_id=module_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} Failed to insert diva profile module! aime id: {aime_id} module: {module_id}"
|
f"{__name__} Failed to insert diva profile module! aime id: {aime_id} module: {module_id}"
|
||||||
@@ -34,18 +34,18 @@ class DivaModuleData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_modules(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
async def get_modules(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
||||||
"""
|
"""
|
||||||
Given a game version and an aime id, return all the modules, not used directly
|
Given a game version and an aime id, return all the modules, not used directly
|
||||||
"""
|
"""
|
||||||
sql = module.select(and_(module.c.version == version, module.c.user == aime_id))
|
sql = module.select(and_(module.c.version == version, module.c.user == aime_id))
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_modules_have_string(self, aime_id: int, version: int) -> str:
|
async def get_modules_have_string(self, aime_id: int, version: int) -> str:
|
||||||
"""
|
"""
|
||||||
Given a game version and an aime id, return the mdl_have hex string
|
Given a game version and an aime id, return the mdl_have hex string
|
||||||
required for diva directly
|
required for diva directly
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ profile = Table(
|
|||||||
|
|
||||||
|
|
||||||
class DivaProfileData(BaseData):
|
class DivaProfileData(BaseData):
|
||||||
def create_profile(
|
async def create_profile(
|
||||||
self, version: int, aime_id: int, player_name: str
|
self, version: int, aime_id: int, player_name: str
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
"""
|
"""
|
||||||
@@ -82,7 +82,7 @@ class DivaProfileData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(player_name=sql.inserted.player_name)
|
conflict = sql.on_duplicate_key_update(player_name=sql.inserted.player_name)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} Failed to insert diva profile! aime id: {aime_id} username: {player_name}"
|
f"{__name__} Failed to insert diva profile! aime id: {aime_id} username: {player_name}"
|
||||||
@@ -90,21 +90,21 @@ class DivaProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def update_profile(self, aime_id: int, **profile_args) -> None:
|
async def update_profile(self, aime_id: int, **profile_args) -> None:
|
||||||
"""
|
"""
|
||||||
Given an aime_id update the profile corresponding to the arguments
|
Given an aime_id update the profile corresponding to the arguments
|
||||||
which are the diva_profile Columns
|
which are the diva_profile Columns
|
||||||
"""
|
"""
|
||||||
sql = profile.update(profile.c.user == aime_id).values(**profile_args)
|
sql = profile.update(profile.c.user == aime_id).values(**profile_args)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"update_profile: failed to update profile! profile: {aime_id}"
|
f"update_profile: failed to update profile! profile: {aime_id}"
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_profile(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
async def get_profile(self, aime_id: int, version: int) -> Optional[List[Dict]]:
|
||||||
"""
|
"""
|
||||||
Given a game version and either a profile or aime id, return the profile
|
Given a game version and either a profile or aime id, return the profile
|
||||||
"""
|
"""
|
||||||
@@ -112,7 +112,7 @@ class DivaProfileData(BaseData):
|
|||||||
and_(profile.c.version == version, profile.c.user == aime_id)
|
and_(profile.c.version == version, profile.c.user == aime_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ pv_customize = Table(
|
|||||||
|
|
||||||
|
|
||||||
class DivaPvCustomizeData(BaseData):
|
class DivaPvCustomizeData(BaseData):
|
||||||
def put_pv_customize(
|
async def put_pv_customize(
|
||||||
self,
|
self,
|
||||||
aime_id: int,
|
aime_id: int,
|
||||||
version: int,
|
version: int,
|
||||||
@@ -64,7 +64,7 @@ class DivaPvCustomizeData(BaseData):
|
|||||||
ms_itm_flg_ary=ms_itm_flg_ary,
|
ms_itm_flg_ary=ms_itm_flg_ary,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} Failed to insert diva pv customize! aime id: {aime_id}"
|
f"{__name__} Failed to insert diva pv customize! aime id: {aime_id}"
|
||||||
@@ -72,7 +72,7 @@ class DivaPvCustomizeData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_pv_customize(self, aime_id: int, pv_id: int) -> Optional[List[Dict]]:
|
async def get_pv_customize(self, aime_id: int, pv_id: int) -> Optional[List[Dict]]:
|
||||||
"""
|
"""
|
||||||
Given either a profile or aime id, return a Pv Customize row
|
Given either a profile or aime id, return a Pv Customize row
|
||||||
"""
|
"""
|
||||||
@@ -80,7 +80,7 @@ class DivaPvCustomizeData(BaseData):
|
|||||||
and_(pv_customize.c.user == aime_id, pv_customize.c.pv_id == pv_id)
|
and_(pv_customize.c.user == aime_id, pv_customize.c.pv_id == pv_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|||||||
+12
-12
@@ -57,7 +57,7 @@ playlog = Table(
|
|||||||
|
|
||||||
|
|
||||||
class DivaScoreData(BaseData):
|
class DivaScoreData(BaseData):
|
||||||
def put_best_score(
|
async def put_best_score(
|
||||||
self,
|
self,
|
||||||
user_id: int,
|
user_id: int,
|
||||||
game_version: int,
|
game_version: int,
|
||||||
@@ -109,7 +109,7 @@ class DivaScoreData(BaseData):
|
|||||||
max_combo=max_combo,
|
max_combo=max_combo,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} failed to insert best score! profile: {user_id}, song: {song_id}"
|
f"{__name__} failed to insert best score! profile: {user_id}, song: {song_id}"
|
||||||
@@ -118,7 +118,7 @@ class DivaScoreData(BaseData):
|
|||||||
|
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_playlog(
|
async def put_playlog(
|
||||||
self,
|
self,
|
||||||
user_id: int,
|
user_id: int,
|
||||||
game_version: int,
|
game_version: int,
|
||||||
@@ -157,7 +157,7 @@ class DivaScoreData(BaseData):
|
|||||||
max_combo=max_combo,
|
max_combo=max_combo,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"{__name__} failed to insert playlog! profile: {user_id}, song: {song_id}, chart: {difficulty}"
|
f"{__name__} failed to insert playlog! profile: {user_id}, song: {song_id}, chart: {difficulty}"
|
||||||
@@ -166,7 +166,7 @@ class DivaScoreData(BaseData):
|
|||||||
|
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_best_user_score(
|
async def get_best_user_score(
|
||||||
self, user_id: int, pv_id: int, difficulty: int, edition: int
|
self, user_id: int, pv_id: int, difficulty: int, edition: int
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
sql = score.select(
|
sql = score.select(
|
||||||
@@ -178,12 +178,12 @@ class DivaScoreData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_top3_scores(
|
async def get_top3_scores(
|
||||||
self, pv_id: int, difficulty: int, edition: int
|
self, pv_id: int, difficulty: int, edition: int
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = (
|
sql = (
|
||||||
@@ -198,12 +198,12 @@ class DivaScoreData(BaseData):
|
|||||||
.limit(3)
|
.limit(3)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_global_ranking(
|
async def get_global_ranking(
|
||||||
self, user_id: int, pv_id: int, difficulty: int, edition: int
|
self, user_id: int, pv_id: int, difficulty: int, edition: int
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
# get the subquery max score of a user with pv_id, difficulty and
|
# get the subquery max score of a user with pv_id, difficulty and
|
||||||
@@ -227,15 +227,15 @@ class DivaScoreData(BaseData):
|
|||||||
score.c.edition == edition,
|
score.c.edition == edition,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
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 = score.select(score.c.user == user_id)
|
sql = score.select(score.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ items = Table(
|
|||||||
|
|
||||||
|
|
||||||
class DivaStaticData(BaseData):
|
class DivaStaticData(BaseData):
|
||||||
def put_quests(
|
async def put_quests(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
questId: int,
|
questId: int,
|
||||||
@@ -111,22 +111,22 @@ class DivaStaticData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(name=name)
|
conflict = sql.on_duplicate_key_update(name=name)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_enabled_quests(self, version: int) -> Optional[List[Row]]:
|
async def get_enabled_quests(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = select(quests).where(
|
sql = select(quests).where(
|
||||||
and_(quests.c.version == version, quests.c.quest_enable == True)
|
and_(quests.c.version == version, quests.c.quest_enable == True)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_shop(
|
async def put_shop(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
shopId: int,
|
shopId: int,
|
||||||
@@ -150,12 +150,12 @@ class DivaStaticData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(name=name)
|
conflict = sql.on_duplicate_key_update(name=name)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_enabled_shop(self, version: int, shopId: int) -> Optional[Row]:
|
async def get_enabled_shop(self, version: int, shopId: int) -> Optional[Row]:
|
||||||
sql = select(shop).where(
|
sql = select(shop).where(
|
||||||
and_(
|
and_(
|
||||||
shop.c.version == version,
|
shop.c.version == version,
|
||||||
@@ -164,22 +164,22 @@ class DivaStaticData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_enabled_shops(self, version: int) -> Optional[List[Row]]:
|
async def get_enabled_shops(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = select(shop).where(
|
sql = select(shop).where(
|
||||||
and_(shop.c.version == version, shop.c.enabled == True)
|
and_(shop.c.version == version, shop.c.enabled == True)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_items(
|
async def put_items(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
itemId: int,
|
itemId: int,
|
||||||
@@ -203,12 +203,12 @@ class DivaStaticData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(name=name)
|
conflict = sql.on_duplicate_key_update(name=name)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_enabled_item(self, version: int, itemId: int) -> Optional[Row]:
|
async def get_enabled_item(self, version: int, itemId: int) -> Optional[Row]:
|
||||||
sql = select(items).where(
|
sql = select(items).where(
|
||||||
and_(
|
and_(
|
||||||
items.c.version == version,
|
items.c.version == version,
|
||||||
@@ -217,22 +217,22 @@ class DivaStaticData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_enabled_items(self, version: int) -> Optional[List[Row]]:
|
async def get_enabled_items(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = select(items).where(
|
sql = select(items).where(
|
||||||
and_(items.c.version == version, items.c.enabled == True)
|
and_(items.c.version == version, items.c.enabled == True)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_music(
|
async def put_music(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
song: int,
|
song: int,
|
||||||
@@ -271,12 +271,12 @@ class DivaStaticData(BaseData):
|
|||||||
date=date,
|
date=date,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_music(
|
async def get_music(
|
||||||
self, version: int, song_id: Optional[int] = None
|
self, version: int, song_id: Optional[int] = None
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
if song_id is None:
|
if song_id is None:
|
||||||
@@ -289,12 +289,12 @@ class DivaStaticData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_music_chart(
|
async def get_music_chart(
|
||||||
self, version: int, song_id: int, chart_id: int
|
self, version: int, song_id: int, chart_id: int
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = select(music).where(
|
sql = select(music).where(
|
||||||
@@ -305,7 +305,7 @@ class DivaStaticData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|||||||
+7
-10
@@ -37,7 +37,7 @@ class IDACFrontend(FE_Base):
|
|||||||
34: "full_tune_fragments",
|
34: "full_tune_fragments",
|
||||||
}
|
}
|
||||||
|
|
||||||
def generate_all_tables_json(self, user_id: int):
|
async def generate_all_tables_json(self, user_id: int):
|
||||||
json_export = {}
|
json_export = {}
|
||||||
|
|
||||||
idac_tables = {
|
idac_tables = {
|
||||||
@@ -73,7 +73,7 @@ class IDACFrontend(FE_Base):
|
|||||||
sql = sql.where(table.c.version == self.version)
|
sql = sql.where(table.c.version == self.version)
|
||||||
|
|
||||||
# lol use the profile connection for items, dirty hack
|
# lol use the profile connection for items, dirty hack
|
||||||
result = self.data.profile.execute(sql)
|
result = await self.data.profile.execute(sql)
|
||||||
data_list = result.fetchall()
|
data_list = result.fetchall()
|
||||||
|
|
||||||
# add the list to the json export with the correct table name
|
# add the list to the json export with the correct table name
|
||||||
@@ -86,7 +86,7 @@ class IDACFrontend(FE_Base):
|
|||||||
|
|
||||||
return json.dumps(json_export, indent=4, default=str, ensure_ascii=False)
|
return json.dumps(json_export, indent=4, default=str, ensure_ascii=False)
|
||||||
|
|
||||||
def render_GET(self, request: Request) -> bytes:
|
async def render_GET(self, request: Request) -> bytes:
|
||||||
uri: str = request.uri.decode()
|
uri: str = request.uri.decode()
|
||||||
|
|
||||||
template = self.environment.get_template(
|
template = self.environment.get_template(
|
||||||
@@ -103,7 +103,7 @@ class IDACFrontend(FE_Base):
|
|||||||
return redirectTo(b"/game/idac", request)
|
return redirectTo(b"/game/idac", request)
|
||||||
|
|
||||||
# set the file name, content type and size to download the json
|
# set the file name, content type and size to download the json
|
||||||
content = self.generate_all_tables_json(user_id).encode("utf-8")
|
content = await self.generate_all_tables_json(user_id).encode("utf-8")
|
||||||
request.responseHeaders.addRawHeader(
|
request.responseHeaders.addRawHeader(
|
||||||
b"content-type", b"application/octet-stream"
|
b"content-type", b"application/octet-stream"
|
||||||
)
|
)
|
||||||
@@ -119,9 +119,9 @@ class IDACFrontend(FE_Base):
|
|||||||
|
|
||||||
profile_data, tickets, rank = None, None, None
|
profile_data, tickets, rank = None, None, None
|
||||||
if user_id > 0:
|
if user_id > 0:
|
||||||
profile_data = self.data.profile.get_profile(user_id, self.version)
|
profile_data = await self.data.profile.get_profile(user_id, self.version)
|
||||||
ticket_data = self.data.item.get_tickets(user_id)
|
ticket_data = await self.data.item.get_tickets(user_id)
|
||||||
rank = self.data.profile.get_profile_rank(user_id, self.version)
|
rank = await self.data.profile.get_profile_rank(user_id, self.version)
|
||||||
|
|
||||||
tickets = {
|
tickets = {
|
||||||
self.ticket_names[ticket["ticket_id"]]: ticket["ticket_cnt"]
|
self.ticket_names[ticket["ticket_id"]]: ticket["ticket_cnt"]
|
||||||
@@ -137,6 +137,3 @@ class IDACFrontend(FE_Base):
|
|||||||
sesh=vars(usr_sesh),
|
sesh=vars(usr_sesh),
|
||||||
active_page="idac",
|
active_page="idac",
|
||||||
).encode("utf-16")
|
).encode("utf-16")
|
||||||
|
|
||||||
def render_POST(self, request: Request) -> bytes:
|
|
||||||
pass
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class IDACServlet(BaseServlet):
|
|||||||
resp = None
|
resp = None
|
||||||
try:
|
try:
|
||||||
handler = getattr(self.versions[internal_ver], func_to_find)
|
handler = getattr(self.versions[internal_ver], func_to_find)
|
||||||
resp = handler(req_data, header_application)
|
resp = await handler(req_data, header_application)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|||||||
+6
-6
@@ -33,7 +33,7 @@ class IDACReader(BaseReader):
|
|||||||
self.logger.error(f"Invalid Initial D THE ARCADE version {version}")
|
self.logger.error(f"Invalid Initial D THE ARCADE version {version}")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def read(self) -> None:
|
async def read(self) -> None:
|
||||||
if self.bin_dir is None and self.opt_dir is None:
|
if self.bin_dir is None and self.opt_dir is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
(
|
(
|
||||||
@@ -59,9 +59,9 @@ class IDACReader(BaseReader):
|
|||||||
)
|
)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
self.read_idac_profile(self.opt_dir)
|
await self.read_idac_profile(self.opt_dir)
|
||||||
|
|
||||||
def read_idac_profile(self, file_path: str) -> None:
|
async def read_idac_profile(self, file_path: str) -> None:
|
||||||
self.logger.info(f"Reading profile from {file_path}...")
|
self.logger.info(f"Reading profile from {file_path}...")
|
||||||
|
|
||||||
# read it as binary to avoid encoding issues
|
# read it as binary to avoid encoding issues
|
||||||
@@ -88,14 +88,14 @@ class IDACReader(BaseReader):
|
|||||||
self.logger.info("Exiting...")
|
self.logger.info("Exiting...")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
user_id = self.data.user.create_user()
|
user_id = await self.data.user.create_user()
|
||||||
|
|
||||||
if user_id is None:
|
if user_id is None:
|
||||||
self.logger.error("Failed to register user!")
|
self.logger.error("Failed to register user!")
|
||||||
user_id = -1
|
user_id = -1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
card_id = self.data.card.create_card(user_id, access_code)
|
card_id = await self.data.card.create_card(user_id, access_code)
|
||||||
|
|
||||||
if card_id is None:
|
if card_id is None:
|
||||||
self.logger.error("Failed to register card!")
|
self.logger.error("Failed to register card!")
|
||||||
@@ -150,7 +150,7 @@ class IDACReader(BaseReader):
|
|||||||
|
|
||||||
# lol use the profile connection for items, dirty hack
|
# lol use the profile connection for items, dirty hack
|
||||||
conflict = sql.on_duplicate_key_update(**data)
|
conflict = sql.on_duplicate_key_update(**data)
|
||||||
result = self.data.profile.execute(conflict)
|
result = await self.data.profile.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(f"Failed to insert data into table {name}")
|
self.logger.error(f"Failed to insert data into table {name}")
|
||||||
|
|||||||
+92
-92
@@ -297,7 +297,7 @@ timetrial_event = Table(
|
|||||||
|
|
||||||
|
|
||||||
class IDACItemData(BaseData):
|
class IDACItemData(BaseData):
|
||||||
def get_random_user_car(self, aime_id: int, version: int) -> Optional[List[Row]]:
|
async def get_random_user_car(self, aime_id: int, version: int) -> Optional[List[Row]]:
|
||||||
sql = (
|
sql = (
|
||||||
select(car)
|
select(car)
|
||||||
.where(and_(car.c.user == aime_id, car.c.version == version))
|
.where(and_(car.c.user == aime_id, car.c.version == version))
|
||||||
@@ -305,20 +305,20 @@ class IDACItemData(BaseData):
|
|||||||
.limit(1)
|
.limit(1)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_random_car(self, version: int) -> Optional[List[Row]]:
|
async def get_random_car(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = select(car).where(car.c.version == version).order_by(func.rand()).limit(1)
|
sql = select(car).where(car.c.version == version).order_by(func.rand()).limit(1)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_car(
|
async def get_car(
|
||||||
self, aime_id: int, version: int, style_car_id: int
|
self, aime_id: int, version: int, style_car_id: int
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = select(car).where(
|
sql = select(car).where(
|
||||||
@@ -329,12 +329,12 @@ class IDACItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_cars(
|
async def get_cars(
|
||||||
self, version: int, aime_id: int, only_pickup: bool = False
|
self, version: int, aime_id: int, only_pickup: bool = False
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
if only_pickup:
|
if only_pickup:
|
||||||
@@ -350,106 +350,106 @@ class IDACItemData(BaseData):
|
|||||||
and_(car.c.user == aime_id, car.c.version == version)
|
and_(car.c.user == aime_id, car.c.version == version)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_ticket(self, aime_id: int, ticket_id: int) -> Optional[Row]:
|
async def get_ticket(self, aime_id: int, ticket_id: int) -> Optional[Row]:
|
||||||
sql = select(ticket).where(
|
sql = select(ticket).where(
|
||||||
ticket.c.user == aime_id, ticket.c.ticket_id == ticket_id
|
ticket.c.user == aime_id, ticket.c.ticket_id == ticket_id
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_tickets(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_tickets(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(ticket).where(ticket.c.user == aime_id)
|
sql = select(ticket).where(ticket.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_story(self, aime_id: int, chapter_id: int) -> Optional[Row]:
|
async def get_story(self, aime_id: int, chapter_id: int) -> Optional[Row]:
|
||||||
sql = select(story).where(
|
sql = select(story).where(
|
||||||
and_(story.c.user == aime_id, story.c.chapter == chapter_id)
|
and_(story.c.user == aime_id, story.c.chapter == chapter_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_stories(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_stories(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(story).where(story.c.user == aime_id)
|
sql = select(story).where(story.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_story_episodes(self, aime_id: int, chapter_id: int) -> Optional[List[Row]]:
|
async def get_story_episodes(self, aime_id: int, chapter_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(episode).where(
|
sql = select(episode).where(
|
||||||
and_(episode.c.user == aime_id, episode.c.chapter == chapter_id)
|
and_(episode.c.user == aime_id, episode.c.chapter == chapter_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_story_episode(self, aime_id: int, episode_id: int) -> Optional[Row]:
|
async def get_story_episode(self, aime_id: int, episode_id: int) -> Optional[Row]:
|
||||||
sql = select(episode).where(
|
sql = select(episode).where(
|
||||||
and_(episode.c.user == aime_id, episode.c.episode == episode_id)
|
and_(episode.c.user == aime_id, episode.c.episode == episode_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_story_episode_difficulties(
|
async def get_story_episode_difficulties(
|
||||||
self, aime_id: int, episode_id: int
|
self, aime_id: int, episode_id: int
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = select(difficulty).where(
|
sql = select(difficulty).where(
|
||||||
and_(difficulty.c.user == aime_id, difficulty.c.episode == episode_id)
|
and_(difficulty.c.user == aime_id, difficulty.c.episode == episode_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_courses(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_courses(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(course).where(course.c.user == aime_id)
|
sql = select(course).where(course.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_course(self, aime_id: int, course_id: int) -> Optional[Row]:
|
async def get_course(self, aime_id: int, course_id: int) -> Optional[Row]:
|
||||||
sql = select(course).where(
|
sql = select(course).where(
|
||||||
and_(course.c.user == aime_id, course.c.course_id == course_id)
|
and_(course.c.user == aime_id, course.c.course_id == course_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_time_trial_courses(self, version: int) -> Optional[List[Row]]:
|
async def get_time_trial_courses(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = select(trial.c.course_id).where(trial.c.version == version).distinct()
|
sql = select(trial.c.course_id).where(trial.c.version == version).distinct()
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_time_trial_user_best_time_by_course_car(
|
async def get_time_trial_user_best_time_by_course_car(
|
||||||
self, version: int, aime_id: int, course_id: int, style_car_id: int
|
self, version: int, aime_id: int, course_id: int, style_car_id: int
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
sql = select(trial).where(
|
sql = select(trial).where(
|
||||||
@@ -461,12 +461,12 @@ class IDACItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_time_trial_user_best_courses(
|
async def get_time_trial_user_best_courses(
|
||||||
self, version: int, aime_id: int
|
self, version: int, aime_id: int
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
# get for a given aime_id the best time for each course
|
# get for a given aime_id the best time for each course
|
||||||
@@ -491,12 +491,12 @@ class IDACItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_time_trial_best_cars_by_course(
|
async def get_time_trial_best_cars_by_course(
|
||||||
self, version: int, course_id: int, aime_id: Optional[int] = None
|
self, version: int, course_id: int, aime_id: Optional[int] = None
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
subquery = (
|
subquery = (
|
||||||
@@ -527,12 +527,12 @@ class IDACItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_time_trial_ranking_by_course(
|
async def get_time_trial_ranking_by_course(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
course_id: int,
|
course_id: int,
|
||||||
@@ -568,12 +568,12 @@ class IDACItemData(BaseData):
|
|||||||
if limit is not None:
|
if limit is not None:
|
||||||
sql = sql.limit(limit)
|
sql = sql.limit(limit)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_time_trial_best_ranking_by_course(
|
async def get_time_trial_best_ranking_by_course(
|
||||||
self, version: int, aime_id: int, course_id: int
|
self, version: int, aime_id: int, course_id: int
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
sql = (
|
sql = (
|
||||||
@@ -589,12 +589,12 @@ class IDACItemData(BaseData):
|
|||||||
.limit(1)
|
.limit(1)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_challenge(
|
async def get_challenge(
|
||||||
self, aime_id: int, vs_type: int, play_difficulty: int
|
self, aime_id: int, vs_type: int, play_difficulty: int
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
sql = select(challenge).where(
|
sql = select(challenge).where(
|
||||||
@@ -605,20 +605,20 @@ class IDACItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_challenges(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_challenges(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(challenge).where(challenge.c.user == aime_id)
|
sql = select(challenge).where(challenge.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_best_challenges_by_vs_type(
|
async def get_best_challenges_by_vs_type(
|
||||||
self, aime_id: int, story_type: int = 4
|
self, aime_id: int, story_type: int = 4
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
subquery = (
|
subquery = (
|
||||||
@@ -653,20 +653,20 @@ class IDACItemData(BaseData):
|
|||||||
.order_by(challenge.c.vs_type)
|
.order_by(challenge.c.vs_type)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_theory_courses(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_theory_courses(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(theory_course).where(theory_course.c.user == aime_id)
|
sql = select(theory_course).where(theory_course.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_theory_course_by_powerhouse_lv(
|
async def get_theory_course_by_powerhouse_lv(
|
||||||
self, aime_id: int, course_id: int, powerhouse_lv: int, count: int = 3
|
self, aime_id: int, course_id: int, powerhouse_lv: int, count: int = 3
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = (
|
sql = (
|
||||||
@@ -682,40 +682,40 @@ class IDACItemData(BaseData):
|
|||||||
.limit(count)
|
.limit(count)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_theory_course(self, aime_id: int, course_id: int) -> Optional[List[Row]]:
|
async def get_theory_course(self, aime_id: int, course_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(theory_course).where(
|
sql = select(theory_course).where(
|
||||||
and_(
|
and_(
|
||||||
theory_course.c.user == aime_id, theory_course.c.course_id == course_id
|
theory_course.c.user == aime_id, theory_course.c.course_id == course_id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_theory_partners(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_theory_partners(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(theory_partner).where(theory_partner.c.user == aime_id)
|
sql = select(theory_partner).where(theory_partner.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_theory_running(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_theory_running(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(theory_running).where(theory_running.c.user == aime_id)
|
sql = select(theory_running).where(theory_running.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_theory_running_by_course(
|
async def get_theory_running_by_course(
|
||||||
self, aime_id: int, course_id: int
|
self, aime_id: int, course_id: int
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
sql = select(theory_running).where(
|
sql = select(theory_running).where(
|
||||||
@@ -725,32 +725,32 @@ class IDACItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_vs_infos(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_vs_infos(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(vs_info).where(vs_info.c.user == aime_id)
|
sql = select(vs_info).where(vs_info.c.user == aime_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_stamps(self, aime_id: int) -> Optional[List[Row]]:
|
async def get_stamps(self, aime_id: int) -> Optional[List[Row]]:
|
||||||
sql = select(stamp).where(
|
sql = select(stamp).where(
|
||||||
and_(
|
and_(
|
||||||
stamp.c.user == aime_id,
|
stamp.c.user == aime_id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_timetrial_event(self, aime_id: int, timetrial_event_id: int) -> Optional[Row]:
|
async def get_timetrial_event(self, aime_id: int, timetrial_event_id: int) -> Optional[Row]:
|
||||||
sql = select(timetrial_event).where(
|
sql = select(timetrial_event).where(
|
||||||
and_(
|
and_(
|
||||||
timetrial_event.c.user == aime_id,
|
timetrial_event.c.user == aime_id,
|
||||||
@@ -758,49 +758,49 @@ class IDACItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_car(self, aime_id: int, version: int, car_data: Dict) -> Optional[int]:
|
async def put_car(self, aime_id: int, version: int, car_data: Dict) -> Optional[int]:
|
||||||
car_data["user"] = aime_id
|
car_data["user"] = aime_id
|
||||||
car_data["version"] = version
|
car_data["version"] = version
|
||||||
|
|
||||||
sql = insert(car).values(**car_data)
|
sql = insert(car).values(**car_data)
|
||||||
conflict = sql.on_duplicate_key_update(**car_data)
|
conflict = sql.on_duplicate_key_update(**car_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_car: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_car: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_ticket(self, aime_id: int, ticket_data: Dict) -> Optional[int]:
|
async def put_ticket(self, aime_id: int, ticket_data: Dict) -> Optional[int]:
|
||||||
ticket_data["user"] = aime_id
|
ticket_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(ticket).values(**ticket_data)
|
sql = insert(ticket).values(**ticket_data)
|
||||||
conflict = sql.on_duplicate_key_update(**ticket_data)
|
conflict = sql.on_duplicate_key_update(**ticket_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_ticket: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_ticket: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
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
|
story_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(story).values(**story_data)
|
sql = insert(story).values(**story_data)
|
||||||
conflict = sql.on_duplicate_key_update(**story_data)
|
conflict = sql.on_duplicate_key_update(**story_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_story: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_story: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_story_episode_play_status(
|
async def put_story_episode_play_status(
|
||||||
self, aime_id: int, chapter_id: int, play_status: int = 1
|
self, aime_id: int, chapter_id: int, play_status: int = 1
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = (
|
sql = (
|
||||||
@@ -809,7 +809,7 @@ class IDACItemData(BaseData):
|
|||||||
.values(play_status=play_status)
|
.values(play_status=play_status)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
f"put_story_episode_play_status: Failed to update! aime_id: {aime_id}"
|
f"put_story_episode_play_status: Failed to update! aime_id: {aime_id}"
|
||||||
@@ -817,7 +817,7 @@ class IDACItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_story_episode(
|
async def put_story_episode(
|
||||||
self, aime_id: int, chapter_id: int, episode_data: Dict
|
self, aime_id: int, chapter_id: int, episode_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
episode_data["user"] = aime_id
|
episode_data["user"] = aime_id
|
||||||
@@ -825,14 +825,14 @@ class IDACItemData(BaseData):
|
|||||||
|
|
||||||
sql = insert(episode).values(**episode_data)
|
sql = insert(episode).values(**episode_data)
|
||||||
conflict = sql.on_duplicate_key_update(**episode_data)
|
conflict = sql.on_duplicate_key_update(**episode_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_story_episode: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_story_episode: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_story_episode_difficulty(
|
async def put_story_episode_difficulty(
|
||||||
self, aime_id: int, episode_id: int, difficulty_data: Dict
|
self, aime_id: int, episode_id: int, difficulty_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
difficulty_data["user"] = aime_id
|
difficulty_data["user"] = aime_id
|
||||||
@@ -840,7 +840,7 @@ class IDACItemData(BaseData):
|
|||||||
|
|
||||||
sql = insert(difficulty).values(**difficulty_data)
|
sql = insert(difficulty).values(**difficulty_data)
|
||||||
conflict = sql.on_duplicate_key_update(**difficulty_data)
|
conflict = sql.on_duplicate_key_update(**difficulty_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
@@ -849,19 +849,19 @@ class IDACItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_course(self, aime_id: int, course_data: Dict) -> Optional[int]:
|
async def put_course(self, aime_id: int, course_data: Dict) -> Optional[int]:
|
||||||
course_data["user"] = aime_id
|
course_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(course).values(**course_data)
|
sql = insert(course).values(**course_data)
|
||||||
conflict = sql.on_duplicate_key_update(**course_data)
|
conflict = sql.on_duplicate_key_update(**course_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_course: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_course: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_time_trial(
|
async def put_time_trial(
|
||||||
self, version: int, aime_id: int, time_trial_data: Dict
|
self, version: int, aime_id: int, time_trial_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
time_trial_data["user"] = aime_id
|
time_trial_data["user"] = aime_id
|
||||||
@@ -869,47 +869,47 @@ class IDACItemData(BaseData):
|
|||||||
|
|
||||||
sql = insert(trial).values(**time_trial_data)
|
sql = insert(trial).values(**time_trial_data)
|
||||||
conflict = sql.on_duplicate_key_update(**time_trial_data)
|
conflict = sql.on_duplicate_key_update(**time_trial_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_time_trial: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_time_trial: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_challenge(self, aime_id: int, challenge_data: Dict) -> Optional[int]:
|
async def put_challenge(self, aime_id: int, challenge_data: Dict) -> Optional[int]:
|
||||||
challenge_data["user"] = aime_id
|
challenge_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(challenge).values(**challenge_data)
|
sql = insert(challenge).values(**challenge_data)
|
||||||
conflict = sql.on_duplicate_key_update(**challenge_data)
|
conflict = sql.on_duplicate_key_update(**challenge_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_challenge: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_challenge: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_theory_course(
|
async def put_theory_course(
|
||||||
self, aime_id: int, theory_course_data: Dict
|
self, aime_id: int, theory_course_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
theory_course_data["user"] = aime_id
|
theory_course_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(theory_course).values(**theory_course_data)
|
sql = insert(theory_course).values(**theory_course_data)
|
||||||
conflict = sql.on_duplicate_key_update(**theory_course_data)
|
conflict = sql.on_duplicate_key_update(**theory_course_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_theory_course: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_theory_course: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_theory_partner(
|
async def put_theory_partner(
|
||||||
self, aime_id: int, theory_partner_data: Dict
|
self, aime_id: int, theory_partner_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
theory_partner_data["user"] = aime_id
|
theory_partner_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(theory_partner).values(**theory_partner_data)
|
sql = insert(theory_partner).values(**theory_partner_data)
|
||||||
conflict = sql.on_duplicate_key_update(**theory_partner_data)
|
conflict = sql.on_duplicate_key_update(**theory_partner_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
@@ -918,14 +918,14 @@ class IDACItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_theory_running(
|
async def put_theory_running(
|
||||||
self, aime_id: int, theory_running_data: Dict
|
self, aime_id: int, theory_running_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
theory_running_data["user"] = aime_id
|
theory_running_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(theory_running).values(**theory_running_data)
|
sql = insert(theory_running).values(**theory_running_data)
|
||||||
conflict = sql.on_duplicate_key_update(**theory_running_data)
|
conflict = sql.on_duplicate_key_update(**theory_running_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
@@ -934,26 +934,26 @@ class IDACItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_vs_info(self, aime_id: int, vs_info_data: Dict) -> Optional[int]:
|
async def put_vs_info(self, aime_id: int, vs_info_data: Dict) -> Optional[int]:
|
||||||
vs_info_data["user"] = aime_id
|
vs_info_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(vs_info).values(**vs_info_data)
|
sql = insert(vs_info).values(**vs_info_data)
|
||||||
conflict = sql.on_duplicate_key_update(**vs_info_data)
|
conflict = sql.on_duplicate_key_update(**vs_info_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_vs_info: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_vs_info: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_stamp(
|
async def put_stamp(
|
||||||
self, aime_id: int, stamp_data: Dict
|
self, aime_id: int, stamp_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
stamp_data["user"] = aime_id
|
stamp_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(stamp).values(**stamp_data)
|
sql = insert(stamp).values(**stamp_data)
|
||||||
conflict = sql.on_duplicate_key_update(**stamp_data)
|
conflict = sql.on_duplicate_key_update(**stamp_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
@@ -962,7 +962,7 @@ class IDACItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_timetrial_event(
|
async def put_timetrial_event(
|
||||||
self, aime_id: int, time_trial_event_id: int, point: int
|
self, aime_id: int, time_trial_event_id: int, point: int
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
timetrial_event_data = {
|
timetrial_event_data = {
|
||||||
@@ -973,7 +973,7 @@ class IDACItemData(BaseData):
|
|||||||
|
|
||||||
sql = insert(timetrial_event).values(**timetrial_event_data)
|
sql = insert(timetrial_event).values(**timetrial_event_data)
|
||||||
conflict = sql.on_duplicate_key_update(**timetrial_event_data)
|
conflict = sql.on_duplicate_key_update(**timetrial_event_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ class IDACProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
self.date_time_format_short = "%Y-%m-%d"
|
self.date_time_format_short = "%Y-%m-%d"
|
||||||
|
|
||||||
def get_profile(self, aime_id: int, version: int) -> Optional[Row]:
|
async def get_profile(self, aime_id: int, version: int) -> Optional[Row]:
|
||||||
sql = select(profile).where(
|
sql = select(profile).where(
|
||||||
and_(
|
and_(
|
||||||
profile.c.user == aime_id,
|
profile.c.user == aime_id,
|
||||||
@@ -261,12 +261,12 @@ class IDACProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_different_random_profiles(
|
async def get_different_random_profiles(
|
||||||
self, aime_id: int, version: int, count: int = 9
|
self, aime_id: int, version: int, count: int = 9
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
sql = (
|
sql = (
|
||||||
@@ -281,36 +281,36 @@ class IDACProfileData(BaseData):
|
|||||||
.limit(count)
|
.limit(count)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_profile_config(self, aime_id: int) -> Optional[Row]:
|
async def get_profile_config(self, aime_id: int) -> Optional[Row]:
|
||||||
sql = select(config).where(
|
sql = select(config).where(
|
||||||
and_(
|
and_(
|
||||||
config.c.user == aime_id,
|
config.c.user == aime_id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_profile_avatar(self, aime_id: int) -> Optional[Row]:
|
async def get_profile_avatar(self, aime_id: int) -> Optional[Row]:
|
||||||
sql = select(avatar).where(
|
sql = select(avatar).where(
|
||||||
and_(
|
and_(
|
||||||
avatar.c.user == aime_id,
|
avatar.c.user == aime_id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_profile_rank(self, aime_id: int, version: int) -> Optional[Row]:
|
async def get_profile_rank(self, aime_id: int, version: int) -> Optional[Row]:
|
||||||
sql = select(rank).where(
|
sql = select(rank).where(
|
||||||
and_(
|
and_(
|
||||||
rank.c.user == aime_id,
|
rank.c.user == aime_id,
|
||||||
@@ -318,12 +318,12 @@ class IDACProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_profile_stock(self, aime_id: int, version: int) -> Optional[Row]:
|
async def get_profile_stock(self, aime_id: int, version: int) -> Optional[Row]:
|
||||||
sql = select(stock).where(
|
sql = select(stock).where(
|
||||||
and_(
|
and_(
|
||||||
stock.c.user == aime_id,
|
stock.c.user == aime_id,
|
||||||
@@ -331,12 +331,12 @@ class IDACProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_profile_theory(self, aime_id: int, version: int) -> Optional[Row]:
|
async def get_profile_theory(self, aime_id: int, version: int) -> Optional[Row]:
|
||||||
sql = select(theory).where(
|
sql = select(theory).where(
|
||||||
and_(
|
and_(
|
||||||
theory.c.user == aime_id,
|
theory.c.user == aime_id,
|
||||||
@@ -344,12 +344,12 @@ class IDACProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_profile(
|
async def put_profile(
|
||||||
self, aime_id: int, version: int, profile_data: Dict
|
self, aime_id: int, version: int, profile_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
profile_data["user"] = aime_id
|
profile_data["user"] = aime_id
|
||||||
@@ -357,19 +357,19 @@ class IDACProfileData(BaseData):
|
|||||||
|
|
||||||
sql = insert(profile).values(**profile_data)
|
sql = insert(profile).values(**profile_data)
|
||||||
conflict = sql.on_duplicate_key_update(**profile_data)
|
conflict = sql.on_duplicate_key_update(**profile_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_profile: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_profile: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_profile_config(self, aime_id: int, config_data: Dict) -> Optional[int]:
|
async def put_profile_config(self, aime_id: int, config_data: Dict) -> Optional[int]:
|
||||||
config_data["user"] = aime_id
|
config_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(config).values(**config_data)
|
sql = insert(config).values(**config_data)
|
||||||
conflict = sql.on_duplicate_key_update(**config_data)
|
conflict = sql.on_duplicate_key_update(**config_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
@@ -378,12 +378,12 @@ class IDACProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_profile_avatar(self, aime_id: int, avatar_data: Dict) -> Optional[int]:
|
async def put_profile_avatar(self, aime_id: int, avatar_data: Dict) -> Optional[int]:
|
||||||
avatar_data["user"] = aime_id
|
avatar_data["user"] = aime_id
|
||||||
|
|
||||||
sql = insert(avatar).values(**avatar_data)
|
sql = insert(avatar).values(**avatar_data)
|
||||||
conflict = sql.on_duplicate_key_update(**avatar_data)
|
conflict = sql.on_duplicate_key_update(**avatar_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
@@ -392,7 +392,7 @@ class IDACProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_profile_rank(
|
async def put_profile_rank(
|
||||||
self, aime_id: int, version: int, rank_data: Dict
|
self, aime_id: int, version: int, rank_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
rank_data["user"] = aime_id
|
rank_data["user"] = aime_id
|
||||||
@@ -400,14 +400,14 @@ class IDACProfileData(BaseData):
|
|||||||
|
|
||||||
sql = insert(rank).values(**rank_data)
|
sql = insert(rank).values(**rank_data)
|
||||||
conflict = sql.on_duplicate_key_update(**rank_data)
|
conflict = sql.on_duplicate_key_update(**rank_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_profile_rank: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_profile_rank: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_profile_stock(
|
async def put_profile_stock(
|
||||||
self, aime_id: int, version: int, stock_data: Dict
|
self, aime_id: int, version: int, stock_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
stock_data["user"] = aime_id
|
stock_data["user"] = aime_id
|
||||||
@@ -415,14 +415,14 @@ class IDACProfileData(BaseData):
|
|||||||
|
|
||||||
sql = insert(stock).values(**stock_data)
|
sql = insert(stock).values(**stock_data)
|
||||||
conflict = sql.on_duplicate_key_update(**stock_data)
|
conflict = sql.on_duplicate_key_update(**stock_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(f"put_profile_stock: Failed to update! aime_id: {aime_id}")
|
self.logger.warn(f"put_profile_stock: Failed to update! aime_id: {aime_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_profile_theory(
|
async def put_profile_theory(
|
||||||
self, aime_id: int, version: int, theory_data: Dict
|
self, aime_id: int, version: int, theory_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
theory_data["user"] = aime_id
|
theory_data["user"] = aime_id
|
||||||
@@ -430,7 +430,7 @@ class IDACProfileData(BaseData):
|
|||||||
|
|
||||||
sql = insert(theory).values(**theory_data)
|
sql = insert(theory).values(**theory_data)
|
||||||
conflict = sql.on_duplicate_key_update(**theory_data)
|
conflict = sql.on_duplicate_key_update(**theory_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warn(
|
self.logger.warn(
|
||||||
|
|||||||
+222
-222
File diff suppressed because it is too large
Load Diff
@@ -81,7 +81,7 @@ class IDZUserDB:
|
|||||||
self.logger.debug("Connection closed")
|
self.logger.debug("Connection closed")
|
||||||
return
|
return
|
||||||
|
|
||||||
await self.dataReceived(data, reader, writer)
|
await self.data.Received(data, reader, writer)
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
|
|
||||||
except ConnectionResetError as e:
|
except ConnectionResetError as e:
|
||||||
|
|||||||
+52
-52
@@ -82,7 +82,7 @@ class Mai2Base:
|
|||||||
return {"length": 0, "gameTournamentInfoList": []}
|
return {"length": 0, "gameTournamentInfoList": []}
|
||||||
|
|
||||||
async def handle_get_game_event_api_request(self, data: Dict) -> Dict:
|
async def handle_get_game_event_api_request(self, data: Dict) -> Dict:
|
||||||
events = self.data.static.get_enabled_events(self.version)
|
events = await self.data.static.get_enabled_events(self.version)
|
||||||
events_lst = []
|
events_lst = []
|
||||||
if events is None or not events:
|
if events is None or not events:
|
||||||
self.logger.warning("No enabled events, did you run the reader?")
|
self.logger.warning("No enabled events, did you run the reader?")
|
||||||
@@ -112,7 +112,7 @@ class Mai2Base:
|
|||||||
return {"length": 0, "musicIdList": []}
|
return {"length": 0, "musicIdList": []}
|
||||||
|
|
||||||
async def handle_get_game_charge_api_request(self, data: Dict) -> Dict:
|
async def handle_get_game_charge_api_request(self, data: Dict) -> Dict:
|
||||||
game_charge_list = self.data.static.get_enabled_tickets(self.version, 1)
|
game_charge_list = await self.data.static.get_enabled_tickets(self.version, 1)
|
||||||
if game_charge_list is None:
|
if game_charge_list is None:
|
||||||
return {"length": 0, "gameChargeList": []}
|
return {"length": 0, "gameChargeList": []}
|
||||||
|
|
||||||
@@ -143,8 +143,8 @@ class Mai2Base:
|
|||||||
return {"returnCode": 1, "apiName": "UpsertClientTestmodeApi"}
|
return {"returnCode": 1, "apiName": "UpsertClientTestmodeApi"}
|
||||||
|
|
||||||
async def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
|
||||||
p = self.data.profile.get_profile_detail(data["userId"], self.version, False)
|
p = await self.data.profile.get_profile_detail(data["userId"], self.version, False)
|
||||||
w = self.data.profile.get_web_option(data["userId"], self.version)
|
w = await self.data.profile.get_web_option(data["userId"], self.version)
|
||||||
if p is None or w is None:
|
if p is None or w is None:
|
||||||
return {} # Register
|
return {} # Register
|
||||||
profile = p._asdict()
|
profile = p._asdict()
|
||||||
@@ -170,15 +170,15 @@ class Mai2Base:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_user_login_api_request(self, data: Dict) -> Dict:
|
async def handle_user_login_api_request(self, data: Dict) -> Dict:
|
||||||
profile = self.data.profile.get_profile_detail(data["userId"], self.version)
|
profile = await self.data.profile.get_profile_detail(data["userId"], self.version)
|
||||||
consec = self.data.profile.get_consec_login(data["userId"], self.version)
|
consec = await self.data.profile.get_consec_login(data["userId"], self.version)
|
||||||
|
|
||||||
if profile is not None:
|
if profile is not None:
|
||||||
lastLoginDate = profile["lastLoginDate"]
|
lastLoginDate = profile["lastLoginDate"]
|
||||||
loginCt = profile["playCount"]
|
loginCt = profile["playCount"]
|
||||||
|
|
||||||
if "regionId" in data:
|
if "regionId" in data:
|
||||||
self.data.profile.put_profile_region(data["userId"], data["regionId"])
|
await self.data.profile.put_profile_region(data["userId"], data["regionId"])
|
||||||
else:
|
else:
|
||||||
loginCt = 0
|
loginCt = 0
|
||||||
lastLoginDate = "2017-12-05 07:00:00.0"
|
lastLoginDate = "2017-12-05 07:00:00.0"
|
||||||
@@ -193,11 +193,11 @@ class Mai2Base:
|
|||||||
|
|
||||||
if lastlogindate_ < today_midnight:
|
if lastlogindate_ < today_midnight:
|
||||||
consec_ct = consec['logins'] + 1
|
consec_ct = consec['logins'] + 1
|
||||||
self.data.profile.add_consec_login(data["userId"], self.version)
|
await self.data.profile.add_consec_login(data["userId"], self.version)
|
||||||
|
|
||||||
elif lastlogindate_ < yesterday_midnight:
|
elif lastlogindate_ < yesterday_midnight:
|
||||||
consec_ct = 1
|
consec_ct = 1
|
||||||
self.data.profile.reset_consec_login(data["userId"], self.version)
|
await self.data.profile.reset_consec_login(data["userId"], self.version)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
consec_ct = consec['logins']
|
consec_ct = consec['logins']
|
||||||
@@ -214,7 +214,7 @@ class Mai2Base:
|
|||||||
user_id = data["userId"]
|
user_id = data["userId"]
|
||||||
playlog = data["userPlaylog"]
|
playlog = data["userPlaylog"]
|
||||||
|
|
||||||
self.data.score.put_playlog(user_id, playlog)
|
await self.data.score.put_playlog(user_id, playlog)
|
||||||
|
|
||||||
return {"returnCode": 1, "apiName": "UploadUserPlaylogApi"}
|
return {"returnCode": 1, "apiName": "UploadUserPlaylogApi"}
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ class Mai2Base:
|
|||||||
|
|
||||||
# remove the ".0" from the date string, festival only?
|
# remove the ".0" from the date string, festival only?
|
||||||
charge["purchaseDate"] = charge["purchaseDate"].replace(".0", "")
|
charge["purchaseDate"] = charge["purchaseDate"].replace(".0", "")
|
||||||
self.data.item.put_charge(
|
await self.data.item.put_charge(
|
||||||
user_id,
|
user_id,
|
||||||
charge["chargeId"],
|
charge["chargeId"],
|
||||||
charge["stock"],
|
charge["stock"],
|
||||||
@@ -246,64 +246,64 @@ class Mai2Base:
|
|||||||
upsert["userData"][0].pop("accessCode")
|
upsert["userData"][0].pop("accessCode")
|
||||||
upsert["userData"][0].pop("userId")
|
upsert["userData"][0].pop("userId")
|
||||||
|
|
||||||
self.data.profile.put_profile_detail(
|
await self.data.profile.put_profile_detail(
|
||||||
user_id, self.version, upsert["userData"][0], False
|
user_id, self.version, upsert["userData"][0], False
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userWebOption" in upsert and len(upsert["userWebOption"]) > 0:
|
if "userWebOption" in upsert and len(upsert["userWebOption"]) > 0:
|
||||||
upsert["userWebOption"][0]["isNetMember"] = True
|
upsert["userWebOption"][0]["isNetMember"] = True
|
||||||
self.data.profile.put_web_option(
|
await self.data.profile.put_web_option(
|
||||||
user_id, self.version, upsert["userWebOption"][0]
|
user_id, self.version, upsert["userWebOption"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userGradeStatusList" in upsert and len(upsert["userGradeStatusList"]) > 0:
|
if "userGradeStatusList" in upsert and len(upsert["userGradeStatusList"]) > 0:
|
||||||
self.data.profile.put_grade_status(
|
await self.data.profile.put_grade_status(
|
||||||
user_id, upsert["userGradeStatusList"][0]
|
user_id, upsert["userGradeStatusList"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userBossList" in upsert and len(upsert["userBossList"]) > 0:
|
if "userBossList" in upsert and len(upsert["userBossList"]) > 0:
|
||||||
self.data.profile.put_boss_list(
|
await self.data.profile.put_boss_list(
|
||||||
user_id, upsert["userBossList"][0]
|
user_id, upsert["userBossList"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userPlaylogList" in upsert and len(upsert["userPlaylogList"]) > 0:
|
if "userPlaylogList" in upsert and len(upsert["userPlaylogList"]) > 0:
|
||||||
for playlog in upsert["userPlaylogList"]:
|
for playlog in upsert["userPlaylogList"]:
|
||||||
self.data.score.put_playlog(
|
await self.data.score.put_playlog(
|
||||||
user_id, playlog, False
|
user_id, playlog, False
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userExtend" in upsert and len(upsert["userExtend"]) > 0:
|
if "userExtend" in upsert and len(upsert["userExtend"]) > 0:
|
||||||
self.data.profile.put_profile_extend(
|
await self.data.profile.put_profile_extend(
|
||||||
user_id, self.version, upsert["userExtend"][0]
|
user_id, self.version, upsert["userExtend"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userGhost" in upsert:
|
if "userGhost" in upsert:
|
||||||
for ghost in upsert["userGhost"]:
|
for ghost in upsert["userGhost"]:
|
||||||
self.data.profile.put_profile_ghost(user_id, self.version, ghost)
|
await self.data.profile.put_profile_ghost(user_id, self.version, ghost)
|
||||||
|
|
||||||
if "userRecentRatingList" in upsert:
|
if "userRecentRatingList" in upsert:
|
||||||
self.data.profile.put_recent_rating(user_id, upsert["userRecentRatingList"])
|
await self.data.profile.put_recent_rating(user_id, upsert["userRecentRatingList"])
|
||||||
|
|
||||||
if "userOption" in upsert and len(upsert["userOption"]) > 0:
|
if "userOption" in upsert and len(upsert["userOption"]) > 0:
|
||||||
upsert["userOption"][0].pop("userId")
|
upsert["userOption"][0].pop("userId")
|
||||||
self.data.profile.put_profile_option(
|
await self.data.profile.put_profile_option(
|
||||||
user_id, self.version, upsert["userOption"][0], False
|
user_id, self.version, upsert["userOption"][0], False
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userRatingList" in upsert and len(upsert["userRatingList"]) > 0:
|
if "userRatingList" in upsert and len(upsert["userRatingList"]) > 0:
|
||||||
self.data.profile.put_profile_rating(
|
await self.data.profile.put_profile_rating(
|
||||||
user_id, self.version, upsert["userRatingList"][0]
|
user_id, self.version, upsert["userRatingList"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userActivityList" in upsert and len(upsert["userActivityList"]) > 0:
|
if "userActivityList" in upsert and len(upsert["userActivityList"]) > 0:
|
||||||
for act in upsert["userActivityList"]:
|
for act in upsert["userActivityList"]:
|
||||||
self.data.profile.put_profile_activity(user_id, act)
|
await self.data.profile.put_profile_activity(user_id, act)
|
||||||
|
|
||||||
if "userChargeList" in upsert and len(upsert["userChargeList"]) > 0:
|
if "userChargeList" in upsert and len(upsert["userChargeList"]) > 0:
|
||||||
for charge in upsert["userChargeList"]:
|
for charge in upsert["userChargeList"]:
|
||||||
# remove the ".0" from the date string, festival only?
|
# remove the ".0" from the date string, festival only?
|
||||||
charge["purchaseDate"] = charge["purchaseDate"].replace(".0", "")
|
charge["purchaseDate"] = charge["purchaseDate"].replace(".0", "")
|
||||||
self.data.item.put_charge(
|
await self.data.item.put_charge(
|
||||||
user_id,
|
user_id,
|
||||||
charge["chargeId"],
|
charge["chargeId"],
|
||||||
charge["stock"],
|
charge["stock"],
|
||||||
@@ -313,14 +313,14 @@ class Mai2Base:
|
|||||||
|
|
||||||
if "userCharacterList" in upsert and len(upsert["userCharacterList"]) > 0:
|
if "userCharacterList" in upsert and len(upsert["userCharacterList"]) > 0:
|
||||||
for char in upsert["userCharacterList"]:
|
for char in upsert["userCharacterList"]:
|
||||||
self.data.item.put_character_(
|
await self.data.item.put_character_(
|
||||||
user_id,
|
user_id,
|
||||||
char
|
char
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userItemList" in upsert and len(upsert["userItemList"]) > 0:
|
if "userItemList" in upsert and len(upsert["userItemList"]) > 0:
|
||||||
for item in upsert["userItemList"]:
|
for item in upsert["userItemList"]:
|
||||||
self.data.item.put_item(
|
await self.data.item.put_item(
|
||||||
user_id,
|
user_id,
|
||||||
int(item["itemKind"]),
|
int(item["itemKind"]),
|
||||||
item["itemId"],
|
item["itemId"],
|
||||||
@@ -330,7 +330,7 @@ class Mai2Base:
|
|||||||
|
|
||||||
if "userLoginBonusList" in upsert and len(upsert["userLoginBonusList"]) > 0:
|
if "userLoginBonusList" in upsert and len(upsert["userLoginBonusList"]) > 0:
|
||||||
for login_bonus in upsert["userLoginBonusList"]:
|
for login_bonus in upsert["userLoginBonusList"]:
|
||||||
self.data.item.put_login_bonus(
|
await self.data.item.put_login_bonus(
|
||||||
user_id,
|
user_id,
|
||||||
login_bonus["bonusId"],
|
login_bonus["bonusId"],
|
||||||
login_bonus["point"],
|
login_bonus["point"],
|
||||||
@@ -340,7 +340,7 @@ class Mai2Base:
|
|||||||
|
|
||||||
if "userMapList" in upsert and len(upsert["userMapList"]) > 0:
|
if "userMapList" in upsert and len(upsert["userMapList"]) > 0:
|
||||||
for map in upsert["userMapList"]:
|
for map in upsert["userMapList"]:
|
||||||
self.data.item.put_map(
|
await self.data.item.put_map(
|
||||||
user_id,
|
user_id,
|
||||||
map["mapId"],
|
map["mapId"],
|
||||||
map["distance"],
|
map["distance"],
|
||||||
@@ -351,15 +351,15 @@ class Mai2Base:
|
|||||||
|
|
||||||
if "userMusicDetailList" in upsert and len(upsert["userMusicDetailList"]) > 0:
|
if "userMusicDetailList" in upsert and len(upsert["userMusicDetailList"]) > 0:
|
||||||
for music in upsert["userMusicDetailList"]:
|
for music in upsert["userMusicDetailList"]:
|
||||||
self.data.score.put_best_score(user_id, music, False)
|
await self.data.score.put_best_score(user_id, music, False)
|
||||||
|
|
||||||
if "userCourseList" in upsert and len(upsert["userCourseList"]) > 0:
|
if "userCourseList" in upsert and len(upsert["userCourseList"]) > 0:
|
||||||
for course in upsert["userCourseList"]:
|
for course in upsert["userCourseList"]:
|
||||||
self.data.score.put_course(user_id, course)
|
await self.data.score.put_course(user_id, course)
|
||||||
|
|
||||||
if "userFavoriteList" in upsert and len(upsert["userFavoriteList"]) > 0:
|
if "userFavoriteList" in upsert and len(upsert["userFavoriteList"]) > 0:
|
||||||
for fav in upsert["userFavoriteList"]:
|
for fav in upsert["userFavoriteList"]:
|
||||||
self.data.item.put_favorite(user_id, fav["kind"], fav["itemIdList"])
|
await self.data.item.put_favorite(user_id, fav["kind"], fav["itemIdList"])
|
||||||
|
|
||||||
if (
|
if (
|
||||||
"userFriendSeasonRankingList" in upsert
|
"userFriendSeasonRankingList" in upsert
|
||||||
@@ -371,7 +371,7 @@ class Mai2Base:
|
|||||||
fsr["recordDate"], f"{Mai2Constants.DATE_TIME_FORMAT}.0"
|
fsr["recordDate"], f"{Mai2Constants.DATE_TIME_FORMAT}.0"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.data.item.put_friend_season_ranking(user_id, fsr)
|
await self.data.item.put_friend_season_ranking(user_id, fsr)
|
||||||
|
|
||||||
return {"returnCode": 1, "apiName": "UpsertUserAllApi"}
|
return {"returnCode": 1, "apiName": "UpsertUserAllApi"}
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ class Mai2Base:
|
|||||||
return {"returnCode": 1}
|
return {"returnCode": 1}
|
||||||
|
|
||||||
async def handle_get_user_data_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_data_api_request(self, data: Dict) -> Dict:
|
||||||
profile = self.data.profile.get_profile_detail(data["userId"], self.version, False)
|
profile = await self.data.profile.get_profile_detail(data["userId"], self.version, False)
|
||||||
if profile is None:
|
if profile is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ class Mai2Base:
|
|||||||
return {"userId": data["userId"], "userData": profile_dict}
|
return {"userId": data["userId"], "userData": profile_dict}
|
||||||
|
|
||||||
async def handle_get_user_extend_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_extend_api_request(self, data: Dict) -> Dict:
|
||||||
extend = self.data.profile.get_profile_extend(data["userId"], self.version)
|
extend = await self.data.profile.get_profile_extend(data["userId"], self.version)
|
||||||
if extend is None:
|
if extend is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -403,7 +403,7 @@ class Mai2Base:
|
|||||||
return {"userId": data["userId"], "userExtend": extend_dict}
|
return {"userId": data["userId"], "userExtend": extend_dict}
|
||||||
|
|
||||||
async def handle_get_user_option_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_option_api_request(self, data: Dict) -> Dict:
|
||||||
options = self.data.profile.get_profile_option(data["userId"], self.version, False)
|
options = await self.data.profile.get_profile_option(data["userId"], self.version, False)
|
||||||
if options is None:
|
if options is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -415,7 +415,7 @@ class Mai2Base:
|
|||||||
return {"userId": data["userId"], "userOption": options_dict}
|
return {"userId": data["userId"], "userOption": options_dict}
|
||||||
|
|
||||||
async def handle_get_user_card_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_cards is None:
|
||||||
return {"userId": data["userId"], "nextIndex": 0, "userCardList": []}
|
return {"userId": data["userId"], "nextIndex": 0, "userCardList": []}
|
||||||
|
|
||||||
@@ -449,7 +449,7 @@ class Mai2Base:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_charge_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_charge_api_request(self, data: Dict) -> Dict:
|
||||||
user_charges = self.data.item.get_charges(data["userId"])
|
user_charges = await self.data.item.get_charges(data["userId"])
|
||||||
if user_charges is None:
|
if user_charges is None:
|
||||||
return {"userId": data["userId"], "length": 0, "userChargeList": []}
|
return {"userId": data["userId"], "length": 0, "userChargeList": []}
|
||||||
|
|
||||||
@@ -477,7 +477,7 @@ class Mai2Base:
|
|||||||
return { "userId": data.get("userId", 0), "length": 0, "userPresentEventList": []}
|
return { "userId": data.get("userId", 0), "length": 0, "userPresentEventList": []}
|
||||||
|
|
||||||
async def handle_get_user_boss_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_boss_api_request(self, data: Dict) -> Dict:
|
||||||
b = self.data.profile.get_boss_list(data["userId"])
|
b = await self.data.profile.get_boss_list(data["userId"])
|
||||||
if b is None:
|
if b is None:
|
||||||
return { "userId": data.get("userId", 0), "userBossData": {}}
|
return { "userId": data.get("userId", 0), "userBossData": {}}
|
||||||
boss_lst = b._asdict()
|
boss_lst = b._asdict()
|
||||||
@@ -489,7 +489,7 @@ class Mai2Base:
|
|||||||
async def handle_get_user_item_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_item_api_request(self, data: Dict) -> Dict:
|
||||||
kind = int(data["nextIndex"] / 10000000000)
|
kind = int(data["nextIndex"] / 10000000000)
|
||||||
next_idx = int(data["nextIndex"] % 10000000000)
|
next_idx = int(data["nextIndex"] % 10000000000)
|
||||||
user_item_list = self.data.item.get_items(data["userId"], kind)
|
user_item_list = await self.data.item.get_items(data["userId"], kind)
|
||||||
|
|
||||||
items: List[Dict[str, Any]] = []
|
items: List[Dict[str, Any]] = []
|
||||||
for i in range(next_idx, len(user_item_list)):
|
for i in range(next_idx, len(user_item_list)):
|
||||||
@@ -515,7 +515,7 @@ class Mai2Base:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_character_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_character_api_request(self, data: Dict) -> Dict:
|
||||||
characters = self.data.item.get_characters(data["userId"])
|
characters = await self.data.item.get_characters(data["userId"])
|
||||||
|
|
||||||
chara_list = []
|
chara_list = []
|
||||||
for chara in characters:
|
for chara in characters:
|
||||||
@@ -529,7 +529,7 @@ class Mai2Base:
|
|||||||
return {"userId": data["userId"], "userCharacterList": chara_list}
|
return {"userId": data["userId"], "userCharacterList": chara_list}
|
||||||
|
|
||||||
async def handle_get_user_favorite_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_favorite_api_request(self, data: Dict) -> Dict:
|
||||||
favorites = self.data.item.get_favorites(data["userId"], data["itemKind"])
|
favorites = await self.data.item.get_favorites(data["userId"], data["itemKind"])
|
||||||
if favorites is None:
|
if favorites is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -546,7 +546,7 @@ class Mai2Base:
|
|||||||
return {"userId": data["userId"], "userFavoriteData": userFavs}
|
return {"userId": data["userId"], "userFavoriteData": userFavs}
|
||||||
|
|
||||||
async def handle_get_user_ghost_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_ghost_api_request(self, data: Dict) -> Dict:
|
||||||
ghost = self.data.profile.get_profile_ghost(data["userId"], self.version)
|
ghost = await self.data.profile.get_profile_ghost(data["userId"], self.version)
|
||||||
if ghost is None:
|
if ghost is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -558,7 +558,7 @@ class Mai2Base:
|
|||||||
return {"userId": data["userId"], "userGhost": ghost_dict}
|
return {"userId": data["userId"], "userGhost": ghost_dict}
|
||||||
|
|
||||||
async def handle_get_user_recent_rating_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_recent_rating_api_request(self, data: Dict) -> Dict:
|
||||||
rating = self.data.profile.get_recent_rating(data["userId"])
|
rating = await self.data.profile.get_recent_rating(data["userId"])
|
||||||
if rating is None:
|
if rating is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -568,7 +568,7 @@ class Mai2Base:
|
|||||||
return {"userId": data["userId"], "length": len(lst), "userRecentRatingList": lst}
|
return {"userId": data["userId"], "length": len(lst), "userRecentRatingList": lst}
|
||||||
|
|
||||||
async def handle_get_user_rating_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_rating_api_request(self, data: Dict) -> Dict:
|
||||||
rating = self.data.profile.get_profile_rating(data["userId"], self.version)
|
rating = await self.data.profile.get_profile_rating(data["userId"], self.version)
|
||||||
if rating is None:
|
if rating is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -583,8 +583,8 @@ class Mai2Base:
|
|||||||
"""
|
"""
|
||||||
kind 1 is playlist, kind 2 is music list
|
kind 1 is playlist, kind 2 is music list
|
||||||
"""
|
"""
|
||||||
playlist = self.data.profile.get_profile_activity(data["userId"], 1)
|
playlist = await self.data.profile.get_profile_activity(data["userId"], 1)
|
||||||
musiclist = self.data.profile.get_profile_activity(data["userId"], 2)
|
musiclist = await self.data.profile.get_profile_activity(data["userId"], 2)
|
||||||
if playlist is None or musiclist is None:
|
if playlist is None or musiclist is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -608,7 +608,7 @@ class Mai2Base:
|
|||||||
return {"userActivity": {"playList": plst, "musicList": mlst}}
|
return {"userActivity": {"playList": plst, "musicList": mlst}}
|
||||||
|
|
||||||
async def handle_get_user_course_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_course_api_request(self, data: Dict) -> Dict:
|
||||||
user_courses = self.data.score.get_courses(data["userId"])
|
user_courses = await self.data.score.get_courses(data["userId"])
|
||||||
if user_courses is None:
|
if user_courses is None:
|
||||||
return {"userId": data["userId"], "nextIndex": 0, "userCourseList": []}
|
return {"userId": data["userId"], "nextIndex": 0, "userCourseList": []}
|
||||||
|
|
||||||
@@ -626,7 +626,7 @@ class Mai2Base:
|
|||||||
return {"length": 0, "userPortraitList": []}
|
return {"length": 0, "userPortraitList": []}
|
||||||
|
|
||||||
async def handle_get_user_friend_season_ranking_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_friend_season_ranking_api_request(self, data: Dict) -> Dict:
|
||||||
friend_season_ranking = self.data.item.get_friend_season_ranking(data["userId"])
|
friend_season_ranking = await self.data.item.get_friend_season_ranking(data["userId"])
|
||||||
if friend_season_ranking is None:
|
if friend_season_ranking is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -662,7 +662,7 @@ class Mai2Base:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_map_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_map_api_request(self, data: Dict) -> Dict:
|
||||||
maps = self.data.item.get_maps(data["userId"])
|
maps = await self.data.item.get_maps(data["userId"])
|
||||||
if maps is None:
|
if maps is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -695,7 +695,7 @@ class Mai2Base:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_login_bonus_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_login_bonus_api_request(self, data: Dict) -> Dict:
|
||||||
login_bonuses = self.data.item.get_login_bonuses(data["userId"])
|
login_bonuses = await self.data.item.get_login_bonuses(data["userId"])
|
||||||
if login_bonuses is None:
|
if login_bonuses is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -731,7 +731,7 @@ class Mai2Base:
|
|||||||
return {"userId": data["userId"], "length": 0, "userRegionList": []}
|
return {"userId": data["userId"], "length": 0, "userRegionList": []}
|
||||||
|
|
||||||
async def handle_get_user_web_option_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_web_option_api_request(self, data: Dict) -> Dict:
|
||||||
w = self.data.profile.get_web_option(data["userId"], self.version)
|
w = await self.data.profile.get_web_option(data["userId"], self.version)
|
||||||
if w is None:
|
if w is None:
|
||||||
return {"userId": data["userId"], "userWebOption": {}}
|
return {"userId": data["userId"], "userWebOption": {}}
|
||||||
|
|
||||||
@@ -746,7 +746,7 @@ class Mai2Base:
|
|||||||
return {"userId": data["userId"], "length": 0, "userSurvivalList": []}
|
return {"userId": data["userId"], "length": 0, "userSurvivalList": []}
|
||||||
|
|
||||||
async def handle_get_user_grade_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_grade_api_request(self, data: Dict) -> Dict:
|
||||||
g = self.data.profile.get_grade_status(data["userId"])
|
g = await self.data.profile.get_grade_status(data["userId"])
|
||||||
if g is None:
|
if g is None:
|
||||||
return {"userId": data["userId"], "userGradeStatus": {}, "length": 0, "userGradeList": []}
|
return {"userId": data["userId"], "userGradeStatus": {}, "length": 0, "userGradeList": []}
|
||||||
grade_stat = g._asdict()
|
grade_stat = g._asdict()
|
||||||
@@ -766,7 +766,7 @@ class Mai2Base:
|
|||||||
self.logger.warning("handle_get_user_music_api_request: Could not find userid in data, or userId is 0")
|
self.logger.warning("handle_get_user_music_api_request: Could not find userid in data, or userId is 0")
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
songs = self.data.score.get_best_scores(user_id, is_dx=False)
|
songs = await self.data.score.get_best_scores(user_id, is_dx=False)
|
||||||
if songs is None:
|
if songs is None:
|
||||||
self.logger.debug("handle_get_user_music_api_request: get_best_scores returned None!")
|
self.logger.debug("handle_get_user_music_api_request: get_best_scores returned None!")
|
||||||
return {
|
return {
|
||||||
|
|||||||
+36
-36
@@ -34,8 +34,8 @@ class Mai2DX(Mai2Base):
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
|
||||||
p = self.data.profile.get_profile_detail(data["userId"], self.version)
|
p = await self.data.profile.get_profile_detail(data["userId"], self.version)
|
||||||
o = self.data.profile.get_profile_option(data["userId"], self.version)
|
o = await self.data.profile.get_profile_option(data["userId"], self.version)
|
||||||
if p is None or o is None:
|
if p is None or o is None:
|
||||||
return {} # Register
|
return {} # Register
|
||||||
profile = p._asdict()
|
profile = p._asdict()
|
||||||
@@ -73,7 +73,7 @@ class Mai2DX(Mai2Base):
|
|||||||
user_id = data["userId"]
|
user_id = data["userId"]
|
||||||
playlog = data["userPlaylog"]
|
playlog = data["userPlaylog"]
|
||||||
|
|
||||||
self.data.score.put_playlog(user_id, playlog)
|
await self.data.score.put_playlog(user_id, playlog)
|
||||||
|
|
||||||
return {"returnCode": 1, "apiName": "UploadUserPlaylogApi"}
|
return {"returnCode": 1, "apiName": "UploadUserPlaylogApi"}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ class Mai2DX(Mai2Base):
|
|||||||
|
|
||||||
# remove the ".0" from the date string, festival only?
|
# remove the ".0" from the date string, festival only?
|
||||||
charge["purchaseDate"] = charge["purchaseDate"].replace(".0", "")
|
charge["purchaseDate"] = charge["purchaseDate"].replace(".0", "")
|
||||||
self.data.item.put_charge(
|
await self.data.item.put_charge(
|
||||||
user_id,
|
user_id,
|
||||||
charge["chargeId"],
|
charge["chargeId"],
|
||||||
charge["stock"],
|
charge["stock"],
|
||||||
@@ -104,39 +104,39 @@ class Mai2DX(Mai2Base):
|
|||||||
if "userData" in upsert and len(upsert["userData"]) > 0:
|
if "userData" in upsert and len(upsert["userData"]) > 0:
|
||||||
upsert["userData"][0]["isNetMember"] = 1
|
upsert["userData"][0]["isNetMember"] = 1
|
||||||
upsert["userData"][0].pop("accessCode")
|
upsert["userData"][0].pop("accessCode")
|
||||||
self.data.profile.put_profile_detail(
|
await self.data.profile.put_profile_detail(
|
||||||
user_id, self.version, upsert["userData"][0]
|
user_id, self.version, upsert["userData"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userExtend" in upsert and len(upsert["userExtend"]) > 0:
|
if "userExtend" in upsert and len(upsert["userExtend"]) > 0:
|
||||||
self.data.profile.put_profile_extend(
|
await self.data.profile.put_profile_extend(
|
||||||
user_id, self.version, upsert["userExtend"][0]
|
user_id, self.version, upsert["userExtend"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userGhost" in upsert:
|
if "userGhost" in upsert:
|
||||||
for ghost in upsert["userGhost"]:
|
for ghost in upsert["userGhost"]:
|
||||||
self.data.profile.put_profile_ghost(user_id, self.version, ghost)
|
await self.data.profile.put_profile_ghost(user_id, self.version, ghost)
|
||||||
|
|
||||||
if "userOption" in upsert and len(upsert["userOption"]) > 0:
|
if "userOption" in upsert and len(upsert["userOption"]) > 0:
|
||||||
self.data.profile.put_profile_option(
|
await self.data.profile.put_profile_option(
|
||||||
user_id, self.version, upsert["userOption"][0]
|
user_id, self.version, upsert["userOption"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userRatingList" in upsert and len(upsert["userRatingList"]) > 0:
|
if "userRatingList" in upsert and len(upsert["userRatingList"]) > 0:
|
||||||
self.data.profile.put_profile_rating(
|
await self.data.profile.put_profile_rating(
|
||||||
user_id, self.version, upsert["userRatingList"][0]
|
user_id, self.version, upsert["userRatingList"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userActivityList" in upsert and len(upsert["userActivityList"]) > 0:
|
if "userActivityList" in upsert and len(upsert["userActivityList"]) > 0:
|
||||||
for k, v in upsert["userActivityList"][0].items():
|
for k, v in upsert["userActivityList"][0].items():
|
||||||
for act in v:
|
for act in v:
|
||||||
self.data.profile.put_profile_activity(user_id, act)
|
await self.data.profile.put_profile_activity(user_id, act)
|
||||||
|
|
||||||
if "userChargeList" in upsert and len(upsert["userChargeList"]) > 0:
|
if "userChargeList" in upsert and len(upsert["userChargeList"]) > 0:
|
||||||
for charge in upsert["userChargeList"]:
|
for charge in upsert["userChargeList"]:
|
||||||
# remove the ".0" from the date string, festival only?
|
# remove the ".0" from the date string, festival only?
|
||||||
charge["purchaseDate"] = charge["purchaseDate"].replace(".0", "")
|
charge["purchaseDate"] = charge["purchaseDate"].replace(".0", "")
|
||||||
self.data.item.put_charge(
|
await self.data.item.put_charge(
|
||||||
user_id,
|
user_id,
|
||||||
charge["chargeId"],
|
charge["chargeId"],
|
||||||
charge["stock"],
|
charge["stock"],
|
||||||
@@ -150,7 +150,7 @@ class Mai2DX(Mai2Base):
|
|||||||
|
|
||||||
if "userCharacterList" in upsert and len(upsert["userCharacterList"]) > 0:
|
if "userCharacterList" in upsert and len(upsert["userCharacterList"]) > 0:
|
||||||
for char in upsert["userCharacterList"]:
|
for char in upsert["userCharacterList"]:
|
||||||
self.data.item.put_character(
|
await self.data.item.put_character(
|
||||||
user_id,
|
user_id,
|
||||||
char["characterId"],
|
char["characterId"],
|
||||||
char["level"],
|
char["level"],
|
||||||
@@ -160,7 +160,7 @@ class Mai2DX(Mai2Base):
|
|||||||
|
|
||||||
if "userItemList" in upsert and len(upsert["userItemList"]) > 0:
|
if "userItemList" in upsert and len(upsert["userItemList"]) > 0:
|
||||||
for item in upsert["userItemList"]:
|
for item in upsert["userItemList"]:
|
||||||
self.data.item.put_item(
|
await self.data.item.put_item(
|
||||||
user_id,
|
user_id,
|
||||||
int(item["itemKind"]),
|
int(item["itemKind"]),
|
||||||
item["itemId"],
|
item["itemId"],
|
||||||
@@ -170,7 +170,7 @@ class Mai2DX(Mai2Base):
|
|||||||
|
|
||||||
if "userLoginBonusList" in upsert and len(upsert["userLoginBonusList"]) > 0:
|
if "userLoginBonusList" in upsert and len(upsert["userLoginBonusList"]) > 0:
|
||||||
for login_bonus in upsert["userLoginBonusList"]:
|
for login_bonus in upsert["userLoginBonusList"]:
|
||||||
self.data.item.put_login_bonus(
|
await self.data.item.put_login_bonus(
|
||||||
user_id,
|
user_id,
|
||||||
login_bonus["bonusId"],
|
login_bonus["bonusId"],
|
||||||
login_bonus["point"],
|
login_bonus["point"],
|
||||||
@@ -180,7 +180,7 @@ class Mai2DX(Mai2Base):
|
|||||||
|
|
||||||
if "userMapList" in upsert and len(upsert["userMapList"]) > 0:
|
if "userMapList" in upsert and len(upsert["userMapList"]) > 0:
|
||||||
for map in upsert["userMapList"]:
|
for map in upsert["userMapList"]:
|
||||||
self.data.item.put_map(
|
await self.data.item.put_map(
|
||||||
user_id,
|
user_id,
|
||||||
map["mapId"],
|
map["mapId"],
|
||||||
map["distance"],
|
map["distance"],
|
||||||
@@ -191,15 +191,15 @@ class Mai2DX(Mai2Base):
|
|||||||
|
|
||||||
if "userMusicDetailList" in upsert and len(upsert["userMusicDetailList"]) > 0:
|
if "userMusicDetailList" in upsert and len(upsert["userMusicDetailList"]) > 0:
|
||||||
for music in upsert["userMusicDetailList"]:
|
for music in upsert["userMusicDetailList"]:
|
||||||
self.data.score.put_best_score(user_id, music)
|
await self.data.score.put_best_score(user_id, music)
|
||||||
|
|
||||||
if "userCourseList" in upsert and len(upsert["userCourseList"]) > 0:
|
if "userCourseList" in upsert and len(upsert["userCourseList"]) > 0:
|
||||||
for course in upsert["userCourseList"]:
|
for course in upsert["userCourseList"]:
|
||||||
self.data.score.put_course(user_id, course)
|
await self.data.score.put_course(user_id, course)
|
||||||
|
|
||||||
if "userFavoriteList" in upsert and len(upsert["userFavoriteList"]) > 0:
|
if "userFavoriteList" in upsert and len(upsert["userFavoriteList"]) > 0:
|
||||||
for fav in upsert["userFavoriteList"]:
|
for fav in upsert["userFavoriteList"]:
|
||||||
self.data.item.put_favorite(user_id, fav["kind"], fav["itemIdList"])
|
await self.data.item.put_favorite(user_id, fav["kind"], fav["itemIdList"])
|
||||||
|
|
||||||
if (
|
if (
|
||||||
"userFriendSeasonRankingList" in upsert
|
"userFriendSeasonRankingList" in upsert
|
||||||
@@ -211,12 +211,12 @@ class Mai2DX(Mai2Base):
|
|||||||
fsr["recordDate"], f"{Mai2Constants.DATE_TIME_FORMAT}.0"
|
fsr["recordDate"], f"{Mai2Constants.DATE_TIME_FORMAT}.0"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.data.item.put_friend_season_ranking(user_id, fsr)
|
await self.data.item.put_friend_season_ranking(user_id, fsr)
|
||||||
|
|
||||||
return {"returnCode": 1, "apiName": "UpsertUserAllApi"}
|
return {"returnCode": 1, "apiName": "UpsertUserAllApi"}
|
||||||
|
|
||||||
async def handle_get_user_data_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_data_api_request(self, data: Dict) -> Dict:
|
||||||
profile = self.data.profile.get_profile_detail(data["userId"], self.version)
|
profile = await self.data.profile.get_profile_detail(data["userId"], self.version)
|
||||||
if profile is None:
|
if profile is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ class Mai2DX(Mai2Base):
|
|||||||
return {"userId": data["userId"], "userData": profile_dict}
|
return {"userId": data["userId"], "userData": profile_dict}
|
||||||
|
|
||||||
async def handle_get_user_extend_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_extend_api_request(self, data: Dict) -> Dict:
|
||||||
extend = self.data.profile.get_profile_extend(data["userId"], self.version)
|
extend = await self.data.profile.get_profile_extend(data["userId"], self.version)
|
||||||
if extend is None:
|
if extend is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ class Mai2DX(Mai2Base):
|
|||||||
return {"userId": data["userId"], "userExtend": extend_dict}
|
return {"userId": data["userId"], "userExtend": extend_dict}
|
||||||
|
|
||||||
async def handle_get_user_option_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_option_api_request(self, data: Dict) -> Dict:
|
||||||
options = self.data.profile.get_profile_option(data["userId"], self.version)
|
options = await self.data.profile.get_profile_option(data["userId"], self.version)
|
||||||
if options is None:
|
if options is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ class Mai2DX(Mai2Base):
|
|||||||
return {"userId": data["userId"], "userOption": options_dict}
|
return {"userId": data["userId"], "userOption": options_dict}
|
||||||
|
|
||||||
async def handle_get_user_card_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_cards is None:
|
||||||
return {"userId": data["userId"], "nextIndex": 0, "userCardList": []}
|
return {"userId": data["userId"], "nextIndex": 0, "userCardList": []}
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ class Mai2DX(Mai2Base):
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_charge_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_charge_api_request(self, data: Dict) -> Dict:
|
||||||
user_charges = self.data.item.get_charges(data["userId"])
|
user_charges = await self.data.item.get_charges(data["userId"])
|
||||||
if user_charges is None:
|
if user_charges is None:
|
||||||
return {"userId": data["userId"], "length": 0, "userChargeList": []}
|
return {"userId": data["userId"], "length": 0, "userChargeList": []}
|
||||||
|
|
||||||
@@ -313,7 +313,7 @@ class Mai2DX(Mai2Base):
|
|||||||
async def handle_get_user_item_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_item_api_request(self, data: Dict) -> Dict:
|
||||||
kind = int(data["nextIndex"] / 10000000000)
|
kind = int(data["nextIndex"] / 10000000000)
|
||||||
next_idx = int(data["nextIndex"] % 10000000000)
|
next_idx = int(data["nextIndex"] % 10000000000)
|
||||||
user_item_list = self.data.item.get_items(data["userId"], kind)
|
user_item_list = await self.data.item.get_items(data["userId"], kind)
|
||||||
|
|
||||||
items: List[Dict[str, Any]] = []
|
items: List[Dict[str, Any]] = []
|
||||||
for i in range(next_idx, len(user_item_list)):
|
for i in range(next_idx, len(user_item_list)):
|
||||||
@@ -339,7 +339,7 @@ class Mai2DX(Mai2Base):
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_character_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_character_api_request(self, data: Dict) -> Dict:
|
||||||
characters = self.data.item.get_characters(data["userId"])
|
characters = await self.data.item.get_characters(data["userId"])
|
||||||
|
|
||||||
chara_list = []
|
chara_list = []
|
||||||
for chara in characters:
|
for chara in characters:
|
||||||
@@ -351,7 +351,7 @@ class Mai2DX(Mai2Base):
|
|||||||
return {"userId": data["userId"], "userCharacterList": chara_list}
|
return {"userId": data["userId"], "userCharacterList": chara_list}
|
||||||
|
|
||||||
async def handle_get_user_favorite_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_favorite_api_request(self, data: Dict) -> Dict:
|
||||||
favorites = self.data.item.get_favorites(data["userId"], data["itemKind"])
|
favorites = await self.data.item.get_favorites(data["userId"], data["itemKind"])
|
||||||
if favorites is None:
|
if favorites is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -368,7 +368,7 @@ class Mai2DX(Mai2Base):
|
|||||||
return {"userId": data["userId"], "userFavoriteData": userFavs}
|
return {"userId": data["userId"], "userFavoriteData": userFavs}
|
||||||
|
|
||||||
async def handle_get_user_ghost_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_ghost_api_request(self, data: Dict) -> Dict:
|
||||||
ghost = self.data.profile.get_profile_ghost(data["userId"], self.version)
|
ghost = await self.data.profile.get_profile_ghost(data["userId"], self.version)
|
||||||
if ghost is None:
|
if ghost is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -380,7 +380,7 @@ class Mai2DX(Mai2Base):
|
|||||||
return {"userId": data["userId"], "userGhost": ghost_dict}
|
return {"userId": data["userId"], "userGhost": ghost_dict}
|
||||||
|
|
||||||
async def handle_get_user_rating_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_rating_api_request(self, data: Dict) -> Dict:
|
||||||
rating = self.data.profile.get_profile_rating(data["userId"], self.version)
|
rating = await self.data.profile.get_profile_rating(data["userId"], self.version)
|
||||||
if rating is None:
|
if rating is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -395,8 +395,8 @@ class Mai2DX(Mai2Base):
|
|||||||
"""
|
"""
|
||||||
kind 1 is playlist, kind 2 is music list
|
kind 1 is playlist, kind 2 is music list
|
||||||
"""
|
"""
|
||||||
playlist = self.data.profile.get_profile_activity(data["userId"], 1)
|
playlist = await self.data.profile.get_profile_activity(data["userId"], 1)
|
||||||
musiclist = self.data.profile.get_profile_activity(data["userId"], 2)
|
musiclist = await self.data.profile.get_profile_activity(data["userId"], 2)
|
||||||
if playlist is None or musiclist is None:
|
if playlist is None or musiclist is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -420,7 +420,7 @@ class Mai2DX(Mai2Base):
|
|||||||
return {"userActivity": {"playList": plst, "musicList": mlst}}
|
return {"userActivity": {"playList": plst, "musicList": mlst}}
|
||||||
|
|
||||||
async def handle_get_user_course_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_course_api_request(self, data: Dict) -> Dict:
|
||||||
user_courses = self.data.score.get_courses(data["userId"])
|
user_courses = await self.data.score.get_courses(data["userId"])
|
||||||
if user_courses is None:
|
if user_courses is None:
|
||||||
return {"userId": data["userId"], "nextIndex": 0, "userCourseList": []}
|
return {"userId": data["userId"], "nextIndex": 0, "userCourseList": []}
|
||||||
|
|
||||||
@@ -438,7 +438,7 @@ class Mai2DX(Mai2Base):
|
|||||||
return {"length": 0, "userPortraitList": []}
|
return {"length": 0, "userPortraitList": []}
|
||||||
|
|
||||||
async def handle_get_user_friend_season_ranking_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_friend_season_ranking_api_request(self, data: Dict) -> Dict:
|
||||||
friend_season_ranking = self.data.item.get_friend_season_ranking(data["userId"])
|
friend_season_ranking = await self.data.item.get_friend_season_ranking(data["userId"])
|
||||||
if friend_season_ranking is None:
|
if friend_season_ranking is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -474,7 +474,7 @@ class Mai2DX(Mai2Base):
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_map_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_map_api_request(self, data: Dict) -> Dict:
|
||||||
maps = self.data.item.get_maps(data["userId"])
|
maps = await self.data.item.get_maps(data["userId"])
|
||||||
if maps is None:
|
if maps is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -507,7 +507,7 @@ class Mai2DX(Mai2Base):
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_login_bonus_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_login_bonus_api_request(self, data: Dict) -> Dict:
|
||||||
login_bonuses = self.data.item.get_login_bonuses(data["userId"])
|
login_bonuses = await self.data.item.get_login_bonuses(data["userId"])
|
||||||
if login_bonuses is None:
|
if login_bonuses is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -588,7 +588,7 @@ class Mai2DX(Mai2Base):
|
|||||||
self.logger.warning("handle_get_user_music_api_request: Could not find userid in data, or userId is 0")
|
self.logger.warning("handle_get_user_music_api_request: Could not find userid in data, or userId is 0")
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
songs = self.data.score.get_best_scores(user_id)
|
songs = await self.data.score.get_best_scores(user_id)
|
||||||
if songs is None:
|
if songs is None:
|
||||||
self.logger.debug("handle_get_user_music_api_request: get_best_scores returned None!")
|
self.logger.debug("handle_get_user_music_api_request: get_best_scores returned None!")
|
||||||
return {
|
return {
|
||||||
|
|||||||
+23
-23
@@ -35,7 +35,7 @@ class Mai2Reader(BaseReader):
|
|||||||
self.logger.error(f"Invalid maimai DX version {version}")
|
self.logger.error(f"Invalid maimai DX version {version}")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
def read(self) -> None:
|
async def read(self) -> None:
|
||||||
data_dirs = []
|
data_dirs = []
|
||||||
if self.version >= Mai2Constants.VER_MAIMAI_DX:
|
if self.version >= Mai2Constants.VER_MAIMAI_DX:
|
||||||
if self.bin_dir is not None:
|
if self.bin_dir is not None:
|
||||||
@@ -46,10 +46,10 @@ class Mai2Reader(BaseReader):
|
|||||||
|
|
||||||
for dir in data_dirs:
|
for dir in data_dirs:
|
||||||
self.logger.info(f"Read from {dir}")
|
self.logger.info(f"Read from {dir}")
|
||||||
self.get_events(f"{dir}/event")
|
await self.get_events(f"{dir}/event")
|
||||||
self.disable_events(f"{dir}/information", f"{dir}/scoreRanking")
|
await self.disable_events(f"{dir}/information", f"{dir}/scoreRanking")
|
||||||
self.read_music(f"{dir}/music")
|
await self.read_music(f"{dir}/music")
|
||||||
self.read_tickets(f"{dir}/ticket")
|
await self.read_tickets(f"{dir}/ticket")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not os.path.exists(f"{self.bin_dir}/tables"):
|
if not os.path.exists(f"{self.bin_dir}/tables"):
|
||||||
@@ -70,16 +70,16 @@ class Mai2Reader(BaseReader):
|
|||||||
txt_table = self.load_table_raw(f"{self.bin_dir}/tables", "mmtextout_jp.bin", key)
|
txt_table = self.load_table_raw(f"{self.bin_dir}/tables", "mmtextout_jp.bin", key)
|
||||||
score_table = self.load_table_raw(f"{self.bin_dir}/tables", "mmScore.bin", key)
|
score_table = self.load_table_raw(f"{self.bin_dir}/tables", "mmScore.bin", key)
|
||||||
|
|
||||||
self.read_old_events(evt_table)
|
await self.read_old_events(evt_table)
|
||||||
self.read_old_music(score_table, txt_table)
|
await self.read_old_music(score_table, txt_table)
|
||||||
|
|
||||||
if self.opt_dir is not None:
|
if self.opt_dir is not None:
|
||||||
evt_table = self.load_table_raw(f"{self.opt_dir}/tables", "mmEvent.bin", key)
|
evt_table = self.load_table_raw(f"{self.opt_dir}/tables", "mmEvent.bin", key)
|
||||||
txt_table = self.load_table_raw(f"{self.opt_dir}/tables", "mmtextout_jp.bin", key)
|
txt_table = self.load_table_raw(f"{self.opt_dir}/tables", "mmtextout_jp.bin", key)
|
||||||
score_table = self.load_table_raw(f"{self.opt_dir}/tables", "mmScore.bin", key)
|
score_table = self.load_table_raw(f"{self.opt_dir}/tables", "mmScore.bin", key)
|
||||||
|
|
||||||
self.read_old_events(evt_table)
|
await self.read_old_events(evt_table)
|
||||||
self.read_old_music(score_table, txt_table)
|
await self.read_old_music(score_table, txt_table)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ class Mai2Reader(BaseReader):
|
|||||||
self.logger.warning("Failed load table content, skipping")
|
self.logger.warning("Failed load table content, skipping")
|
||||||
return
|
return
|
||||||
|
|
||||||
def get_events(self, base_dir: str) -> None:
|
async def get_events(self, base_dir: str) -> None:
|
||||||
self.logger.info(f"Reading events from {base_dir}...")
|
self.logger.info(f"Reading events from {base_dir}...")
|
||||||
|
|
||||||
for root, dirs, files in os.walk(base_dir):
|
for root, dirs, files in os.walk(base_dir):
|
||||||
@@ -192,12 +192,12 @@ class Mai2Reader(BaseReader):
|
|||||||
id = int(troot.find("name").find("id").text)
|
id = int(troot.find("name").find("id").text)
|
||||||
event_type = int(troot.find("infoType").text)
|
event_type = int(troot.find("infoType").text)
|
||||||
|
|
||||||
self.data.static.put_game_event(
|
await self.data.static.put_game_event(
|
||||||
self.version, event_type, id, name
|
self.version, event_type, id, name
|
||||||
)
|
)
|
||||||
self.logger.info(f"Added event {id}...")
|
self.logger.info(f"Added event {id}...")
|
||||||
|
|
||||||
def disable_events(
|
async def disable_events(
|
||||||
self, base_information_dir: str, base_score_ranking_dir: str
|
self, base_information_dir: str, base_score_ranking_dir: str
|
||||||
) -> None:
|
) -> None:
|
||||||
self.logger.info(f"Reading disabled events from {base_information_dir}...")
|
self.logger.info(f"Reading disabled events from {base_information_dir}...")
|
||||||
@@ -210,7 +210,7 @@ class Mai2Reader(BaseReader):
|
|||||||
|
|
||||||
event_id = int(troot.find("name").find("id").text)
|
event_id = int(troot.find("name").find("id").text)
|
||||||
|
|
||||||
self.data.static.toggle_game_event(
|
await self.data.static.toggle_game_event(
|
||||||
self.version, event_id, toggle=False
|
self.version, event_id, toggle=False
|
||||||
)
|
)
|
||||||
self.logger.info(f"Disabled event {event_id}...")
|
self.logger.info(f"Disabled event {event_id}...")
|
||||||
@@ -223,7 +223,7 @@ class Mai2Reader(BaseReader):
|
|||||||
|
|
||||||
event_id = int(troot.find("eventName").find("id").text)
|
event_id = int(troot.find("eventName").find("id").text)
|
||||||
|
|
||||||
self.data.static.toggle_game_event(
|
await self.data.static.toggle_game_event(
|
||||||
self.version, event_id, toggle=False
|
self.version, event_id, toggle=False
|
||||||
)
|
)
|
||||||
self.logger.info(f"Disabled event {event_id}...")
|
self.logger.info(f"Disabled event {event_id}...")
|
||||||
@@ -252,10 +252,10 @@ class Mai2Reader(BaseReader):
|
|||||||
22091518,
|
22091518,
|
||||||
22091519,
|
22091519,
|
||||||
]:
|
]:
|
||||||
self.data.static.toggle_game_event(self.version, event_id, toggle=False)
|
await self.data.static.toggle_game_event(self.version, event_id, toggle=False)
|
||||||
self.logger.info(f"Disabled event {event_id}...")
|
self.logger.info(f"Disabled event {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}...")
|
self.logger.info(f"Reading music from {base_dir}...")
|
||||||
|
|
||||||
for root, dirs, files in os.walk(base_dir):
|
for root, dirs, files in os.walk(base_dir):
|
||||||
@@ -285,7 +285,7 @@ class Mai2Reader(BaseReader):
|
|||||||
dif.find("notesDesigner").find("str").text
|
dif.find("notesDesigner").find("str").text
|
||||||
)
|
)
|
||||||
|
|
||||||
self.data.static.put_game_music(
|
await self.data.static.put_game_music(
|
||||||
self.version,
|
self.version,
|
||||||
song_id,
|
song_id,
|
||||||
chart_id,
|
chart_id,
|
||||||
@@ -302,7 +302,7 @@ class Mai2Reader(BaseReader):
|
|||||||
f"Added music id {song_id} chart {chart_id}"
|
f"Added music id {song_id} chart {chart_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def read_tickets(self, base_dir: str) -> None:
|
async def read_tickets(self, base_dir: str) -> None:
|
||||||
self.logger.info(f"Reading tickets from {base_dir}...")
|
self.logger.info(f"Reading tickets from {base_dir}...")
|
||||||
|
|
||||||
for root, dirs, files in os.walk(base_dir):
|
for root, dirs, files in os.walk(base_dir):
|
||||||
@@ -316,12 +316,12 @@ class Mai2Reader(BaseReader):
|
|||||||
ticket_type = int(troot.find("ticketKind").find("id").text)
|
ticket_type = int(troot.find("ticketKind").find("id").text)
|
||||||
price = int(troot.find("creditNum").text)
|
price = int(troot.find("creditNum").text)
|
||||||
|
|
||||||
self.data.static.put_game_ticket(
|
await self.data.static.put_game_ticket(
|
||||||
self.version, id, ticket_type, price, name
|
self.version, id, ticket_type, price, name
|
||||||
)
|
)
|
||||||
self.logger.info(f"Added ticket {id}...")
|
self.logger.info(f"Added ticket {id}...")
|
||||||
|
|
||||||
def read_old_events(self, events: Optional[List[Dict[str, str]]]) -> None:
|
async def read_old_events(self, events: Optional[List[Dict[str, str]]]) -> None:
|
||||||
if events is None:
|
if events is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -332,12 +332,12 @@ class Mai2Reader(BaseReader):
|
|||||||
is_aou = bool(int(event.get('AOU許可', '0')))
|
is_aou = bool(int(event.get('AOU許可', '0')))
|
||||||
name = event.get('comment', f'evt_{evt_id}')
|
name = event.get('comment', f'evt_{evt_id}')
|
||||||
|
|
||||||
self.data.static.put_game_event(self.version, 0, evt_id, name)
|
await self.data.static.put_game_event(self.version, 0, evt_id, name)
|
||||||
|
|
||||||
if not (is_exp or is_aou):
|
if not (is_exp or is_aou):
|
||||||
self.data.static.toggle_game_event(self.version, evt_id, False)
|
await self.data.static.toggle_game_event(self.version, evt_id, False)
|
||||||
|
|
||||||
def read_old_music(self, scores: Optional[List[Dict[str, str]]], text: Optional[List[Dict[str, str]]]) -> None:
|
async def read_old_music(self, scores: Optional[List[Dict[str, str]]], text: Optional[List[Dict[str, str]]]) -> None:
|
||||||
if scores is None or text is None:
|
if scores is None or text is None:
|
||||||
return
|
return
|
||||||
# TODO
|
# TODO
|
||||||
|
|||||||
+44
-44
@@ -186,7 +186,7 @@ print_detail = Table(
|
|||||||
|
|
||||||
|
|
||||||
class Mai2ItemData(BaseData):
|
class Mai2ItemData(BaseData):
|
||||||
def put_item(
|
async def put_item(
|
||||||
self, user_id: int, item_kind: int, item_id: int, stock: int, is_valid: bool
|
self, user_id: int, item_kind: int, item_id: int, stock: int, is_valid: bool
|
||||||
) -> None:
|
) -> None:
|
||||||
sql = insert(item).values(
|
sql = insert(item).values(
|
||||||
@@ -202,7 +202,7 @@ class Mai2ItemData(BaseData):
|
|||||||
isValid=is_valid,
|
isValid=is_valid,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_item: failed to insert item! user_id: {user_id}, item_kind: {item_kind}, item_id: {item_id}"
|
f"put_item: failed to insert item! user_id: {user_id}, item_kind: {item_kind}, item_id: {item_id}"
|
||||||
@@ -210,7 +210,7 @@ class Mai2ItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_items(self, user_id: int, item_kind: int = None) -> Optional[List[Row]]:
|
async def get_items(self, user_id: int, item_kind: int = None) -> Optional[List[Row]]:
|
||||||
if item_kind is None:
|
if item_kind is None:
|
||||||
sql = item.select(item.c.user == user_id)
|
sql = item.select(item.c.user == user_id)
|
||||||
else:
|
else:
|
||||||
@@ -218,12 +218,12 @@ class Mai2ItemData(BaseData):
|
|||||||
and_(item.c.user == user_id, item.c.itemKind == item_kind)
|
and_(item.c.user == user_id, item.c.itemKind == item_kind)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_item(self, user_id: int, item_kind: int, item_id: int) -> Optional[Row]:
|
async def get_item(self, user_id: int, item_kind: int, item_id: int) -> Optional[Row]:
|
||||||
sql = item.select(
|
sql = item.select(
|
||||||
and_(
|
and_(
|
||||||
item.c.user == user_id,
|
item.c.user == user_id,
|
||||||
@@ -232,12 +232,12 @@ class Mai2ItemData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_login_bonus(
|
async def put_login_bonus(
|
||||||
self,
|
self,
|
||||||
user_id: int,
|
user_id: int,
|
||||||
bonus_id: int,
|
bonus_id: int,
|
||||||
@@ -259,7 +259,7 @@ class Mai2ItemData(BaseData):
|
|||||||
isComplete=is_complete,
|
isComplete=is_complete,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_login_bonus: failed to insert item! user_id: {user_id}, bonus_id: {bonus_id}, point: {point}"
|
f"put_login_bonus: failed to insert item! user_id: {user_id}, bonus_id: {bonus_id}, point: {point}"
|
||||||
@@ -267,25 +267,25 @@ class Mai2ItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_login_bonuses(self, user_id: int) -> Optional[List[Row]]:
|
async def get_login_bonuses(self, user_id: int) -> Optional[List[Row]]:
|
||||||
sql = login_bonus.select(login_bonus.c.user == user_id)
|
sql = login_bonus.select(login_bonus.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_login_bonus(self, user_id: int, bonus_id: int) -> Optional[Row]:
|
async def get_login_bonus(self, user_id: int, bonus_id: int) -> Optional[Row]:
|
||||||
sql = login_bonus.select(
|
sql = login_bonus.select(
|
||||||
and_(login_bonus.c.user == user_id, login_bonus.c.bonus_id == bonus_id)
|
and_(login_bonus.c.user == user_id, login_bonus.c.bonus_id == bonus_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_map(
|
async def put_map(
|
||||||
self,
|
self,
|
||||||
user_id: int,
|
user_id: int,
|
||||||
map_id: int,
|
map_id: int,
|
||||||
@@ -310,7 +310,7 @@ class Mai2ItemData(BaseData):
|
|||||||
isComplete=is_complete,
|
isComplete=is_complete,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_map: failed to insert item! user_id: {user_id}, map_id: {map_id}, distance: {distance}"
|
f"put_map: failed to insert item! user_id: {user_id}, map_id: {map_id}, distance: {distance}"
|
||||||
@@ -318,28 +318,28 @@ class Mai2ItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_maps(self, user_id: int) -> Optional[List[Row]]:
|
async def get_maps(self, user_id: int) -> Optional[List[Row]]:
|
||||||
sql = map.select(map.c.user == user_id)
|
sql = map.select(map.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_map(self, user_id: int, map_id: int) -> Optional[Row]:
|
async def get_map(self, user_id: int, map_id: int) -> Optional[Row]:
|
||||||
sql = map.select(and_(map.c.user == user_id, map.c.mapId == map_id))
|
sql = map.select(and_(map.c.user == user_id, map.c.mapId == map_id))
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_character_(self, user_id: int, char_data: Dict) -> Optional[int]:
|
async def put_character_(self, user_id: int, char_data: Dict) -> Optional[int]:
|
||||||
char_data["user"] = user_id
|
char_data["user"] = user_id
|
||||||
sql = insert(character).values(**char_data)
|
sql = insert(character).values(**char_data)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**char_data)
|
conflict = sql.on_duplicate_key_update(**char_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_character_: failed to insert item! user_id: {user_id}"
|
f"put_character_: failed to insert item! user_id: {user_id}"
|
||||||
@@ -347,7 +347,7 @@ class Mai2ItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_character(
|
async def put_character(
|
||||||
self,
|
self,
|
||||||
user_id: int,
|
user_id: int,
|
||||||
character_id: int,
|
character_id: int,
|
||||||
@@ -369,7 +369,7 @@ class Mai2ItemData(BaseData):
|
|||||||
useCount=use_count,
|
useCount=use_count,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_character: failed to insert item! user_id: {user_id}, character_id: {character_id}, level: {level}"
|
f"put_character: failed to insert item! user_id: {user_id}, character_id: {character_id}, level: {level}"
|
||||||
@@ -377,33 +377,33 @@ class Mai2ItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_characters(self, user_id: int) -> Optional[List[Row]]:
|
async def get_characters(self, user_id: int) -> Optional[List[Row]]:
|
||||||
sql = character.select(character.c.user == user_id)
|
sql = character.select(character.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_character(self, user_id: int, character_id: int) -> Optional[Row]:
|
async def get_character(self, user_id: int, character_id: int) -> Optional[Row]:
|
||||||
sql = character.select(
|
sql = character.select(
|
||||||
and_(character.c.user == user_id, character.c.character_id == character_id)
|
and_(character.c.user == user_id, character.c.character_id == character_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def get_friend_season_ranking(self, user_id: int) -> Optional[Row]:
|
async def get_friend_season_ranking(self, user_id: int) -> Optional[Row]:
|
||||||
sql = friend_season_ranking.select(friend_season_ranking.c.user == user_id)
|
sql = friend_season_ranking.select(friend_season_ranking.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_friend_season_ranking(
|
async def put_friend_season_ranking(
|
||||||
self, aime_id: int, friend_season_ranking_data: Dict
|
self, aime_id: int, friend_season_ranking_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(friend_season_ranking).values(
|
sql = insert(friend_season_ranking).values(
|
||||||
@@ -411,7 +411,7 @@ class Mai2ItemData(BaseData):
|
|||||||
)
|
)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**friend_season_ranking_data)
|
conflict = sql.on_duplicate_key_update(**friend_season_ranking_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
@@ -421,7 +421,7 @@ class Mai2ItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_favorite(
|
async def put_favorite(
|
||||||
self, user_id: int, kind: int, item_id_list: List[int]
|
self, user_id: int, kind: int, item_id_list: List[int]
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(favorite).values(
|
sql = insert(favorite).values(
|
||||||
@@ -430,7 +430,7 @@ class Mai2ItemData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(item_id_list=item_id_list)
|
conflict = sql.on_duplicate_key_update(item_id_list=item_id_list)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_favorite: failed to insert item! user_id: {user_id}, kind: {kind}"
|
f"put_favorite: failed to insert item! user_id: {user_id}, kind: {kind}"
|
||||||
@@ -438,7 +438,7 @@ class Mai2ItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_favorites(self, user_id: int, kind: int = None) -> Optional[Row]:
|
async def get_favorites(self, user_id: int, kind: int = None) -> Optional[Row]:
|
||||||
if kind is None:
|
if kind is None:
|
||||||
sql = favorite.select(favorite.c.user == user_id)
|
sql = favorite.select(favorite.c.user == user_id)
|
||||||
else:
|
else:
|
||||||
@@ -446,12 +446,12 @@ class Mai2ItemData(BaseData):
|
|||||||
and_(favorite.c.user == user_id, favorite.c.itemKind == kind)
|
and_(favorite.c.user == user_id, favorite.c.itemKind == kind)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_card(
|
async def put_card(
|
||||||
self,
|
self,
|
||||||
user_id: int,
|
user_id: int,
|
||||||
card_type_id: int,
|
card_type_id: int,
|
||||||
@@ -475,7 +475,7 @@ class Mai2ItemData(BaseData):
|
|||||||
charaId=chara_id, mapId=map_id, startDate=start_date, endDate=end_date
|
charaId=chara_id, mapId=map_id, startDate=start_date, endDate=end_date
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_card: failed to insert card! user_id: {user_id}, kind: {card_kind}"
|
f"put_card: failed to insert card! user_id: {user_id}, kind: {card_kind}"
|
||||||
@@ -483,7 +483,7 @@ class Mai2ItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_cards(self, user_id: int, kind: int = None) -> Optional[Row]:
|
async def get_cards(self, user_id: int, kind: int = None) -> Optional[Row]:
|
||||||
if kind is None:
|
if kind is None:
|
||||||
sql = card.select(card.c.user == user_id)
|
sql = card.select(card.c.user == user_id)
|
||||||
else:
|
else:
|
||||||
@@ -491,12 +491,12 @@ class Mai2ItemData(BaseData):
|
|||||||
|
|
||||||
sql = sql.order_by(card.c.startDate.desc())
|
sql = sql.order_by(card.c.startDate.desc())
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_charge(
|
async def put_charge(
|
||||||
self,
|
self,
|
||||||
user_id: int,
|
user_id: int,
|
||||||
charge_id: int,
|
charge_id: int,
|
||||||
@@ -516,7 +516,7 @@ class Mai2ItemData(BaseData):
|
|||||||
stock=stock, purchaseDate=purchase_date, validDate=valid_date
|
stock=stock, purchaseDate=purchase_date, validDate=valid_date
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_card: failed to insert charge! user_id: {user_id}, chargeId: {charge_id}"
|
f"put_card: failed to insert charge! user_id: {user_id}, chargeId: {charge_id}"
|
||||||
@@ -524,15 +524,15 @@ class Mai2ItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_charges(self, user_id: int) -> Optional[Row]:
|
async def get_charges(self, user_id: int) -> Optional[Row]:
|
||||||
sql = charge.select(charge.c.user == user_id)
|
sql = charge.select(charge.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_user_print_detail(
|
async def put_user_print_detail(
|
||||||
self, aime_id: int, serial_id: str, user_print_data: Dict
|
self, aime_id: int, serial_id: str, user_print_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(print_detail).values(
|
sql = insert(print_detail).values(
|
||||||
@@ -540,7 +540,7 @@ class Mai2ItemData(BaseData):
|
|||||||
)
|
)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**user_print_data)
|
conflict = sql.on_duplicate_key_update(**user_print_data)
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ consec_logins = Table(
|
|||||||
|
|
||||||
|
|
||||||
class Mai2ProfileData(BaseData):
|
class Mai2ProfileData(BaseData):
|
||||||
def put_profile_detail(
|
async def put_profile_detail(
|
||||||
self, user_id: int, version: int, detail_data: Dict, is_dx: bool = True
|
self, user_id: int, version: int, detail_data: Dict, is_dx: bool = True
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
detail_data["user"] = user_id
|
detail_data["user"] = user_id
|
||||||
@@ -504,7 +504,7 @@ class Mai2ProfileData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**detail_data)
|
conflict = sql.on_duplicate_key_update(**detail_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_profile: Failed to create profile! user_id {user_id} is_dx {is_dx}"
|
f"put_profile: Failed to create profile! user_id {user_id} is_dx {is_dx}"
|
||||||
@@ -512,7 +512,7 @@ class Mai2ProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_detail(
|
async def get_profile_detail(
|
||||||
self, user_id: int, version: int, is_dx: bool = True
|
self, user_id: int, version: int, is_dx: bool = True
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
if is_dx:
|
if is_dx:
|
||||||
@@ -531,12 +531,12 @@ class Mai2ProfileData(BaseData):
|
|||||||
.order_by(detail_old.c.version.desc())
|
.order_by(detail_old.c.version.desc())
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_profile_ghost(
|
async def put_profile_ghost(
|
||||||
self, user_id: int, version: int, ghost_data: Dict
|
self, user_id: int, version: int, ghost_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
ghost_data["user"] = user_id
|
ghost_data["user"] = user_id
|
||||||
@@ -545,25 +545,25 @@ class Mai2ProfileData(BaseData):
|
|||||||
sql = insert(ghost).values(**ghost_data)
|
sql = insert(ghost).values(**ghost_data)
|
||||||
conflict = sql.on_duplicate_key_update(**ghost_data)
|
conflict = sql.on_duplicate_key_update(**ghost_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"put_profile_ghost: failed to update! {user_id}")
|
self.logger.warning(f"put_profile_ghost: failed to update! {user_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_ghost(self, user_id: int, version: int) -> Optional[Row]:
|
async def get_profile_ghost(self, user_id: int, version: int) -> Optional[Row]:
|
||||||
sql = (
|
sql = (
|
||||||
select(ghost)
|
select(ghost)
|
||||||
.where(and_(ghost.c.user == user_id, ghost.c.version_int <= version))
|
.where(and_(ghost.c.user == user_id, ghost.c.version_int <= version))
|
||||||
.order_by(ghost.c.version.desc())
|
.order_by(ghost.c.version.desc())
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_profile_extend(
|
async def put_profile_extend(
|
||||||
self, user_id: int, version: int, extend_data: Dict
|
self, user_id: int, version: int, extend_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
extend_data["user"] = user_id
|
extend_data["user"] = user_id
|
||||||
@@ -572,25 +572,25 @@ class Mai2ProfileData(BaseData):
|
|||||||
sql = insert(extend).values(**extend_data)
|
sql = insert(extend).values(**extend_data)
|
||||||
conflict = sql.on_duplicate_key_update(**extend_data)
|
conflict = sql.on_duplicate_key_update(**extend_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"put_profile_extend: failed to update! {user_id}")
|
self.logger.warning(f"put_profile_extend: failed to update! {user_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_extend(self, user_id: int, version: int) -> Optional[Row]:
|
async def get_profile_extend(self, user_id: int, version: int) -> Optional[Row]:
|
||||||
sql = (
|
sql = (
|
||||||
select(extend)
|
select(extend)
|
||||||
.where(and_(extend.c.user == user_id, extend.c.version <= version))
|
.where(and_(extend.c.user == user_id, extend.c.version <= version))
|
||||||
.order_by(extend.c.version.desc())
|
.order_by(extend.c.version.desc())
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_profile_option(
|
async def put_profile_option(
|
||||||
self, user_id: int, version: int, option_data: Dict, is_dx: bool = True
|
self, user_id: int, version: int, option_data: Dict, is_dx: bool = True
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
option_data["user"] = user_id
|
option_data["user"] = user_id
|
||||||
@@ -602,7 +602,7 @@ class Mai2ProfileData(BaseData):
|
|||||||
sql = insert(option_old).values(**option_data)
|
sql = insert(option_old).values(**option_data)
|
||||||
conflict = sql.on_duplicate_key_update(**option_data)
|
conflict = sql.on_duplicate_key_update(**option_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_profile_option: failed to update! {user_id} is_dx {is_dx}"
|
f"put_profile_option: failed to update! {user_id} is_dx {is_dx}"
|
||||||
@@ -610,7 +610,7 @@ class Mai2ProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_option(
|
async def get_profile_option(
|
||||||
self, user_id: int, version: int, is_dx: bool = True
|
self, user_id: int, version: int, is_dx: bool = True
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
if is_dx:
|
if is_dx:
|
||||||
@@ -628,12 +628,12 @@ class Mai2ProfileData(BaseData):
|
|||||||
.order_by(option_old.c.version.desc())
|
.order_by(option_old.c.version.desc())
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_profile_rating(
|
async def put_profile_rating(
|
||||||
self, user_id: int, version: int, rating_data: Dict
|
self, user_id: int, version: int, rating_data: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
rating_data["user"] = user_id
|
rating_data["user"] = user_id
|
||||||
@@ -642,25 +642,25 @@ class Mai2ProfileData(BaseData):
|
|||||||
sql = insert(rating).values(**rating_data)
|
sql = insert(rating).values(**rating_data)
|
||||||
conflict = sql.on_duplicate_key_update(**rating_data)
|
conflict = sql.on_duplicate_key_update(**rating_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"put_profile_rating: failed to update! {user_id}")
|
self.logger.warning(f"put_profile_rating: failed to update! {user_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_rating(self, user_id: int, version: int) -> Optional[Row]:
|
async def get_profile_rating(self, user_id: int, version: int) -> Optional[Row]:
|
||||||
sql = (
|
sql = (
|
||||||
select(rating)
|
select(rating)
|
||||||
.where(and_(rating.c.user == user_id, rating.c.version <= version))
|
.where(and_(rating.c.user == user_id, rating.c.version <= version))
|
||||||
.order_by(rating.c.version.desc())
|
.order_by(rating.c.version.desc())
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_profile_region(self, user_id: int, region_id: int) -> Optional[int]:
|
async def put_profile_region(self, user_id: int, region_id: int) -> Optional[int]:
|
||||||
sql = insert(region).values(
|
sql = insert(region).values(
|
||||||
user=user_id,
|
user=user_id,
|
||||||
regionId=region_id,
|
regionId=region_id,
|
||||||
@@ -669,21 +669,21 @@ class Mai2ProfileData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(playCount=region.c.playCount + 1)
|
conflict = sql.on_duplicate_key_update(playCount=region.c.playCount + 1)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"put_region: failed to update! {user_id}")
|
self.logger.warning(f"put_region: failed to update! {user_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_regions(self, user_id: int) -> Optional[List[Dict]]:
|
async def get_regions(self, user_id: int) -> Optional[List[Dict]]:
|
||||||
sql = select(region).where(region.c.user == user_id)
|
sql = select(region).where(region.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_profile_activity(self, user_id: int, activity_data: Dict) -> Optional[int]:
|
async def put_profile_activity(self, user_id: int, activity_data: Dict) -> Optional[int]:
|
||||||
if "id" in activity_data:
|
if "id" in activity_data:
|
||||||
activity_data["activityId"] = activity_data["id"]
|
activity_data["activityId"] = activity_data["id"]
|
||||||
activity_data.pop("id")
|
activity_data.pop("id")
|
||||||
@@ -694,7 +694,7 @@ class Mai2ProfileData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**activity_data)
|
conflict = sql.on_duplicate_key_update(**activity_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_profile_activity: failed to update! user_id: {user_id}"
|
f"put_profile_activity: failed to update! user_id: {user_id}"
|
||||||
@@ -702,7 +702,7 @@ class Mai2ProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_profile_activity(
|
async def get_profile_activity(
|
||||||
self, user_id: int, kind: int = None
|
self, user_id: int, kind: int = None
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = activity.select(
|
sql = activity.select(
|
||||||
@@ -712,12 +712,12 @@ class Mai2ProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_web_option(
|
async def put_web_option(
|
||||||
self, user_id: int, version: int, web_opts: Dict
|
self, user_id: int, version: int, web_opts: Dict
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
web_opts["user"] = user_id
|
web_opts["user"] = user_id
|
||||||
@@ -726,29 +726,29 @@ class Mai2ProfileData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**web_opts)
|
conflict = sql.on_duplicate_key_update(**web_opts)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"put_web_option: failed to update! user_id: {user_id}")
|
self.logger.warning(f"put_web_option: failed to update! user_id: {user_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_web_option(self, user_id: int, version: int) -> Optional[Row]:
|
async def get_web_option(self, user_id: int, version: int) -> Optional[Row]:
|
||||||
sql = web_opt.select(
|
sql = web_opt.select(
|
||||||
and_(web_opt.c.user == user_id, web_opt.c.version == version)
|
and_(web_opt.c.user == user_id, web_opt.c.version == version)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_grade_status(self, user_id: int, grade_stat: Dict) -> Optional[int]:
|
async def put_grade_status(self, user_id: int, grade_stat: Dict) -> Optional[int]:
|
||||||
grade_stat["user"] = user_id
|
grade_stat["user"] = user_id
|
||||||
sql = insert(grade_status).values(**grade_stat)
|
sql = insert(grade_status).values(**grade_stat)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**grade_stat)
|
conflict = sql.on_duplicate_key_update(**grade_stat)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_grade_status: failed to update! user_id: {user_id}"
|
f"put_grade_status: failed to update! user_id: {user_id}"
|
||||||
@@ -756,40 +756,40 @@ class Mai2ProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_grade_status(self, user_id: int) -> Optional[Row]:
|
async def get_grade_status(self, user_id: int) -> Optional[Row]:
|
||||||
sql = grade_status.select(grade_status.c.user == user_id)
|
sql = grade_status.select(grade_status.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_boss_list(self, user_id: int, boss_stat: Dict) -> Optional[int]:
|
async def put_boss_list(self, user_id: int, boss_stat: Dict) -> Optional[int]:
|
||||||
boss_stat["user"] = user_id
|
boss_stat["user"] = user_id
|
||||||
sql = insert(boss).values(**boss_stat)
|
sql = insert(boss).values(**boss_stat)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**boss_stat)
|
conflict = sql.on_duplicate_key_update(**boss_stat)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"put_boss_list: failed to update! user_id: {user_id}")
|
self.logger.warning(f"put_boss_list: failed to update! user_id: {user_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_boss_list(self, user_id: int) -> Optional[Row]:
|
async def get_boss_list(self, user_id: int) -> Optional[Row]:
|
||||||
sql = boss.select(boss.c.user == user_id)
|
sql = boss.select(boss.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_recent_rating(self, user_id: int, rr: Dict) -> Optional[int]:
|
async def put_recent_rating(self, user_id: int, rr: Dict) -> Optional[int]:
|
||||||
sql = insert(recent_rating).values(user=user_id, userRecentRatingList=rr)
|
sql = insert(recent_rating).values(user=user_id, userRecentRatingList=rr)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update({"userRecentRatingList": rr})
|
conflict = sql.on_duplicate_key_update({"userRecentRatingList": rr})
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_recent_rating: failed to update! user_id: {user_id}"
|
f"put_recent_rating: failed to update! user_id: {user_id}"
|
||||||
@@ -797,26 +797,26 @@ class Mai2ProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_recent_rating(self, user_id: int) -> Optional[Row]:
|
async def get_recent_rating(self, user_id: int) -> Optional[Row]:
|
||||||
sql = recent_rating.select(recent_rating.c.user == user_id)
|
sql = recent_rating.select(recent_rating.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def add_consec_login(self, user_id: int, version: int) -> None:
|
async def add_consec_login(self, user_id: int, version: int) -> None:
|
||||||
sql = insert(consec_logins).values(user=user_id, version=version, logins=1)
|
sql = insert(consec_logins).values(user=user_id, version=version, logins=1)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(logins=consec_logins.c.logins + 1)
|
conflict = sql.on_duplicate_key_update(logins=consec_logins.c.logins + 1)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"Failed to update consecutive login count for user {user_id} version {version}"
|
f"Failed to update consecutive login count for user {user_id} version {version}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_consec_login(self, user_id: int, version: int) -> Optional[Row]:
|
async def get_consec_login(self, user_id: int, version: int) -> Optional[Row]:
|
||||||
sql = select(consec_logins).where(
|
sql = select(consec_logins).where(
|
||||||
and_(
|
and_(
|
||||||
consec_logins.c.user == user_id,
|
consec_logins.c.user == user_id,
|
||||||
@@ -824,12 +824,12 @@ class Mai2ProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def reset_consec_login(self, user_id: int, version: int) -> Optional[Row]:
|
async def reset_consec_login(self, user_id: int, version: int) -> Optional[Row]:
|
||||||
sql = consec_logins.update(
|
sql = consec_logins.update(
|
||||||
and_(
|
and_(
|
||||||
consec_logins.c.user == user_id,
|
consec_logins.c.user == user_id,
|
||||||
@@ -837,7 +837,7 @@ class Mai2ProfileData(BaseData):
|
|||||||
)
|
)
|
||||||
).values(logins=1)
|
).values(logins=1)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|||||||
+12
-12
@@ -273,7 +273,7 @@ best_score_old = Table(
|
|||||||
)
|
)
|
||||||
|
|
||||||
class Mai2ScoreData(BaseData):
|
class Mai2ScoreData(BaseData):
|
||||||
def put_best_score(self, user_id: int, score_data: Dict, is_dx: bool = True) -> Optional[int]:
|
async def put_best_score(self, user_id: int, score_data: Dict, is_dx: bool = True) -> Optional[int]:
|
||||||
score_data["user"] = user_id
|
score_data["user"] = user_id
|
||||||
|
|
||||||
if is_dx:
|
if is_dx:
|
||||||
@@ -282,7 +282,7 @@ class Mai2ScoreData(BaseData):
|
|||||||
sql = insert(best_score_old).values(**score_data)
|
sql = insert(best_score_old).values(**score_data)
|
||||||
conflict = sql.on_duplicate_key_update(**score_data)
|
conflict = sql.on_duplicate_key_update(**score_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
f"put_best_score: Failed to insert best score! user_id {user_id} is_dx {is_dx}"
|
f"put_best_score: Failed to insert best score! user_id {user_id} is_dx {is_dx}"
|
||||||
@@ -291,7 +291,7 @@ class Mai2ScoreData(BaseData):
|
|||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
@cached(2)
|
@cached(2)
|
||||||
def get_best_scores(self, user_id: int, song_id: int = None, is_dx: bool = True) -> Optional[List[Row]]:
|
async def get_best_scores(self, user_id: int, song_id: int = None, is_dx: bool = True) -> Optional[List[Row]]:
|
||||||
if is_dx:
|
if is_dx:
|
||||||
sql = best_score.select(
|
sql = best_score.select(
|
||||||
and_(
|
and_(
|
||||||
@@ -307,12 +307,12 @@ class Mai2ScoreData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_best_score(
|
async def get_best_score(
|
||||||
self, user_id: int, song_id: int, chart_id: int
|
self, user_id: int, song_id: int, chart_id: int
|
||||||
) -> Optional[Row]:
|
) -> Optional[Row]:
|
||||||
sql = best_score.select(
|
sql = best_score.select(
|
||||||
@@ -323,12 +323,12 @@ class Mai2ScoreData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_playlog(self, user_id: int, playlog_data: Dict, is_dx: bool = True) -> Optional[int]:
|
async def put_playlog(self, user_id: int, playlog_data: Dict, is_dx: bool = True) -> Optional[int]:
|
||||||
playlog_data["user"] = user_id
|
playlog_data["user"] = user_id
|
||||||
|
|
||||||
if is_dx:
|
if is_dx:
|
||||||
@@ -338,28 +338,28 @@ class Mai2ScoreData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**playlog_data)
|
conflict = sql.on_duplicate_key_update(**playlog_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(f"put_playlog: Failed to insert! user_id {user_id} is_dx {is_dx}")
|
self.logger.error(f"put_playlog: Failed to insert! user_id {user_id} is_dx {is_dx}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_course(self, user_id: int, course_data: Dict) -> Optional[int]:
|
async def put_course(self, user_id: int, course_data: Dict) -> Optional[int]:
|
||||||
course_data["user"] = user_id
|
course_data["user"] = user_id
|
||||||
sql = insert(course).values(**course_data)
|
sql = insert(course).values(**course_data)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**course_data)
|
conflict = sql.on_duplicate_key_update(**course_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.error(f"put_course: Failed to insert! user_id {user_id}")
|
self.logger.error(f"put_course: Failed to insert! user_id {user_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_courses(self, user_id: int) -> Optional[List[Row]]:
|
async def get_courses(self, user_id: int) -> Optional[List[Row]]:
|
||||||
sql = course.select(course.c.user == user_id)
|
sql = course.select(course.c.user == user_id)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ cards = Table(
|
|||||||
|
|
||||||
|
|
||||||
class Mai2StaticData(BaseData):
|
class Mai2StaticData(BaseData):
|
||||||
def put_game_event(
|
async def put_game_event(
|
||||||
self, version: int, type: int, event_id: int, name: str
|
self, version: int, type: int, event_id: int, name: str
|
||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
sql = insert(event).values(
|
sql = insert(event).values(
|
||||||
@@ -84,46 +84,46 @@ class Mai2StaticData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(eventId=event_id)
|
conflict = sql.on_duplicate_key_update(eventId=event_id)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"put_game_event: Failed to insert event! event_id {event_id} type {type} name {name}"
|
f"put_game_event: Failed to insert event! event_id {event_id} type {type} name {name}"
|
||||||
)
|
)
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_game_events(self, version: int) -> Optional[List[Row]]:
|
async def get_game_events(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = event.select(event.c.version == version)
|
sql = event.select(event.c.version == version)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_enabled_events(self, version: int) -> Optional[List[Row]]:
|
async def get_enabled_events(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = select(event).where(
|
sql = select(event).where(
|
||||||
and_(event.c.version == version, event.c.enabled == True)
|
and_(event.c.version == version, event.c.enabled == True)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def toggle_game_event(
|
async def toggle_game_event(
|
||||||
self, version: int, event_id: int, toggle: bool
|
self, version: int, event_id: int, toggle: bool
|
||||||
) -> Optional[List]:
|
) -> Optional[List]:
|
||||||
sql = event.update(
|
sql = event.update(
|
||||||
and_(event.c.version == version, event.c.eventId == event_id)
|
and_(event.c.version == version, event.c.eventId == event_id)
|
||||||
).values(enabled=int(toggle))
|
).values(enabled=int(toggle))
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
f"toggle_game_event: Failed to update event! event_id {event_id} toggle {toggle}"
|
f"toggle_game_event: Failed to update event! event_id {event_id} toggle {toggle}"
|
||||||
)
|
)
|
||||||
return result.last_updated_params()
|
return result.last_updated_params()
|
||||||
|
|
||||||
def put_game_music(
|
async def put_game_music(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
song_id: int,
|
song_id: int,
|
||||||
@@ -159,13 +159,13 @@ class Mai2StaticData(BaseData):
|
|||||||
noteDesigner=note_designer,
|
noteDesigner=note_designer,
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"Failed to insert song {song_id} chart {chart_id}")
|
self.logger.warning(f"Failed to insert song {song_id} chart {chart_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def put_game_ticket(
|
async def put_game_ticket(
|
||||||
self,
|
self,
|
||||||
version: int,
|
version: int,
|
||||||
ticket_id: int,
|
ticket_id: int,
|
||||||
@@ -185,13 +185,13 @@ class Mai2StaticData(BaseData):
|
|||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(price=ticket_price)
|
conflict = sql.on_duplicate_key_update(price=ticket_price)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"Failed to insert charge {ticket_id} type {ticket_type}")
|
self.logger.warning(f"Failed to insert charge {ticket_id} type {ticket_type}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_enabled_tickets(
|
async def get_enabled_tickets(
|
||||||
self, version: int, kind: int = None
|
self, version: int, kind: int = None
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
if kind is not None:
|
if kind is not None:
|
||||||
@@ -207,12 +207,12 @@ class Mai2StaticData(BaseData):
|
|||||||
and_(ticket.c.version == version, ticket.c.enabled == True)
|
and_(ticket.c.version == version, ticket.c.enabled == True)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def get_music_chart(
|
async def get_music_chart(
|
||||||
self, version: int, song_id: int, chart_id: int
|
self, version: int, song_id: int, chart_id: int
|
||||||
) -> Optional[List[Row]]:
|
) -> Optional[List[Row]]:
|
||||||
sql = select(music).where(
|
sql = select(music).where(
|
||||||
@@ -223,28 +223,28 @@ class Mai2StaticData(BaseData):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_card(self, version: int, card_id: int, card_name: str, **card_data) -> int:
|
async def put_card(self, version: int, card_id: int, card_name: str, **card_data) -> int:
|
||||||
sql = insert(cards).values(
|
sql = insert(cards).values(
|
||||||
version=version, cardId=card_id, cardName=card_name, **card_data
|
version=version, cardId=card_id, cardName=card_name, **card_data
|
||||||
)
|
)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**card_data)
|
conflict = sql.on_duplicate_key_update(**card_data)
|
||||||
|
|
||||||
result = self.execute(conflict)
|
result = await self.execute(conflict)
|
||||||
if result is None:
|
if result is None:
|
||||||
self.logger.warning(f"Failed to insert card {card_id}")
|
self.logger.warning(f"Failed to insert card {card_id}")
|
||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_enabled_cards(self, version: int) -> Optional[List[Row]]:
|
async def get_enabled_cards(self, version: int) -> Optional[List[Row]]:
|
||||||
sql = cards.select(and_(cards.c.version == version, cards.c.enabled == True))
|
sql = cards.select(and_(cards.c.version == version, cards.c.enabled == True))
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = await self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|||||||
+10
-10
@@ -16,7 +16,7 @@ class Mai2Universe(Mai2SplashPlus):
|
|||||||
self.version = Mai2Constants.VER_MAIMAI_DX_UNIVERSE
|
self.version = Mai2Constants.VER_MAIMAI_DX_UNIVERSE
|
||||||
|
|
||||||
async def handle_cm_get_user_preview_api_request(self, data: Dict) -> Dict:
|
async def handle_cm_get_user_preview_api_request(self, data: Dict) -> Dict:
|
||||||
p = self.data.profile.get_profile_detail(data["userId"], self.version)
|
p = await self.data.profile.get_profile_detail(data["userId"], self.version)
|
||||||
if p is None:
|
if p is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -32,9 +32,9 @@ class Mai2Universe(Mai2SplashPlus):
|
|||||||
|
|
||||||
async def handle_cm_get_user_data_api_request(self, data: Dict) -> Dict:
|
async def handle_cm_get_user_data_api_request(self, data: Dict) -> Dict:
|
||||||
# user already exists, because the preview checks that already
|
# user already exists, because the preview checks that already
|
||||||
p = self.data.profile.get_profile_detail(data["userId"], self.version)
|
p = await self.data.profile.get_profile_detail(data["userId"], self.version)
|
||||||
|
|
||||||
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:
|
if cards is None or len(cards) == 0:
|
||||||
# This should never happen
|
# This should never happen
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
@@ -59,7 +59,7 @@ class Mai2Universe(Mai2SplashPlus):
|
|||||||
return {"returnCode": 1}
|
return {"returnCode": 1}
|
||||||
|
|
||||||
async def handle_cm_get_selling_card_api_request(self, data: Dict) -> Dict:
|
async def handle_cm_get_selling_card_api_request(self, data: Dict) -> Dict:
|
||||||
selling_cards = self.data.static.get_enabled_cards(self.version)
|
selling_cards = await self.data.static.get_enabled_cards(self.version)
|
||||||
if selling_cards is None:
|
if selling_cards is None:
|
||||||
return {"length": 0, "sellingCardList": []}
|
return {"length": 0, "sellingCardList": []}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ class Mai2Universe(Mai2SplashPlus):
|
|||||||
return {"length": len(selling_card_list), "sellingCardList": selling_card_list}
|
return {"length": len(selling_card_list), "sellingCardList": selling_card_list}
|
||||||
|
|
||||||
async def handle_cm_get_user_card_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_cards is None:
|
||||||
return {"returnCode": 1, "length": 0, "nextIndex": 0, "userCardList": []}
|
return {"returnCode": 1, "length": 0, "nextIndex": 0, "userCardList": []}
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ class Mai2Universe(Mai2SplashPlus):
|
|||||||
super().handle_get_user_item_api_request(data)
|
super().handle_get_user_item_api_request(data)
|
||||||
|
|
||||||
async def handle_cm_get_user_character_api_request(self, data: Dict) -> Dict:
|
async def handle_cm_get_user_character_api_request(self, data: Dict) -> Dict:
|
||||||
characters = self.data.item.get_characters(data["userId"])
|
characters = await self.data.item.get_characters(data["userId"])
|
||||||
|
|
||||||
chara_list = []
|
chara_list = []
|
||||||
for chara in characters:
|
for chara in characters:
|
||||||
@@ -168,7 +168,7 @@ class Mai2Universe(Mai2SplashPlus):
|
|||||||
end_date = datetime.utcnow() + timedelta(days=15)
|
end_date = datetime.utcnow() + timedelta(days=15)
|
||||||
|
|
||||||
user_card = upsert["userCard"]
|
user_card = upsert["userCard"]
|
||||||
self.data.item.put_card(
|
await self.data.item.put_card(
|
||||||
user_id,
|
user_id,
|
||||||
user_card["cardId"],
|
user_card["cardId"],
|
||||||
user_card["cardTypeId"],
|
user_card["cardTypeId"],
|
||||||
@@ -180,7 +180,7 @@ class Mai2Universe(Mai2SplashPlus):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# get the profile extend to save the new bought card
|
# get the profile extend to save the new bought card
|
||||||
extend = self.data.profile.get_profile_extend(user_id, self.version)
|
extend = await self.data.profile.get_profile_extend(user_id, self.version)
|
||||||
if extend:
|
if extend:
|
||||||
extend = extend._asdict()
|
extend = extend._asdict()
|
||||||
# parse the selectedCardList
|
# parse the selectedCardList
|
||||||
@@ -192,14 +192,14 @@ class Mai2Universe(Mai2SplashPlus):
|
|||||||
selected_cards.insert(0, user_card["cardTypeId"])
|
selected_cards.insert(0, user_card["cardTypeId"])
|
||||||
|
|
||||||
extend["selectedCardList"] = selected_cards
|
extend["selectedCardList"] = selected_cards
|
||||||
self.data.profile.put_profile_extend(user_id, self.version, extend)
|
await self.data.profile.put_profile_extend(user_id, self.version, extend)
|
||||||
|
|
||||||
# properly format userPrintDetail for the database
|
# properly format userPrintDetail for the database
|
||||||
upsert.pop("userCard")
|
upsert.pop("userCard")
|
||||||
upsert.pop("serialId")
|
upsert.pop("serialId")
|
||||||
upsert["printDate"] = datetime.strptime(upsert["printDate"], "%Y-%m-%d")
|
upsert["printDate"] = datetime.strptime(upsert["printDate"], "%Y-%m-%d")
|
||||||
|
|
||||||
self.data.item.put_user_print_detail(user_id, serial_id, upsert)
|
await self.data.item.put_user_print_detail(user_id, serial_id, upsert)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"returnCode": 1,
|
"returnCode": 1,
|
||||||
|
|||||||
+71
-71
@@ -157,7 +157,7 @@ class OngekiBase:
|
|||||||
return {"type": data["type"], "length": 0, "gameIdlistList": []}
|
return {"type": data["type"], "length": 0, "gameIdlistList": []}
|
||||||
|
|
||||||
async def handle_get_game_ranking_api_request(self, data: Dict) -> Dict:
|
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 = []
|
ranking_list = []
|
||||||
for music in game_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:
|
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 = []
|
game_point = []
|
||||||
|
|
||||||
if not get_game_point:
|
if not get_game_point:
|
||||||
self.logger.info(f"GP table is empty, inserting defaults")
|
self.logger.info(f"GP table is empty, inserting defaults")
|
||||||
self.data.static.put_static_game_point_defaults()
|
await self.data.static.put_static_game_point_defaults()
|
||||||
get_game_point = self.data.static.get_static_game_point()
|
get_game_point = await self.data.static.get_static_game_point()
|
||||||
for gp in get_game_point:
|
for gp in get_game_point:
|
||||||
tmp = gp._asdict()
|
tmp = gp._asdict()
|
||||||
game_point.append(tmp)
|
game_point.append(tmp)
|
||||||
@@ -204,7 +204,7 @@ class OngekiBase:
|
|||||||
return {"returnCode": 1, "apiName": "ExtendLockTimeApi"}
|
return {"returnCode": 1, "apiName": "ExtendLockTimeApi"}
|
||||||
|
|
||||||
async def handle_get_game_reward_api_request(self, data: Dict) -> Dict:
|
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 = []
|
reward_list = []
|
||||||
for reward in get_game_rewards:
|
for reward in get_game_rewards:
|
||||||
@@ -222,7 +222,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_game_present_api_request(self, data: Dict) -> Dict:
|
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 = []
|
present_list = []
|
||||||
for present in get_present:
|
for present in get_present:
|
||||||
@@ -245,7 +245,7 @@ class OngekiBase:
|
|||||||
return {"length": 0, "gameSaleList": []}
|
return {"length": 0, "gameSaleList": []}
|
||||||
|
|
||||||
async def handle_get_game_tech_music_api_request(self, data: Dict) -> Dict:
|
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 = []
|
prep_music_list = []
|
||||||
for music in music_list:
|
for music in music_list:
|
||||||
@@ -268,9 +268,9 @@ class OngekiBase:
|
|||||||
|
|
||||||
client_id = data["clientId"]
|
client_id = data["clientId"]
|
||||||
client_setting_data = data["clientSetting"]
|
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:
|
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"}
|
return {"returnCode": 1, "apiName": "UpsertClientSettingApi"}
|
||||||
|
|
||||||
async def handle_upsert_client_testmode_api_request(self, data: Dict) -> Dict:
|
async def handle_upsert_client_testmode_api_request(self, data: Dict) -> Dict:
|
||||||
@@ -279,7 +279,7 @@ class OngekiBase:
|
|||||||
|
|
||||||
region_id = data["regionId"]
|
region_id = data["regionId"]
|
||||||
client_testmode_data = data["clientTestmode"]
|
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"}
|
return {"returnCode": 1, "apiName": "UpsertClientTestmodeApi"}
|
||||||
|
|
||||||
async def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict:
|
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
|
if user >= 200000000000000: # Account for guest play
|
||||||
user = None
|
user = None
|
||||||
|
|
||||||
self.data.log.put_gp_log(
|
await self.data.log.put_gp_log(
|
||||||
user,
|
user,
|
||||||
data["usedCredit"],
|
data["usedCredit"],
|
||||||
data["placeName"],
|
data["placeName"],
|
||||||
@@ -313,7 +313,7 @@ class OngekiBase:
|
|||||||
return {"returnCode": 1, "apiName": "ExtendLockTimeApi"}
|
return {"returnCode": 1, "apiName": "ExtendLockTimeApi"}
|
||||||
|
|
||||||
async def handle_get_game_event_api_request(self, data: Dict) -> Dict:
|
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:
|
if evts is None:
|
||||||
return {
|
return {
|
||||||
@@ -366,7 +366,7 @@ class OngekiBase:
|
|||||||
return {"userId": data["userId"], "length": 0, "userRegionList": []}
|
return {"userId": data["userId"], "length": 0, "userRegionList": []}
|
||||||
|
|
||||||
async def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
|
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:
|
if profile is None:
|
||||||
return {
|
return {
|
||||||
@@ -422,7 +422,7 @@ class OngekiBase:
|
|||||||
Gets the number of AB and ABPs a player has per-difficulty (7, 7+, 8, etc)
|
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
|
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 = []
|
userTechCountList = []
|
||||||
|
|
||||||
for tc in utcl:
|
for tc in utcl:
|
||||||
@@ -437,7 +437,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_tech_event_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_tech_event_list is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -456,7 +456,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_tech_event_ranking_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_tech_event_ranks is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -482,7 +482,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_kop_api_request(self, data: Dict) -> Dict:
|
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:
|
if kop_list is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -518,7 +518,7 @@ class OngekiBase:
|
|||||||
|
|
||||||
async def handle_get_user_item_api_request(self, data: Dict) -> Dict:
|
async def handle_get_user_item_api_request(self, data: Dict) -> Dict:
|
||||||
kind = data["nextIndex"] / 10000000000
|
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:
|
if p is None:
|
||||||
return {
|
return {
|
||||||
@@ -553,7 +553,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_option_api_request(self, data: Dict) -> Dict:
|
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:
|
if o is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -567,11 +567,11 @@ class OngekiBase:
|
|||||||
return {"userId": data["userId"], "userOption": user_opts}
|
return {"userId": data["userId"], "userOption": user_opts}
|
||||||
|
|
||||||
async def handle_get_user_data_api_request(self, data: Dict) -> Dict:
|
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:
|
if p is None:
|
||||||
return {}
|
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:
|
if cards is None or len(cards) == 0:
|
||||||
# This should never happen
|
# This should never happen
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
@@ -595,7 +595,7 @@ class OngekiBase:
|
|||||||
return {"userId": data["userId"], "userData": user_data}
|
return {"userId": data["userId"], "userData": user_data}
|
||||||
|
|
||||||
async def handle_get_user_event_ranking_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_event_ranking_list is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -618,7 +618,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_login_bonus_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_login_bonus_list is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -636,7 +636,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_bp_base_request(self, data: Dict) -> Dict:
|
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"]
|
self.game, self.version, user_id=data["userId"]
|
||||||
)
|
)
|
||||||
if p is None:
|
if p is None:
|
||||||
@@ -649,7 +649,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_recent_rating_api_request(self, data: Dict) -> Dict:
|
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:
|
if recent_rating is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -666,7 +666,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_activity_api_request(self, data: Dict) -> Dict:
|
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:
|
if activity is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -693,7 +693,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_story_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_stories is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -711,7 +711,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_chapter_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_chapters is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -736,7 +736,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_character_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_characters is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -754,7 +754,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_card_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_cards is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -773,7 +773,7 @@ class OngekiBase:
|
|||||||
|
|
||||||
async def handle_get_user_deck_by_key_api_request(self, data: Dict) -> Dict:
|
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
|
# 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:
|
if decks is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -791,7 +791,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_trade_item_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_trade_items is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -809,7 +809,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_scenario_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_scenerio is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -827,7 +827,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_ratinglog_api_request(self, data: Dict) -> Dict:
|
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:
|
if rating_log is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -845,7 +845,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_mission_point_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_mission_point_list is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -865,7 +865,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_event_point_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_event_point_list is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -887,7 +887,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_music_item_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_music_item_list is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -905,7 +905,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_event_music_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_evt_music_list is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -923,7 +923,7 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_boss_api_request(self, data: Dict) -> Dict:
|
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:
|
if p is None:
|
||||||
return {}
|
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.
|
# 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:
|
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]
|
user_id, self.version, upsert["userData"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userOption" in upsert and len(upsert["userOption"]) > 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:
|
if "userPlaylogList" in upsert:
|
||||||
for playlog in upsert["userPlaylogList"]:
|
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:
|
if "userActivityList" in upsert:
|
||||||
for act in upsert["userActivityList"]:
|
for act in upsert["userActivityList"]:
|
||||||
self.data.profile.put_profile_activity(
|
await self.data.profile.put_profile_activity(
|
||||||
user_id,
|
user_id,
|
||||||
act["kind"],
|
act["kind"],
|
||||||
act["id"],
|
act["id"],
|
||||||
@@ -972,101 +972,101 @@ class OngekiBase:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if "userRecentRatingList" in upsert:
|
if "userRecentRatingList" in upsert:
|
||||||
self.data.profile.put_profile_recent_rating(
|
await self.data.profile.put_profile_recent_rating(
|
||||||
user_id, upsert["userRecentRatingList"]
|
user_id, upsert["userRecentRatingList"]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userBpBaseList" in upsert:
|
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:
|
if "userMusicDetailList" in upsert:
|
||||||
for x in upsert["userMusicDetailList"]:
|
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:
|
if "userCharacterList" in upsert:
|
||||||
for x in upsert["userCharacterList"]:
|
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:
|
if "userCardList" in upsert:
|
||||||
for x in upsert["userCardList"]:
|
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:
|
if "userDeckList" in upsert:
|
||||||
for x in upsert["userDeckList"]:
|
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:
|
if "userTrainingRoomList" in upsert:
|
||||||
for x in upsert["userTrainingRoomList"]:
|
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:
|
if "userStoryList" in upsert:
|
||||||
for x in upsert["userStoryList"]:
|
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:
|
if "userChapterList" in upsert:
|
||||||
for x in upsert["userChapterList"]:
|
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:
|
if "userMemoryChapterList" in upsert:
|
||||||
for x in upsert["userMemoryChapterList"]:
|
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:
|
if "userItemList" in upsert:
|
||||||
for x in upsert["userItemList"]:
|
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:
|
if "userMusicItemList" in upsert:
|
||||||
for x in upsert["userMusicItemList"]:
|
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:
|
if "userLoginBonusList" in upsert:
|
||||||
for x in upsert["userLoginBonusList"]:
|
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:
|
if "userEventPointList" in upsert:
|
||||||
for x in upsert["userEventPointList"]:
|
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:
|
if "userMissionPointList" in upsert:
|
||||||
for x in upsert["userMissionPointList"]:
|
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:
|
if "userRatinglogList" in upsert:
|
||||||
for x in upsert["userRatinglogList"]:
|
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"]
|
user_id, x["dataVersion"], x["highestRating"]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userBossList" in upsert:
|
if "userBossList" in upsert:
|
||||||
for x in upsert["userBossList"]:
|
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:
|
if "userTechCountList" in upsert:
|
||||||
for x in upsert["userTechCountList"]:
|
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:
|
if "userScenerioList" in upsert:
|
||||||
for x in upsert["userScenerioList"]:
|
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:
|
if "userTradeItemList" in upsert:
|
||||||
for x in upsert["userTradeItemList"]:
|
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:
|
if "userEventMusicList" in upsert:
|
||||||
for x in upsert["userEventMusicList"]:
|
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:
|
if "userTechEventList" in upsert:
|
||||||
for x in upsert["userTechEventList"]:
|
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
|
# 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:
|
if "userKopList" in upsert:
|
||||||
for x in upsert["userKopList"]:
|
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"}
|
return {"returnCode": 1, "apiName": "upsertUserAll"}
|
||||||
|
|
||||||
@@ -1076,7 +1076,7 @@ class OngekiBase:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
rival_list = []
|
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:
|
for rival in user_rivals:
|
||||||
tmp = {}
|
tmp = {}
|
||||||
tmp["rivalUserId"] = rival[0]
|
tmp["rivalUserId"] = rival[0]
|
||||||
@@ -1100,7 +1100,7 @@ class OngekiBase:
|
|||||||
"""
|
"""
|
||||||
rivals = []
|
rivals = []
|
||||||
for rival in data["userRivalList"]:
|
for rival in data["userRivalList"]:
|
||||||
name = self.data.profile.get_profile_name(
|
name = await self.data.profile.get_profile_name(
|
||||||
rival["rivalUserId"], self.version
|
rival["rivalUserId"], self.version
|
||||||
)
|
)
|
||||||
if name is None:
|
if name is None:
|
||||||
@@ -1135,8 +1135,8 @@ class OngekiBase:
|
|||||||
}
|
}
|
||||||
|
|
||||||
@cached(2)
|
@cached(2)
|
||||||
def util_generate_music_list(self, user_id: int) -> List:
|
async def util_generate_music_list(self, user_id: int) -> List:
|
||||||
music_detail = self.data.score.get_best_scores(user_id)
|
music_detail = await self.data.score.get_best_scores(user_id)
|
||||||
song_list = []
|
song_list = []
|
||||||
|
|
||||||
for md in music_detail:
|
for md in music_detail:
|
||||||
|
|||||||
+34
-34
@@ -23,11 +23,11 @@ class OngekiBright(OngekiBase):
|
|||||||
|
|
||||||
async def handle_cm_get_user_data_api_request(self, data: Dict) -> Dict:
|
async def handle_cm_get_user_data_api_request(self, data: Dict) -> Dict:
|
||||||
# check for a bright profile
|
# 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:
|
if p is None:
|
||||||
return {}
|
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:
|
if cards is None or len(cards) == 0:
|
||||||
# This should never happen
|
# This should never happen
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
@@ -62,7 +62,7 @@ class OngekiBright(OngekiBase):
|
|||||||
return {"returnCode": 1}
|
return {"returnCode": 1}
|
||||||
|
|
||||||
async def handle_cm_get_user_card_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_cards is None:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ class OngekiBright(OngekiBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_cm_get_user_character_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_characters is None:
|
||||||
return {
|
return {
|
||||||
"userId": data["userId"],
|
"userId": data["userId"],
|
||||||
@@ -125,7 +125,7 @@ class OngekiBright(OngekiBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def handle_get_user_gacha_api_request(self, data: Dict) -> Dict:
|
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:
|
if user_gachas is None:
|
||||||
return {"userId": data["userId"], "length": 0, "userGachaList": []}
|
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:
|
async def handle_cm_get_user_gacha_supply_api_request(self, data: Dict) -> Dict:
|
||||||
# not used for now? not sure what it even does
|
# 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:
|
if user_gacha_supplies is None:
|
||||||
return {"supplyId": 1, "length": 0, "supplyCardList": []}
|
return {"supplyId": 1, "length": 0, "supplyCardList": []}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ class OngekiBright(OngekiBase):
|
|||||||
game_gachas = []
|
game_gachas = []
|
||||||
# for every gacha_id in the OngekiConfig, grab the banner from the db
|
# for every gacha_id in the OngekiConfig, grab the banner from the db
|
||||||
for gacha_id in self.game_cfg.gachas.enabled_gachas:
|
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:
|
if game_gacha:
|
||||||
game_gachas.append(game_gacha)
|
game_gachas.append(game_gacha)
|
||||||
|
|
||||||
@@ -265,26 +265,26 @@ class OngekiBright(OngekiBase):
|
|||||||
return self.handle_roll_gacha_api_request(data)
|
return self.handle_roll_gacha_api_request(data)
|
||||||
|
|
||||||
# get a list of cards for each rarity
|
# 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 = [], []
|
cards_sr, cards_ssr = [], []
|
||||||
|
|
||||||
# free gachas are only allowed to get their specific cards! (R irrelevant)
|
# free gachas are only allowed to get their specific cards! (R irrelevant)
|
||||||
if gacha_id in {1011, 1012}:
|
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:
|
for card in gacha_cards:
|
||||||
if card["rarity"] == 3:
|
if card["rarity"] == 3:
|
||||||
cards_sr.append({"cardId": card["cardId"], "rarity": 2})
|
cards_sr.append({"cardId": card["cardId"], "rarity": 2})
|
||||||
elif card["rarity"] == 4:
|
elif card["rarity"] == 4:
|
||||||
cards_ssr.append({"cardId": card["cardId"], "rarity": 3})
|
cards_ssr.append({"cardId": card["cardId"], "rarity": 3})
|
||||||
else:
|
else:
|
||||||
cards_sr = self.data.static.get_cards_by_rarity(self.version, 2)
|
cards_sr = await self.data.static.get_cards_by_rarity(self.version, 2)
|
||||||
cards_ssr = self.data.static.get_cards_by_rarity(self.version, 3)
|
cards_ssr = await self.data.static.get_cards_by_rarity(self.version, 3)
|
||||||
|
|
||||||
# get the promoted cards for that gacha and add them multiple
|
# get the promoted cards for that gacha and add them multiple
|
||||||
# times to increase chances by factor chances
|
# times to increase chances by factor chances
|
||||||
chances = 10
|
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:
|
for card in gacha_cards:
|
||||||
# make sure to add the cards to the corresponding rarity
|
# make sure to add the cards to the corresponding rarity
|
||||||
if card["rarity"] == 2:
|
if card["rarity"] == 2:
|
||||||
@@ -339,7 +339,7 @@ class OngekiBright(OngekiBase):
|
|||||||
daily_gacha_date = datetime.strptime("2000-01-01", "%Y-%m-%d")
|
daily_gacha_date = datetime.strptime("2000-01-01", "%Y-%m-%d")
|
||||||
|
|
||||||
# check if the user previously rolled the exact same gacha
|
# 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:
|
if user_gacha:
|
||||||
total_gacha_count = user_gacha["totalGachaCnt"]
|
total_gacha_count = user_gacha["totalGachaCnt"]
|
||||||
ceiling_gacha_count = user_gacha["ceilingGachaCnt"]
|
ceiling_gacha_count = user_gacha["ceilingGachaCnt"]
|
||||||
@@ -358,7 +358,7 @@ class OngekiBright(OngekiBase):
|
|||||||
daily_gacha_date = play_date
|
daily_gacha_date = play_date
|
||||||
daily_gacha_cnt = 0
|
daily_gacha_cnt = 0
|
||||||
|
|
||||||
self.data.item.put_user_gacha(
|
await self.data.item.put_user_gacha(
|
||||||
user_id,
|
user_id,
|
||||||
gacha_id,
|
gacha_id,
|
||||||
totalGachaCnt=total_gacha_count + gacha_count,
|
totalGachaCnt=total_gacha_count + gacha_count,
|
||||||
@@ -375,29 +375,29 @@ class OngekiBright(OngekiBase):
|
|||||||
|
|
||||||
if "userData" in upsert and len(upsert["userData"]) > 0:
|
if "userData" in upsert and len(upsert["userData"]) > 0:
|
||||||
# check if the profile is a bright memory profile
|
# 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:
|
if p is not None:
|
||||||
# save the bright memory profile
|
# 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]
|
user_id, self.version, upsert["userData"][0]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# save the bright profile
|
# save the bright profile
|
||||||
self.data.profile.put_profile_data(
|
await self.data.profile.put_profile_data(
|
||||||
user_id, self.version, upsert["userData"][0]
|
user_id, self.version, upsert["userData"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userCharacterList" in upsert:
|
if "userCharacterList" in upsert:
|
||||||
for x in upsert["userCharacterList"]:
|
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:
|
if "userItemList" in upsert:
|
||||||
for x in upsert["userItemList"]:
|
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:
|
if "userCardList" in upsert:
|
||||||
for x in upsert["userCardList"]:
|
for x in upsert["userCardList"]:
|
||||||
self.data.item.put_card(user_id, x)
|
await self.data.item.put_card(user_id, x)
|
||||||
|
|
||||||
# TODO?
|
# TODO?
|
||||||
# if "gameGachaCardList" in upsert:
|
# if "gameGachaCardList" in upsert:
|
||||||
@@ -411,29 +411,29 @@ class OngekiBright(OngekiBase):
|
|||||||
|
|
||||||
if "userData" in upsert and len(upsert["userData"]) > 0:
|
if "userData" in upsert and len(upsert["userData"]) > 0:
|
||||||
# check if the profile is a bright memory profile
|
# 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:
|
if p is not None:
|
||||||
# save the bright memory profile
|
# 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]
|
user_id, self.version, upsert["userData"][0]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# save the bright profile
|
# save the bright profile
|
||||||
self.data.profile.put_profile_data(
|
await self.data.profile.put_profile_data(
|
||||||
user_id, self.version, upsert["userData"][0]
|
user_id, self.version, upsert["userData"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userCharacterList" in upsert:
|
if "userCharacterList" in upsert:
|
||||||
for x in upsert["userCharacterList"]:
|
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:
|
if "userCardList" in upsert:
|
||||||
for x in upsert["userCardList"]:
|
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:
|
if "selectGachaLogList" in data:
|
||||||
for x in data["selectGachaLogList"]:
|
for x in data["selectGachaLogList"]:
|
||||||
self.data.item.put_user_gacha(
|
await self.data.item.put_user_gacha(
|
||||||
user_id,
|
user_id,
|
||||||
x["gachaId"],
|
x["gachaId"],
|
||||||
selectPoint=0,
|
selectPoint=0,
|
||||||
@@ -443,7 +443,7 @@ class OngekiBright(OngekiBase):
|
|||||||
return {"returnCode": 1, "apiName": "cmUpsertUserSelectGacha"}
|
return {"returnCode": 1, "apiName": "cmUpsertUserSelectGacha"}
|
||||||
|
|
||||||
async def handle_get_game_gacha_card_by_id_api_request(self, data: Dict) -> Dict:
|
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 == []:
|
if game_gacha_cards == []:
|
||||||
# fallback to be at least able to select that gacha
|
# fallback to be at least able to select that gacha
|
||||||
return {
|
return {
|
||||||
@@ -579,7 +579,7 @@ class OngekiBright(OngekiBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# add the entry to the user print table with the random serialId
|
# 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
|
data["userId"], serial_id, user_print_detail
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -595,21 +595,21 @@ class OngekiBright(OngekiBase):
|
|||||||
|
|
||||||
if "userData" in upsert and len(upsert["userData"]) > 0:
|
if "userData" in upsert and len(upsert["userData"]) > 0:
|
||||||
# check if the profile is a bright memory profile
|
# 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:
|
if p is not None:
|
||||||
# save the bright memory profile
|
# 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]
|
user_id, self.version, upsert["userData"][0]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# save the bright profile
|
# save the bright profile
|
||||||
self.data.profile.put_profile_data(
|
await self.data.profile.put_profile_data(
|
||||||
user_id, self.version, upsert["userData"][0]
|
user_id, self.version, upsert["userData"][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userActivityList" in upsert:
|
if "userActivityList" in upsert:
|
||||||
for act in upsert["userActivityList"]:
|
for act in upsert["userActivityList"]:
|
||||||
self.data.profile.put_profile_activity(
|
await self.data.profile.put_profile_activity(
|
||||||
user_id,
|
user_id,
|
||||||
act["kind"],
|
act["kind"],
|
||||||
act["id"],
|
act["id"],
|
||||||
@@ -622,10 +622,10 @@ class OngekiBright(OngekiBase):
|
|||||||
|
|
||||||
if "userItemList" in upsert:
|
if "userItemList" in upsert:
|
||||||
for x in upsert["userItemList"]:
|
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:
|
if "userCardList" in upsert:
|
||||||
for x in upsert["userCardList"]:
|
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"}
|
return {"returnCode": 1, "apiName": "cmUpsertUserAll"}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user