mirror of
https://gitea.tendokyu.moe/Hay1tsme/artemis.git
synced 2026-02-14 19:57:27 +08:00
- Add ClientTestmode upsert
- Add ClientSetting upsert - Add endDate for Events - Add Upgrade Schema - Small bugfixes for events
This commit is contained in:
@@ -287,9 +287,21 @@ class OngekiBase:
|
||||
}
|
||||
|
||||
def handle_upsert_client_setting_api_request(self, data: Dict) -> Dict:
|
||||
if self.core_cfg.server.is_develop:
|
||||
return {"returnCode": 1, "apiName": "UpsertClientSettingApi"}
|
||||
|
||||
client_id = data["clientId"]
|
||||
client_setting_data = data["clientSetting"]
|
||||
self.data.static.put_client_setting_data(client_id, client_setting_data)
|
||||
return {"returnCode": 1, "apiName": "UpsertClientSettingApi"}
|
||||
|
||||
def handle_upsert_client_testmode_api_request(self, data: Dict) -> Dict:
|
||||
if self.core_cfg.server.is_develop:
|
||||
return {"returnCode": 1, "apiName": "UpsertClientTestmodeApi"}
|
||||
|
||||
region_id = data["regionId"]
|
||||
client_testmode_data = data["clientTestmode"]
|
||||
self.data.static.put_client_testmode_data(region_id, client_testmode_data)
|
||||
return {"returnCode": 1, "apiName": "UpsertClientTestmodeApi"}
|
||||
|
||||
def handle_upsert_client_bookkeeping_api_request(self, data: Dict) -> Dict:
|
||||
@@ -333,10 +345,9 @@ class OngekiBase:
|
||||
"id": event["eventId"],
|
||||
# actually use the startDate from the import so it
|
||||
# properly shows all the events when new ones are imported
|
||||
"startDate": datetime.strftime(
|
||||
event["startDate"], "%Y-%m-%d %H:%M:%S.0"
|
||||
),
|
||||
"endDate": "2099-12-31 00:00:00.0",
|
||||
"startDate": datetime.strftime(event["startDate"], "%Y-%m-%d %H:%M:%S.0"),
|
||||
#"endDate": "2099-12-31 00:00:00.0",
|
||||
"endDate": datetime.strftime(event["endDate"], "%Y-%m-%d %H:%M:%S.0"),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -849,7 +860,7 @@ class OngekiBase:
|
||||
}
|
||||
|
||||
def handle_get_user_mission_point_api_request(self, data: Dict) -> Dict:
|
||||
user_mission_point_list = self.data.item.get_mission_points(data["userId"])
|
||||
user_mission_point_list = self.data.item.get_mission_points(self.version, data["userId"])
|
||||
if user_mission_point_list is None:
|
||||
return {}
|
||||
|
||||
@@ -858,6 +869,7 @@ class OngekiBase:
|
||||
tmp = evt_music._asdict()
|
||||
tmp.pop("id")
|
||||
tmp.pop("user")
|
||||
tmp.pop("version")
|
||||
mission_point_list.append(tmp)
|
||||
|
||||
|
||||
@@ -1032,7 +1044,7 @@ class OngekiBase:
|
||||
|
||||
if "userMissionPointList" in upsert:
|
||||
for x in upsert["userMissionPointList"]:
|
||||
self.data.item.put_mission_point(user_id, x)
|
||||
self.data.item.put_mission_point(user_id, self.version, x)
|
||||
|
||||
if "userRatinglogList" in upsert:
|
||||
for x in upsert["userRatinglogList"]:
|
||||
|
||||
@@ -187,6 +187,7 @@ mission_point = Table(
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("version", Integer),
|
||||
Column("eventId", Integer),
|
||||
Column("point", Integer),
|
||||
UniqueConstraint("user", "eventId", name="ongeki_user_mission_point_uk"),
|
||||
@@ -337,7 +338,6 @@ print_detail = Table(
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
class OngekiItemData(BaseData):
|
||||
def put_card(self, aime_id: int, card_data: Dict) -> Optional[int]:
|
||||
card_data["user"] = aime_id
|
||||
@@ -532,10 +532,9 @@ class OngekiItemData(BaseData):
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_mission_point(
|
||||
self, aime_id: int, mission_point_data: Dict
|
||||
) -> Optional[int]:
|
||||
def put_mission_point(self, version: int, aime_id: int, mission_point_data: Dict) -> Optional[int]:
|
||||
mission_point_data["user"] = aime_id
|
||||
mission_point_data["version"] = version
|
||||
|
||||
sql = insert(mission_point).values(**mission_point_data)
|
||||
conflict = sql.on_duplicate_key_update(**mission_point_data)
|
||||
@@ -546,8 +545,8 @@ class OngekiItemData(BaseData):
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def get_mission_points(self, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(mission_point).where(mission_point.c.user == aime_id)
|
||||
def get_mission_points(self, version: int, aime_id: int) -> Optional[List[Dict]]:
|
||||
sql = select(mission_point).where(and_(mission_point.c.user == aime_id, mission_point.c.version == version))
|
||||
result = self.execute(sql)
|
||||
|
||||
if result is None:
|
||||
|
||||
@@ -17,6 +17,7 @@ events = Table(
|
||||
Column("type", Integer),
|
||||
Column("name", String(255)),
|
||||
Column("startDate", TIMESTAMP, server_default=func.now()),
|
||||
Column("endDate", TIMESTAMP, server_default=func.now()),
|
||||
Column("enabled", Boolean, server_default="1"),
|
||||
UniqueConstraint("version", "eventId", "type", name="ongeki_static_events_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
@@ -104,7 +105,7 @@ music_ranking = Table(
|
||||
Column("musicId", Integer, nullable=False),
|
||||
Column("point", Integer, nullable=False),
|
||||
Column("userName", String(255)),
|
||||
UniqueConstraint("musicId", name="ongeki_static_music_ranking_uk"),
|
||||
UniqueConstraint("version", "musicId", name="ongeki_static_music_ranking_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
@@ -117,7 +118,7 @@ rewards = Table(
|
||||
Column("rewardname", String(255), nullable=False),
|
||||
Column("itemKind", Integer, nullable=False),
|
||||
Column("itemId", Integer, nullable=False),
|
||||
UniqueConstraint("version","itemKind","rewardId", name="ongeki_static_rewards_uk"),
|
||||
UniqueConstraint("version", "rewardId", name="ongeki_static_rewards_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
@@ -133,7 +134,7 @@ present = Table(
|
||||
Column("message", String(255)),
|
||||
Column("startDate", String(25), nullable=False),
|
||||
Column("endDate", String(25), nullable=False),
|
||||
UniqueConstraint("version","presentId", name="ongeki_static_present_list_uk"),
|
||||
UniqueConstraint("version", "presentId", "rewardId", name="ongeki_static_present_list_uk",
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
@@ -149,6 +150,30 @@ tech_music = Table(
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
client_testmode = Table(
|
||||
"ongeki_static_client_testmode",
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("regionId", Integer, nullable=False),
|
||||
Column("placeId", Integer, nullable=False),
|
||||
Column("clientId", String(11), nullable=False),
|
||||
Column("updateDate", TIMESTAMP, nullable=False),
|
||||
Column("isDelivery", Boolean, nullable=False),
|
||||
Column("groupId", Integer, nullable=False),
|
||||
Column("groupRole", Integer, nullable=False),
|
||||
Column("continueMode", Integer, nullable=False),
|
||||
Column("selectMusicTime", Integer, nullable=False),
|
||||
Column("advertiseVolume", Integer, nullable=False),
|
||||
Column("eventMode", Integer, nullable=False),
|
||||
Column("eventMusicNum", Integer, nullable=False),
|
||||
Column("patternGp", Integer, nullable=False),
|
||||
Column("limitGp", Integer, nullable=False),
|
||||
Column("maxLeverMovable", Integer, nullable=False),
|
||||
Column("minLeverMovable", Integer, nullable=False),
|
||||
UniqueConstraint("clientId", name="ongeki_static_client_testmode_uk"),
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
class OngekiStaticData(BaseData):
|
||||
def put_card(self, version: int, card_id: int, **card_data) -> Optional[int]:
|
||||
sql = insert(cards).values(version=version, cardId=card_id, **card_data)
|
||||
@@ -287,6 +312,7 @@ class OngekiStaticData(BaseData):
|
||||
eventId=event_id,
|
||||
type=event_type,
|
||||
name=event_name,
|
||||
endDate=f"2038-01-01 00:00:00",
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
@@ -436,3 +462,23 @@ class OngekiStaticData(BaseData):
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def put_client_testmode_data(self, region_id: int, client_testmode_data: Dict) -> Optional[List[Dict]]:
|
||||
sql = insert(client_testmode).values(regionId=region_id, **client_testmode_data)
|
||||
conflict = sql.on_duplicate_key_update(regionId=region_id, **client_testmode_data)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warning(f"clientId: {clientId} Failed to update ClientTestMode data"),
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_client_setting_data(self, client_id: str, client_setting_data: Dict) -> Optional[List[Dict]]:
|
||||
sql = insert(machine).values(data=client_setting_data)
|
||||
conflict = sql.on_duplicate_key_update(serial=client_id)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warning(f"clientId: {clientId} Failed to update ClientSetting data"),
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
Reference in New Issue
Block a user