forked from Hay1tsme/artemis
let black do it's magic
This commit is contained in:
@ -16,7 +16,11 @@ profile = Table(
|
||||
"ongeki_profile_data",
|
||||
metadata,
|
||||
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("version", Integer, nullable=False),
|
||||
Column("userName", String(8)),
|
||||
Column("level", Integer),
|
||||
@ -81,7 +85,7 @@ profile = Table(
|
||||
Column("lastEmoneyCredit", Integer, server_default="0"),
|
||||
Column("isDialogWatchedSuggestMemory", Boolean, server_default="0"),
|
||||
UniqueConstraint("user", "version", name="ongeki_profile_profile_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
# No point setting defaults since the game sends everything on profile creation anyway
|
||||
@ -89,7 +93,11 @@ option = Table(
|
||||
"ongeki_profile_option",
|
||||
metadata,
|
||||
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("optionSet", Integer),
|
||||
Column("speed", Integer),
|
||||
Column("mirror", Integer),
|
||||
@ -128,14 +136,18 @@ option = Table(
|
||||
Column("stealthField", Integer),
|
||||
Column("colorWallBright", Integer),
|
||||
UniqueConstraint("user", name="ongeki_profile_option_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
activity = Table(
|
||||
"ongeki_profile_activity",
|
||||
metadata,
|
||||
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("kind", Integer),
|
||||
Column("activityId", Integer),
|
||||
Column("sortNumber", Integer),
|
||||
@ -144,40 +156,52 @@ activity = Table(
|
||||
Column("param3", Integer),
|
||||
Column("param4", Integer),
|
||||
UniqueConstraint("user", "kind", "activityId", name="ongeki_profile_activity_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
recent_rating = Table(
|
||||
"ongeki_profile_recent_rating",
|
||||
metadata,
|
||||
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("recentRating", JSON),
|
||||
UniqueConstraint("user", name="ongeki_profile_recent_rating_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
rating_log = Table(
|
||||
"ongeki_profile_rating_log",
|
||||
metadata,
|
||||
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("highestRating", Integer),
|
||||
Column("dataVersion", String(10)),
|
||||
UniqueConstraint("user", "dataVersion", name="ongeki_profile_rating_log_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
region = Table(
|
||||
"ongeki_profile_region",
|
||||
metadata,
|
||||
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("regionId", Integer),
|
||||
Column("playCount", Integer),
|
||||
Column("created", String(25)),
|
||||
UniqueConstraint("user", "regionId", name="ongeki_profile_region_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
training_room = Table(
|
||||
@ -185,12 +209,12 @@ training_room = Table(
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("roomId", Integer),
|
||||
Column("roomId", Integer),
|
||||
Column("authKey", Integer),
|
||||
Column("cardId", Integer),
|
||||
Column("valueDate", String(25)),
|
||||
UniqueConstraint("user", "roomId", name="ongeki_profile_training_room_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
kop = Table(
|
||||
@ -199,14 +223,14 @@ kop = Table(
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("authKey", Integer),
|
||||
Column("kopId", Integer),
|
||||
Column("kopId", Integer),
|
||||
Column("areaId", Integer),
|
||||
Column("totalTechScore", Integer),
|
||||
Column("totalPlatinumScore", Integer),
|
||||
Column("techRecordDate", String(25)),
|
||||
Column("isTotalTechNewRecord", Boolean),
|
||||
UniqueConstraint("user", "kopId", name="ongeki_profile_kop_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
rival = Table(
|
||||
@ -214,86 +238,112 @@ rival = Table(
|
||||
metadata,
|
||||
Column("id", Integer, primary_key=True, nullable=False),
|
||||
Column("user", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column("rivalUserId", ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade")),
|
||||
Column(
|
||||
"rivalUserId",
|
||||
ForeignKey("aime_user.id", ondelete="cascade", onupdate="cascade"),
|
||||
),
|
||||
UniqueConstraint("user", "rivalUserId", name="ongeki_profile_rival_uk"),
|
||||
mysql_charset='utf8mb4'
|
||||
mysql_charset="utf8mb4",
|
||||
)
|
||||
|
||||
|
||||
class OngekiProfileData(BaseData):
|
||||
def __init__(self, cfg: CoreConfig, conn: Connection) -> None:
|
||||
super().__init__(cfg, conn)
|
||||
self.date_time_format_ext = "%Y-%m-%d %H:%M:%S.%f" # needs to be lopped off at [:-5]
|
||||
self.date_time_format_ext = (
|
||||
"%Y-%m-%d %H:%M:%S.%f" # needs to be lopped off at [:-5]
|
||||
)
|
||||
self.date_time_format_short = "%Y-%m-%d"
|
||||
|
||||
def get_profile_name(self, aime_id: int, version: int) -> Optional[str]:
|
||||
sql = select(profile.c.userName).where(and_(profile.c.user == aime_id, profile.c.version == version))
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
|
||||
row = result.fetchone()
|
||||
if row is None: return None
|
||||
|
||||
return row["userName"]
|
||||
|
||||
def get_profile_preview(self, aime_id: int, version: int) -> Optional[Row]:
|
||||
sql = select([profile, option]).join(option, profile.c.user == option.c.user).filter(
|
||||
sql = select(profile.c.userName).where(
|
||||
and_(profile.c.user == aime_id, profile.c.version == version)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
|
||||
row = result.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
|
||||
return row["userName"]
|
||||
|
||||
def get_profile_preview(self, aime_id: int, version: int) -> Optional[Row]:
|
||||
sql = (
|
||||
select([profile, option])
|
||||
.join(option, profile.c.user == option.c.user)
|
||||
.filter(and_(profile.c.user == aime_id, profile.c.version == version))
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_profile_data(self, aime_id: int, version: int) -> Optional[Row]:
|
||||
sql = select(profile).where(and_(
|
||||
profile.c.user == aime_id,
|
||||
profile.c.version == version,
|
||||
))
|
||||
sql = select(profile).where(
|
||||
and_(
|
||||
profile.c.user == aime_id,
|
||||
profile.c.version == version,
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_profile_options(self, aime_id: int) -> Optional[Row]:
|
||||
sql = select(option).where(and_(
|
||||
option.c.user == aime_id,
|
||||
))
|
||||
sql = select(option).where(
|
||||
and_(
|
||||
option.c.user == aime_id,
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_profile_recent_rating(self, aime_id: int) -> Optional[List[Row]]:
|
||||
sql = select(recent_rating).where(recent_rating.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchone()
|
||||
|
||||
def get_profile_rating_log(self, aime_id: int) -> Optional[List[Row]]:
|
||||
sql = select(rating_log).where(recent_rating.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_profile_activity(self, aime_id: int, kind: int = None) -> Optional[List[Row]]:
|
||||
sql = select(activity).where(and_(
|
||||
activity.c.user == aime_id,
|
||||
(activity.c.kind == kind) if kind is not None else True
|
||||
))
|
||||
def get_profile_activity(
|
||||
self, aime_id: int, kind: int = None
|
||||
) -> Optional[List[Row]]:
|
||||
sql = select(activity).where(
|
||||
and_(
|
||||
activity.c.user == aime_id,
|
||||
(activity.c.kind == kind) if kind is not None else True,
|
||||
)
|
||||
)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_kop(self, aime_id: int) -> Optional[List[Row]]:
|
||||
sql = select(kop).where(kop.c.user == aime_id)
|
||||
|
||||
result = self.execute(sql)
|
||||
if result is None: return None
|
||||
if result is None:
|
||||
return None
|
||||
return result.fetchall()
|
||||
|
||||
def get_rivals(self, aime_id: int) -> Optional[List[Row]]:
|
||||
@ -326,48 +376,62 @@ class OngekiProfileData(BaseData):
|
||||
result = self.execute(conflict)
|
||||
|
||||
if result is None:
|
||||
self.logger.warn(f"put_profile_options: Failed to update! aime_id: {aime_id}")
|
||||
self.logger.warn(
|
||||
f"put_profile_options: Failed to update! aime_id: {aime_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_profile_recent_rating(self, aime_id: int, recent_rating_data: List[Dict]) -> Optional[int]:
|
||||
def put_profile_recent_rating(
|
||||
self, aime_id: int, recent_rating_data: List[Dict]
|
||||
) -> Optional[int]:
|
||||
sql = insert(recent_rating).values(
|
||||
user=aime_id,
|
||||
recentRating=recent_rating_data
|
||||
user=aime_id, recentRating=recent_rating_data
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
recentRating=recent_rating_data
|
||||
)
|
||||
conflict = sql.on_duplicate_key_update(recentRating=recent_rating_data)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(f"put_profile_recent_rating: failed to update recent rating! aime_id {aime_id}")
|
||||
self.logger.warn(
|
||||
f"put_profile_recent_rating: failed to update recent rating! aime_id {aime_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_profile_bp_list(self, aime_id: int, bp_base_list: List[Dict]) -> Optional[int]:
|
||||
def put_profile_bp_list(
|
||||
self, aime_id: int, bp_base_list: List[Dict]
|
||||
) -> Optional[int]:
|
||||
pass
|
||||
|
||||
def put_profile_rating_log(self, aime_id: int, data_version: str, highest_rating: int) -> Optional[int]:
|
||||
|
||||
def put_profile_rating_log(
|
||||
self, aime_id: int, data_version: str, highest_rating: int
|
||||
) -> Optional[int]:
|
||||
sql = insert(rating_log).values(
|
||||
user=aime_id,
|
||||
dataVersion=data_version,
|
||||
highestRating=highest_rating
|
||||
user=aime_id, dataVersion=data_version, highestRating=highest_rating
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
highestRating=highest_rating
|
||||
)
|
||||
conflict = sql.on_duplicate_key_update(highestRating=highest_rating)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(f"put_profile_rating_log: failed to update rating log! aime_id {aime_id} data_version {data_version} highest_rating {highest_rating}")
|
||||
self.logger.warn(
|
||||
f"put_profile_rating_log: failed to update rating log! aime_id {aime_id} data_version {data_version} highest_rating {highest_rating}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_profile_activity(self, aime_id: int, kind: int, activity_id: int, sort_num: int,
|
||||
p1: int, p2: int, p3: int, p4: int) -> Optional[int]:
|
||||
def put_profile_activity(
|
||||
self,
|
||||
aime_id: int,
|
||||
kind: int,
|
||||
activity_id: int,
|
||||
sort_num: int,
|
||||
p1: int,
|
||||
p2: int,
|
||||
p3: int,
|
||||
p4: int,
|
||||
) -> Optional[int]:
|
||||
sql = insert(activity).values(
|
||||
user=aime_id,
|
||||
kind=kind,
|
||||
@ -376,29 +440,24 @@ class OngekiProfileData(BaseData):
|
||||
param1=p1,
|
||||
param2=p2,
|
||||
param3=p3,
|
||||
param4=p4
|
||||
param4=p4,
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
sortNumber=sort_num,
|
||||
param1=p1,
|
||||
param2=p2,
|
||||
param3=p3,
|
||||
param4=p4
|
||||
sortNumber=sort_num, param1=p1, param2=p2, param3=p3, param4=p4
|
||||
)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(f"put_profile_activity: failed to put activity! aime_id {aime_id} kind {kind} activity_id {activity_id}")
|
||||
self.logger.warn(
|
||||
f"put_profile_activity: failed to put activity! aime_id {aime_id} kind {kind} activity_id {activity_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def put_profile_region(self, aime_id: int, region: int, date: str) -> Optional[int]:
|
||||
sql = insert(activity).values(
|
||||
user=aime_id,
|
||||
region=region,
|
||||
playCount=1,
|
||||
created=date
|
||||
user=aime_id, region=region, playCount=1, created=date
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(
|
||||
@ -407,10 +466,12 @@ class OngekiProfileData(BaseData):
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(f"put_profile_region: failed to update! aime_id {aime_id} region {region}")
|
||||
self.logger.warn(
|
||||
f"put_profile_region: failed to update! aime_id {aime_id} region {region}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def put_training_room(self, aime_id: int, room_detail: Dict) -> Optional[int]:
|
||||
room_detail["user"] = aime_id
|
||||
|
||||
@ -422,7 +483,7 @@ class OngekiProfileData(BaseData):
|
||||
self.logger.warn(f"put_best_score: Failed to add score! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
|
||||
def put_kop(self, aime_id: int, kop_data: Dict) -> Optional[int]:
|
||||
kop_data["user"] = aime_id
|
||||
|
||||
@ -434,17 +495,16 @@ class OngekiProfileData(BaseData):
|
||||
self.logger.warn(f"put_kop: Failed to add score! aime_id: {aime_id}")
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
||||
def put_rival(self, aime_id: int, rival_id: int) -> Optional[int]:
|
||||
sql = insert(rival).values(
|
||||
user = aime_id,
|
||||
rivalUserId = rival_id
|
||||
)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(rival = rival_id)
|
||||
def put_rival(self, aime_id: int, rival_id: int) -> Optional[int]:
|
||||
sql = insert(rival).values(user=aime_id, rivalUserId=rival_id)
|
||||
|
||||
conflict = sql.on_duplicate_key_update(rival=rival_id)
|
||||
|
||||
result = self.execute(conflict)
|
||||
if result is None:
|
||||
self.logger.warn(f"put_rival: failed to update! aime_id: {aime_id}, rival_id: {rival_id}")
|
||||
self.logger.warn(
|
||||
f"put_rival: failed to update! aime_id: {aime_id}, rival_id: {rival_id}"
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
|
Reference in New Issue
Block a user