mai2: convert selectedCardList to a json fixed

This commit is contained in:
Dniel97 2023-12-07 22:37:34 +01:00
parent 06d33f61e9
commit 9aeb61617b
Signed by: Dniel97
GPG Key ID: 6180B3C768FB2E08

View File

@ -807,8 +807,8 @@ class Importer:
game_cfg = Mai2Config()
game_cfg.update(yaml.safe_load(open(f"{self.config_folder}/mai2.yaml")))
fes = Mai2Festival(self.config, game_cfg)
version_str = Mai2Constants.game_ver_to_string(fes.version)
base = Mai2Festival(self.config, game_cfg)
version_str = Mai2Constants.game_ver_to_string(base.version)
answer = input(
f"Do you really want to import ALL {version_str} data into ARTEMiS? [N/y]: "
@ -826,6 +826,7 @@ class Importer:
unused_columns=["id", "aimeCardId"],
card_id=row._asdict()["aime_card_id"],
)
# useless but required
tmp["accessCode"] = ""
# camel case conversion fix
@ -836,7 +837,7 @@ class Importer:
tmp["charaSlot"] = [int(x) for x in tmp["charaSlot"].split(";")]
tmp["charaLockSlot"] = [int(x) for x in tmp["charaLockSlot"].split(";")]
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{"userId": tmp["user"], "upsertUserAll": {"userData": [tmp]}}
)
@ -853,7 +854,7 @@ class Importer:
udemae,
) = self.get_mai2_rating_lists_by_aqua_row(row)
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{
"userId": tmp["user"],
"upsertUserAll": {
@ -881,7 +882,7 @@ class Importer:
tmp["userId"] = tmp["user"]
id_ = tmp.pop("id")
fes.handle_upload_user_playlog_api_request(
base.handle_upload_user_playlog_api_request(
{"userId": tmp["user"], "userPlaylog": tmp}
)
@ -895,7 +896,10 @@ class Importer:
row, datetime_columns, unused_columns=["id"], card_id=user
)
fes.handle_upsert_user_all_api_request(
# convert the str to a list, so it matches the JSON schema
tmp["selectedCardList"] = []
base.handle_upsert_user_all_api_request(
{"userId": tmp["user"], "upsertUserAll": {"userExtend": [tmp]}}
)
@ -911,7 +915,7 @@ class Importer:
row, datetime_columns, unused_columns=["id"], card_id=user
)
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{"userId": tmp["user"], "upsertUserAll": {"userOption": [tmp]}}
)
@ -931,7 +935,7 @@ class Importer:
)
# using raw operation because wtf
fes.data.profile.put_profile_activity(tmp["user"], tmp)
base.data.profile.put_profile_activity(tmp["user"], tmp)
self.logger.info(
f"Imported {version_str} userActivity: {tmp['user']}, {tmp['activityId']}"
@ -949,7 +953,7 @@ class Importer:
card_id=user,
)
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{"userId": tmp["user"], "upsertUserAll": {"userChargeList": [tmp]}}
)
@ -970,7 +974,7 @@ class Importer:
tmp["point"] = 0
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{"userId": tmp["user"], "upsertUserAll": {"userCharacterList": [tmp]}}
)
@ -989,7 +993,7 @@ class Importer:
card_id=user,
)
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{"userId": tmp["user"], "upsertUserAll": {"userItemList": [tmp]}}
)
@ -1008,7 +1012,7 @@ class Importer:
card_id=user,
)
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{"userId": tmp["user"], "upsertUserAll": {"userLoginBonusList": [tmp]}}
)
@ -1027,7 +1031,7 @@ class Importer:
card_id=user,
)
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{"userId": tmp["user"], "upsertUserAll": {"userMapList": [tmp]}}
)
@ -1046,7 +1050,7 @@ class Importer:
card_id=user,
)
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{"userId": tmp["user"], "upsertUserAll": {"userMusicDetailList": [tmp]}}
)
@ -1065,7 +1069,7 @@ class Importer:
card_id=user,
)
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{"userId": tmp["user"], "upsertUserAll": {"userCourseList": [tmp]}}
)
@ -1091,7 +1095,7 @@ class Importer:
"itemIdList": tmp["itemIdList"],
}
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{"userId": tmp["user"], "upsertUserAll": {"userFavoriteList": [tmp]}}
)
@ -1112,7 +1116,7 @@ class Importer:
# user is redundant
artemis_user = tmp.pop("user")
fes.handle_upsert_user_all_api_request(
base.handle_upsert_user_all_api_request(
{
"userId": artemis_user,
"upsertUserAll": {"userFriendSeasonRankingList": [tmp]},