forked from Hay1tsme/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:
|
if "userCharacterList" in upsert and len(upsert["userCharacterList"]) > 0:
|
||||||
for char in upsert["userCharacterList"]:
|
for char in upsert["userCharacterList"]:
|
||||||
self.data.item.put_character(
|
self.data.item.put_character_(
|
||||||
user_id,
|
user_id,
|
||||||
char["characterId"],
|
char
|
||||||
char["level"],
|
|
||||||
char["point"],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userItemList" in upsert and len(upsert["userItemList"]) > 0:
|
if "userItemList" in upsert and len(upsert["userItemList"]) > 0:
|
||||||
@ -275,6 +273,7 @@ class Mai2Base:
|
|||||||
int(item["itemKind"]),
|
int(item["itemKind"]),
|
||||||
item["itemId"],
|
item["itemId"],
|
||||||
item["stock"],
|
item["stock"],
|
||||||
|
True
|
||||||
)
|
)
|
||||||
|
|
||||||
if "userLoginBonusList" in upsert and len(upsert["userLoginBonusList"]) > 0:
|
if "userLoginBonusList" in upsert and len(upsert["userLoginBonusList"]) > 0:
|
||||||
|
@ -334,6 +334,19 @@ class Mai2ItemData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.fetchone()
|
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(
|
def put_character(
|
||||||
self,
|
self,
|
||||||
user_id: int,
|
user_id: int,
|
||||||
|
@ -456,7 +456,7 @@ recent_rating = Table(
|
|||||||
metadata,
|
metadata,
|
||||||
Column("id", Integer, primary_key=True, nullable=False),
|
Column("id", Integer, primary_key=True, nullable=False),
|
||||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"), 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"),
|
UniqueConstraint("user", name="mai2_profile_recent_rating_uk"),
|
||||||
mysql_charset="utf8mb4",
|
mysql_charset="utf8mb4",
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user