From af26de66032c21df8ac91e48443081f276c1eaa6 Mon Sep 17 00:00:00 2001 From: Conatum Date: Tue, 5 Oct 2021 11:18:44 +0300 Subject: [PATCH 1/2] (accountability): Close rooms before turnover. No longer automatically move members from the previous room. Add extra member hardening to the turnover process. --- bot/modules/accountability/tracker.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/bot/modules/accountability/tracker.py b/bot/modules/accountability/tracker.py index dde5e72e..e1136b39 100644 --- a/bot/modules/accountability/tracker.py +++ b/bot/modules/accountability/tracker.py @@ -168,7 +168,7 @@ async def turnover(): to_update = [ (mem.data.duration + int((now - mem.data.last_joined_at).total_seconds()), None, mem.slotid, mem.userid) for slot in last_slots for mem in slot.members.values() - if mem.data.last_joined_at + if mem.data and mem.data.last_joined_at ] if to_update: accountability_members.update_many( @@ -178,6 +178,15 @@ async def turnover(): cast_row='(NULL::int, NULL::timestamptz, NULL::int, NULL::int)' ) + # Close all completed rooms, update data + await asyncio.gather(*(slot.close() for slot in last_slots), return_exceptions=True) + update_slots = [slot.data.slotid for slot in last_slots if slot.data] + if update_slots: + accountability_rooms.update_where( + {'closed_at': utc_now()}, + slotid=update_slots + ) + # Rotate guild sessions [aguild.advance() for aguild in AccountabilityGuild.cache.values()] @@ -185,7 +194,6 @@ async def turnover(): # We could break up the session starting? # Move members of the next session over to the session channel - # This includes any members of the session just complete current_slots = [ aguild.current_slot for aguild in AccountabilityGuild.cache.values() if aguild.current_slot is not None @@ -207,21 +215,12 @@ async def turnover(): return_exceptions=True ) - # Close all completed rooms, update data - await asyncio.gather(*(slot.close() for slot in last_slots)) - update_slots = [slot.data.slotid for slot in last_slots if slot.data] - if update_slots: - accountability_rooms.update_where( - {'closed_at': utc_now()}, - slotid=update_slots - ) - # Update session data of all members in new channels member_session_data = [ (0, slot.start_time, mem.slotid, mem.userid) for slot in current_slots for mem in slot.members.values() - if mem.member.voice and mem.member.voice.channel == slot.channel + if mem.data and mem.member and mem.member.voice and mem.member.voice.channel == slot.channel ] if member_session_data: accountability_members.update_many( From 4523b16d87448af26ee6e8330ade6aeb0f3f4599 Mon Sep 17 00:00:00 2001 From: Conatum Date: Tue, 5 Oct 2021 11:20:16 +0300 Subject: [PATCH 2/2] fix (guild admin): Fix typo in module import --- bot/modules/guild_admin/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/modules/guild_admin/__init__.py b/bot/modules/guild_admin/__init__.py index b44b04da..7aa49faf 100644 --- a/bot/modules/guild_admin/__init__.py +++ b/bot/modules/guild_admin/__init__.py @@ -2,4 +2,4 @@ from .module import module from . import guild_config from . import statreset -from . import utils +from . import new_members