add rollback sql

move GP support to table in DB
small fixes
This commit is contained in:
phantomlan 2023-11-13 03:26:09 +01:00
parent d663b1ef7c
commit b56a5f020b
4 changed files with 82 additions and 45 deletions

View File

@ -0,0 +1,22 @@
SET FOREIGN_KEY_CHECKS=0;
ALTER TABLE ongeki_user_event_point DROP COLUMN version;
ALTER TABLE ongeki_user_event_point DROP COLUMN rank;
ALTER TABLE ongeki_user_event_point DROP COLUMN type;
ALTER TABLE ongeki_user_event_point DROP COLUMN date;
ALTER TABLE ongeki_user_tech_event DROP COLUMN version;
ALTER TABLE ongeki_user_mission_point DROP COLUMN version;
ALTER TABLE ongeki_static_event DROP COLUMN endDate;
DROP TABLE ongeki_tech_event_ranking;
DROP TABLE ongeki_static_music_ranking_list;
DROP TABLE ongeki_static_rewards;
DROP TABLE ongeki_static_present_list;
DROP TABLE ongeki_static_tech_music;
DROP TABLE ongeki_static_client_testmode;
DROP TABLE ongeki_static_game_point;
SET FOREIGN_KEY_CHECKS=1;

View File

@ -85,4 +85,14 @@ CREATE TABLE ongeki_static_client_testmode (
minLeverMovable INT NOT NULL,
UNIQUE KEY ongeki_static_client_testmode_uk (clientId)
);
CREATE TABLE ongeki_static_game_point (
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
type INT NOT NULL,
cost INT NOT NULL,
startDate VARCHAR(25) NOT NULL DEFAULT "2000-01-01 05:00:00.0",
endDate VARCHAR(25) NOT NULL DEFAULT "2099-01-01 05:00:00.0",
UNIQUE KEY ongeki_static_game_point_uk (type)
);
SET FOREIGN_KEY_CHECKS=1;

View File

@ -173,49 +173,26 @@ class OngekiBase:
def handle_get_game_point_api_request(self, data: Dict) -> Dict:
"""
Sets the GP amount for A and B sets for 1 - 3 credits
"""
get_game_point = self.data.static.get_static_game_point()
game_point = []
if not get_game_point:
self.logger.info(f"GP table is empty, inserting defaults")
self.data.static.put_static_game_point_defaults()
get_game_point = self.data.static.get_static_game_point()
for gp in get_game_point:
tmp = gp._asdict()
game_point.append(tmp)
return {
"length": 6,
"gamePointList": [
{
"type": 0,
"cost": 100,
"startDate": "2000-01-01 05:00:00.0",
"endDate": "2099-01-01 05:00:00.0",
},
{
"type": 1,
"cost": 230,
"startDate": "2000-01-01 05:00:00.0",
"endDate": "2099-01-01 05:00:00.0",
},
{
"type": 2,
"cost": 370,
"startDate": "2000-01-01 05:00:00.0",
"endDate": "2099-01-01 05:00:00.0",
},
{
"type": 3,
"cost": 120,
"startDate": "2000-01-01 05:00:00.0",
"endDate": "2099-01-01 05:00:00.0",
},
{
"type": 4,
"cost": 240,
"startDate": "2000-01-01 05:00:00.0",
"endDate": "2099-01-01 05:00:00.0",
},
{
"type": 5,
"cost": 360,
"startDate": "2000-01-01 05:00:00.0",
"endDate": "2099-01-01 05:00:00.0",
},
],
"length": len(game_point),
"gamePointList": game_point,
}
for gp in get_game_point:
tmp = gp._asdict()
game_point.append(tmp)
return {
"length": len(game_point),
"gamePointList": game_point,
}
def handle_game_login_api_request(self, data: Dict) -> Dict:

View File

@ -134,7 +134,7 @@ present = Table(
Column("message", String(255)),
Column("startDate", String(25), nullable=False),
Column("endDate", String(25), nullable=False),
UniqueConstraint("version", "presentId", "rewardId", name="ongeki_static_present_list_uk"),
UniqueConstraint("version", "presentId", name="ongeki_static_present_list_uk"),
mysql_charset="utf8mb4",
)
@ -174,6 +174,18 @@ client_testmode = Table(
mysql_charset="utf8mb4",
)
game_point = Table(
"ongeki_static_game_point",
metadata,
Column("id", Integer, primary_key=True, nullable=False),
Column("type", Integer, nullable=False),
Column("cost", Integer, nullable=False),
Column("startDate", String(25), nullable=False, server_default="2000-01-01 05:00:00.0"),
Column("endDate", String(25), nullable=False, server_default="2099-01-01 05:00:00.0"),
UniqueConstraint("type", name="ongeki_static_game_point_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)
@ -482,3 +494,19 @@ class OngekiStaticData(BaseData):
self.logger.warning(f"clientId: {clientId} Failed to update ClientSetting data"),
return None
return result.lastrowid
def put_static_game_point_defaults(self) -> Optional[List[Dict]]:
game_point_defaults = [{"type": 0, "cost": 100},{"type": 1, "cost": 230},{"type": 2, "cost": 370},{"type": 3, "cost": 120},{"type": 4, "cost": 240},{"type": 5, "cost": 360}]
sql = insert(game_point).values(game_point_defaults)
result = self.execute(sql)
if result is None:
self.logger.warning(f"Failed to insert default GP table!")
return None
return result.lastrowid
def get_static_game_point(self) -> Optional[List[Dict]]:
sql = select(game_point.c.type, game_point.c.cost, game_point.c.startDate, game_point.c.endDate)
result = self.execute(sql)
if result is None:
return None
return result.fetchall()