idac: battle gift event, tips, QoL improvements added
This commit is contained in:
@@ -321,6 +321,23 @@ timetrial_event = Table(
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
battle_gift = Table(
|
||||
"idac_user_battle_gift",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column(
|
||||
"user",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
nullable=False,
|
||||
),
|
||||
Column("battle_gift_event_id", Integer),
|
||||
Column("gift_id", Integer),
|
||||
Column("gift_status", Integer),
|
||||
Column("received_date", TIMESTAMP, server_default=func.now()),
|
||||
UniqueConstraint("user", "battle_gift_event_id", "gift_id", name="idac_user_battle_gift_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
class IDACItemData(BaseData):
|
||||
async def get_random_user_car(self, aime_id: int, version: int) -> Optional[List[Row]]:
|
||||
@@ -843,6 +860,19 @@ class IDACItemData(BaseData):
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
async def get_battle_gifts(self, aime_id: int, battle_gift_event_id: int) -> Optional[Row]:
|
||||
sql = select(battle_gift).where(
|
||||
and_(
|
||||
battle_gift.c.user == aime_id,
|
||||
battle_gift.c.battle_gift_event_id == battle_gift_event_id,
|
||||
)
|
||||
)
|
||||
|
||||
result = await self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
async def put_car(self, aime_id: int, version: int, car_data: Dict) -> Optional[int]:
|
||||
car_data["user"] = aime_id
|
||||
@@ -1074,3 +1104,19 @@ class IDACItemData(BaseData):
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
async def put_battle_gift(
|
||||
self, aime_id: int, battle_gift_data: Dict
|
||||
) -> Optional[int]:
|
||||
battle_gift_data["user"] = aime_id
|
||||
|
||||
sql = insert(battle_gift).values(**battle_gift_data)
|
||||
conflict = sql.on_duplicate_key_update(**battle_gift_data)
|
||||
result = await self.execute(conflict)
|
||||
|
||||
if result is None:
|
||||
self.logger.warn(
|
||||
f"put_battle_gift: Failed to update! aime_id: {aime_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
Reference in New Issue
Block a user