forked from Dniel97/artemis
mai2: 4th round of fixes
This commit is contained in:
parent
9859ab4fdb
commit
d9a92f5865
@ -261,11 +261,9 @@ class Mai2Base:
|
||||
|
||||
if "userCharacterList" in upsert and len(upsert["userCharacterList"]) > 0:
|
||||
for char in upsert["userCharacterList"]:
|
||||
self.data.item.put_character(
|
||||
self.data.item.put_character_(
|
||||
user_id,
|
||||
char["characterId"],
|
||||
char["level"],
|
||||
char["point"],
|
||||
char
|
||||
)
|
||||
|
||||
if "userItemList" in upsert and len(upsert["userItemList"]) > 0:
|
||||
@ -275,6 +273,7 @@ class Mai2Base:
|
||||
int(item["itemKind"]),
|
||||
item["itemId"],
|
||||
item["stock"],
|
||||
True
|
||||
)
|
||||
|
||||
if "userLoginBonusList" in upsert and len(upsert["userLoginBonusList"]) > 0:
|
||||
|
@ -333,6 +333,19 @@ class Mai2ItemData(BaseData):
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def put_character_(self, user_id: int, char_data: Dict) -> Optional[int]:
|
||||
char_data["user"] = user_id
|
||||
sql = insert(character).values(**char_data)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(**char_data)
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(
|
||||
f"put_character_: failed to insert item! user_id: {user_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_character(
|
||||
self,
|
||||
|
@ -456,7 +456,7 @@ recent_rating = Table(
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), nullable=False),
|
||||
Column("userRecentRatingList", Integer),
|
||||
Column("userRecentRatingList", JSON),
|
||||
UniqueConstraint("user", name="mai2_profile_recent_rating_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user