mai2: fixes round 3
This commit is contained in:
parent
dc8c27046e
commit
d89eb61e62
@ -113,7 +113,7 @@ class Mai2Base:
|
|||||||
|
|
||||||
def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
|
def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
|
||||||
p = self.data.profile.get_profile_detail(data["userId"], self.version, True)
|
p = self.data.profile.get_profile_detail(data["userId"], self.version, True)
|
||||||
w = self.data.profile.get_web_option(data["userId"])
|
w = 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()
|
||||||
@ -229,6 +229,7 @@ class Mai2Base:
|
|||||||
self.data.profile.put_recent_rating(user_id, upsert["userRecentRatingList"])
|
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")
|
||||||
self.data.profile.put_profile_option(
|
self.data.profile.put_profile_option(
|
||||||
user_id, self.version, upsert["userOption"][0], False
|
user_id, self.version, upsert["userOption"][0], False
|
||||||
)
|
)
|
||||||
@ -239,8 +240,7 @@ class Mai2Base:
|
|||||||
)
|
)
|
||||||
|
|
||||||
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 act in upsert["userActivityList"]:
|
||||||
for act in v:
|
|
||||||
self.data.profile.put_profile_activity(user_id, act)
|
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:
|
||||||
@ -265,8 +265,7 @@ class Mai2Base:
|
|||||||
user_id,
|
user_id,
|
||||||
char["characterId"],
|
char["characterId"],
|
||||||
char["level"],
|
char["level"],
|
||||||
char["awakening"],
|
char["point"],
|
||||||
char["useCount"],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userItemList" in upsert and len(upsert["userItemList"]) > 0:
|
if "userItemList" in upsert and len(upsert["userItemList"]) > 0:
|
||||||
@ -276,7 +275,6 @@ class Mai2Base:
|
|||||||
int(item["itemKind"]),
|
int(item["itemKind"]),
|
||||||
item["itemId"],
|
item["itemId"],
|
||||||
item["stock"],
|
item["stock"],
|
||||||
item["isValid"],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userLoginBonusList" in upsert and len(upsert["userLoginBonusList"]) > 0:
|
if "userLoginBonusList" in upsert and len(upsert["userLoginBonusList"]) > 0:
|
||||||
@ -302,7 +300,7 @@ 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)
|
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"]:
|
||||||
|
@ -678,7 +678,9 @@ class Mai2ProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.fetchall()
|
return result.fetchall()
|
||||||
|
|
||||||
def put_web_option(self, user_id: int, web_opts: Dict) -> Optional[int]:
|
def put_web_option(self, user_id: int, version: int, web_opts: Dict) -> Optional[int]:
|
||||||
|
web_opts["user"] = user_id
|
||||||
|
web_opts["version"] = version
|
||||||
sql = insert(web_opt).values(**web_opts)
|
sql = insert(web_opt).values(**web_opts)
|
||||||
|
|
||||||
conflict = sql.on_duplicate_key_update(**web_opts)
|
conflict = sql.on_duplicate_key_update(**web_opts)
|
||||||
@ -691,8 +693,8 @@ class Mai2ProfileData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
def get_web_option(self, user_id: int) -> Optional[Row]:
|
def get_web_option(self, user_id: int, version: int) -> Optional[Row]:
|
||||||
sql = web_opt.select(web_opt.c.user == user_id)
|
sql = web_opt.select(and_(web_opt.c.user == user_id, web_opt.c.version == version))
|
||||||
|
|
||||||
result = self.execute(sql)
|
result = self.execute(sql)
|
||||||
if result is None:
|
if result is None:
|
||||||
@ -700,6 +702,7 @@ class Mai2ProfileData(BaseData):
|
|||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_grade_status(self, user_id: int, grade_stat: Dict) -> Optional[int]:
|
def put_grade_status(self, user_id: int, grade_stat: Dict) -> Optional[int]:
|
||||||
|
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)
|
||||||
@ -721,6 +724,7 @@ class Mai2ProfileData(BaseData):
|
|||||||
return result.fetchone()
|
return result.fetchone()
|
||||||
|
|
||||||
def put_boss_list(self, user_id: int, boss_stat: Dict) -> Optional[int]:
|
def put_boss_list(self, user_id: int, boss_stat: Dict) -> Optional[int]:
|
||||||
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user