promote debug logs to info & change playtime calc
All checks were successful
Build and Push Docker Image / build (push) Successful in 13s
All checks were successful
Build and Push Docker Image / build (push) Successful in 13s
This commit is contained in:
parent
41b50e352f
commit
2ed97dba5f
@ -96,6 +96,7 @@ class Player(Model):
|
||||
table = "players"
|
||||
|
||||
async def get_playtime(self) -> timedelta:
|
||||
log.info("Getting total playtime for player: %s", self.username)
|
||||
sessions = await PlayerSession.filter(player=self)
|
||||
total_playtime = timedelta()
|
||||
now = datetime.now()
|
||||
@ -104,8 +105,7 @@ class Player(Model):
|
||||
# I know this is terrible efficiency-wise, but the tortoise docs
|
||||
# are so bad and the annotations don't work like Django's models. Deal with it!
|
||||
for session in sessions:
|
||||
disconnected_at = session.disconnected_at or now
|
||||
total_playtime += disconnected_at.astimezone(utc) - session.connected_at.astimezone(utc)
|
||||
total_playtime += session.playtime
|
||||
|
||||
return total_playtime
|
||||
|
||||
@ -122,7 +122,7 @@ class Player(Model):
|
||||
) -> PlayerDeath:
|
||||
"""
|
||||
"""
|
||||
log.debug("Assigning death to player: %s", self.username)
|
||||
log.info("Assigning death to player: %s", self.username)
|
||||
self.is_dead = True
|
||||
await self.save()
|
||||
coordinates = await Coordinates.create(x=coord_x, y=coord_y, z=coord_z)
|
||||
@ -147,7 +147,7 @@ class Player(Model):
|
||||
coord_y: str | int,
|
||||
coord_z: str | int,
|
||||
) -> PlayerSession:
|
||||
log.debug("creating session for player: %s", self.username)
|
||||
log.info("creating session for player: %s", self.username)
|
||||
existing_session = await self.get_latest_session(ignore_closed_sessions=True)
|
||||
if existing_session:
|
||||
log.debug("deleting an unfinished session to open a new one")
|
||||
@ -167,7 +167,7 @@ class Player(Model):
|
||||
coord_y: str | int,
|
||||
coord_z: str | int,
|
||||
) -> PlayerSession:
|
||||
log.debug("closing session for player: %s", self.username)
|
||||
log.info("closing session for player: %s", self.username)
|
||||
current_session = await self.get_latest_session(ignore_closed_sessions=True)
|
||||
if not current_session:
|
||||
raise ValueError("Tried to close session that doesn't exist.")
|
||||
@ -185,7 +185,7 @@ class Player(Model):
|
||||
async def update_steam_summary(self, steam_id: str | int, steam_api_key: str) -> SteamProfileSummary:
|
||||
"""
|
||||
"""
|
||||
log.debug("Updating Steam summary for player: %s", self.username)
|
||||
log.info("Updating Steam summary for player: %s", self.username)
|
||||
|
||||
if not steam_api_key:
|
||||
raise ValueError("No Steam API key provided, can't get profile summary.")
|
||||
@ -220,6 +220,7 @@ class Player(Model):
|
||||
return summary
|
||||
|
||||
async def get_embed(self) -> Embed:
|
||||
log.info("Creating an embed for player: %s", self.username)
|
||||
summary = await self.get_steam_summary()
|
||||
if not summary:
|
||||
raise ValueError("You must fetch the steam_profile_summary before creating an embed.")
|
||||
|
Reference in New Issue
Block a user