forked from Dniel97/artemis
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:
|
||||
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:
|
||||
return {} # Register
|
||||
profile = p._asdict()
|
||||
@ -229,6 +229,7 @@ class Mai2Base:
|
||||
self.data.profile.put_recent_rating(user_id, upsert["userRecentRatingList"])
|
||||
|
||||
if "userOption" in upsert and len(upsert["userOption"]) > 0:
|
||||
upsert["userOption"][0].pop("userId")
|
||||
self.data.profile.put_profile_option(
|
||||
user_id, self.version, upsert["userOption"][0], False
|
||||
)
|
||||
@ -239,8 +240,7 @@ class Mai2Base:
|
||||
)
|
||||
|
||||
if "userActivityList" in upsert and len(upsert["userActivityList"]) > 0:
|
||||
for k, v in upsert["userActivityList"][0].items():
|
||||
for act in v:
|
||||
for act in upsert["userActivityList"]:
|
||||
self.data.profile.put_profile_activity(user_id, act)
|
||||
|
||||
if "userChargeList" in upsert and len(upsert["userChargeList"]) > 0:
|
||||
@ -265,8 +265,7 @@ class Mai2Base:
|
||||
user_id,
|
||||
char["characterId"],
|
||||
char["level"],
|
||||
char["awakening"],
|
||||
char["useCount"],
|
||||
char["point"],
|
||||
)
|
||||
|
||||
if "userItemList" in upsert and len(upsert["userItemList"]) > 0:
|
||||
@ -276,7 +275,6 @@ class Mai2Base:
|
||||
int(item["itemKind"]),
|
||||
item["itemId"],
|
||||
item["stock"],
|
||||
item["isValid"],
|
||||
)
|
||||
|
||||
if "userLoginBonusList" in upsert and len(upsert["userLoginBonusList"]) > 0:
|
||||
@ -302,7 +300,7 @@ class Mai2Base:
|
||||
|
||||
if "userMusicDetailList" in upsert and len(upsert["userMusicDetailList"]) > 0:
|
||||
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:
|
||||
for course in upsert["userCourseList"]:
|
||||
|
@ -678,7 +678,9 @@ class Mai2ProfileData(BaseData):
|
||||
return None
|
||||
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)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(**web_opts)
|
||||
@ -691,8 +693,8 @@ class Mai2ProfileData(BaseData):
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_web_option(self, user_id: int) -> Optional[Row]:
|
||||
sql = web_opt.select(web_opt.c.user == user_id)
|
||||
def get_web_option(self, user_id: int, version: int) -> Optional[Row]:
|
||||
sql = web_opt.select(and_(web_opt.c.user == user_id, web_opt.c.version == version))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
@ -700,6 +702,7 @@ class Mai2ProfileData(BaseData):
|
||||
return result.fetchone()
|
||||
|
||||
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)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(**grade_stat)
|
||||
@ -721,6 +724,7 @@ class Mai2ProfileData(BaseData):
|
||||
return result.fetchone()
|
||||
|
||||
def put_boss_list(self, user_id: int, boss_stat: Dict) -> Optional[int]:
|
||||
boss_stat["user"] = user_id
|
||||
sql = insert(boss).values(**boss_stat)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(**boss_stat)
|
||||
|
Loading…
Reference in New Issue
Block a user