From e91fcaf0cce4472eab15366a3cdd9595afcce4af Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 9 Jun 2026 12:22:10 -0600 Subject: [PATCH 1/8] add: queue_history sql command --- db.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/db.py b/db.py index 7e33317..c7d340c 100644 --- a/db.py +++ b/db.py @@ -47,6 +47,38 @@ def _initialize_database() -> None: """ ) + # original SQL table from old help queue + # """ + # CREATE TABLE IF NOT EXISTS queue_history ( + # id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + # NetId TEXT NOT NULL, + # removedBy TEXT NOT NULL, + # enqueueTime INTEGER NOT NULL, + # dequeueTime INTEGER NOT NULL, + # QUESTION TEXT, + # PASSOFF Bit, + # DoneGettingHelpTime INTEGER, + # ZOOMLINK TEXT, + # ) + # """ + + # dequeue_time refers to the TA offering help, as the student is no longer waiting in the queue + conn.execute( + """ + CREATE TABLE IF NOT EXISTS queue_history ( + id INTEGER NOT NULL PRIMARY KEY, + user_name TEXT NOT NULL, + student_name TEXT NOT NULL, + removed_by TEXT NOT NULL, + enqueue_time INTEGER NOT NULL, + dequeue_time INTEGER NOT NULL, + question TEXT, + is_passoff Bit, + done_getting_help_time INTEGER, + ) + """ + ) + # Ensure queue_settings has a default row cursor = conn.cursor() cursor.execute("SELECT COUNT(*) FROM queue_settings") From 153d16872f275e0d17e16d88aaf0b35332a0367f Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 9 Jun 2026 12:33:39 -0600 Subject: [PATCH 2/8] add: in-person bool column to queue_history --- db.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db.py b/db.py index bab277d..05b915e 100644 --- a/db.py +++ b/db.py @@ -66,7 +66,7 @@ def _initialize_database() -> None: conn.execute( """ CREATE TABLE IF NOT EXISTS queue_history ( - id INTEGER NOT NULL PRIMARY KEY, + id INTEGER NOT NULL PRIMARY KEY, user_name TEXT NOT NULL, student_name TEXT NOT NULL, removed_by TEXT NOT NULL, @@ -74,6 +74,7 @@ def _initialize_database() -> None: dequeue_time INTEGER NOT NULL, question TEXT, is_passoff Bit, + in_person Bit, done_getting_help_time INTEGER, ) """ From 5aebbe4da7fa974c9fee4b6e37b4baba5d0a41d0 Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 9 Jun 2026 13:52:19 -0600 Subject: [PATCH 3/8] add: todo statements for updating queue_history --- ui/modals.py | 5 +++++ ui/views/queue_view.py | 2 ++ ui/views/ta_view.py | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/ui/modals.py b/ui/modals.py index 4839409..3f019e7 100644 --- a/ui/modals.py +++ b/ui/modals.py @@ -151,6 +151,8 @@ async def on_submit(self, interaction: discord.Interaction): if self.confirmation.value.lower() != 'y': await interaction.response.send_message("Clear aborted", ephemeral=True, delete_after=10) else: + # TODO: update queue_history for each student + await interaction.client.queue.clear() await update_queue_messages(interaction.client) await interaction.response.send_message("Queue cleared", delete_after=60*5) @@ -167,6 +169,9 @@ class RemoveConfirmModal(discord.ui.Modal, title="Removal Confirmation"): async def on_submit(self, interaction: discord.Interaction): for entry in interaction.client.queue.entries: if entry.username == self.input.value: + + # TODO: update queue_history + user: discord.User = await interaction.client.fetch_user(entry.user_id) await interaction.client.queue.remove(user.id) await update_queue_messages(interaction.client) diff --git a/ui/views/queue_view.py b/ui/views/queue_view.py index f7507fe..ba4f17f 100644 --- a/ui/views/queue_view.py +++ b/ui/views/queue_view.py @@ -25,6 +25,8 @@ async def passoff_btn(self, interaction: discord.Interaction, button): @discord.ui.button(label="Leave Queue", style=discord.ButtonStyle.danger, custom_id="leave_queue", emoji="🚪") async def leave_btn(self, interaction: discord.Interaction, button): + # TODO: update queue_history if they are currently being helped by a TA + if await interaction.client.queue.is_in_queue(interaction.user.id): await interaction.client.queue.remove(interaction.user.id) await update_queue_messages(interaction.client) diff --git a/ui/views/ta_view.py b/ui/views/ta_view.py index cd1bcf3..bb512ac 100644 --- a/ui/views/ta_view.py +++ b/ui/views/ta_view.py @@ -17,6 +17,8 @@ async def next(self, interaction: discord.Interaction, button): if not entry: return await interaction.response.send_message("Queue is empty.", ephemeral=True, delete_after=SHORT_TIMEOUT) + # TODO: update queue_history + if not entry.is_passoff: increment_help(entry.user_id, entry.username, entry.student_name) @@ -42,6 +44,8 @@ async def next_online(self, interaction: discord.Interaction, button: discord.ui if not entry: return await interaction.response.send_message("No online students in the queue.", ephemeral=True, delete_after=SHORT_TIMEOUT) + # TODO: update queue_history + if not entry.is_passoff: increment_help(entry.user_id, entry.username, entry.student_name) @@ -71,6 +75,8 @@ async def next_passoff(self, interaction: discord.Interaction, button: discord.u if not entry: return await interaction.response.send_message("No students awaiting passoff.", ephemeral=True, delete_after=SHORT_TIMEOUT) + # TODO: update queue_history + await move_to_breakout(interaction, entry) # Notify the next student in line only if they changed @@ -92,6 +98,8 @@ async def next_online_passoff(self, interaction: discord.Interaction, button: di if not entry: return await interaction.response.send_message("No online students awaiting passoff.", ephemeral=True, delete_after=SHORT_TIMEOUT) + # TODO: update queue_history + await move_to_breakout(interaction, entry) # Notify the next student in line only if they changed @@ -109,6 +117,8 @@ class TAQueueControls3(discord.ui.ActionRow[discord.ui.LayoutView]): async def finish_button(self, interaction: discord.Interaction, button): online_ta_vc: discord.VoiceChannel = get_channel(interaction, TA_VOICE_CHANNEL_NAME) + # TODO: update queue_history + try: ta_voice_state: discord.VoiceState = await interaction.user.fetch_voice() voice_channel: discord.VoiceChannel = ta_voice_state.channel From 4507ce50a659e1daf2c21a93df5d547e6072a7ec Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 9 Jun 2026 14:00:28 -0600 Subject: [PATCH 4/8] add: clarified TODO for queue_history --- ui/modals.py | 4 ++-- ui/views/ta_view.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/modals.py b/ui/modals.py index 3f019e7..ce6f33f 100644 --- a/ui/modals.py +++ b/ui/modals.py @@ -151,7 +151,7 @@ async def on_submit(self, interaction: discord.Interaction): if self.confirmation.value.lower() != 'y': await interaction.response.send_message("Clear aborted", ephemeral=True, delete_after=10) else: - # TODO: update queue_history for each student + # TODO: update queue_history for each student (add/update a row with done_getting_help_time or time_helped depending on implementation) await interaction.client.queue.clear() await update_queue_messages(interaction.client) @@ -170,7 +170,7 @@ async def on_submit(self, interaction: discord.Interaction): for entry in interaction.client.queue.entries: if entry.username == self.input.value: - # TODO: update queue_history + # TODO: update queue_history (add/update a row with done_getting_help_time or time_helped depending on implementation) user: discord.User = await interaction.client.fetch_user(entry.user_id) await interaction.client.queue.remove(user.id) diff --git a/ui/views/ta_view.py b/ui/views/ta_view.py index bb512ac..d8ffcd9 100644 --- a/ui/views/ta_view.py +++ b/ui/views/ta_view.py @@ -17,7 +17,7 @@ async def next(self, interaction: discord.Interaction, button): if not entry: return await interaction.response.send_message("Queue is empty.", ephemeral=True, delete_after=SHORT_TIMEOUT) - # TODO: update queue_history + # TODO: update queue_history (add a row with the dequeue time) if not entry.is_passoff: increment_help(entry.user_id, entry.username, entry.student_name) @@ -44,7 +44,7 @@ async def next_online(self, interaction: discord.Interaction, button: discord.ui if not entry: return await interaction.response.send_message("No online students in the queue.", ephemeral=True, delete_after=SHORT_TIMEOUT) - # TODO: update queue_history + # TODO: update queue_history (add a row with the dequeue time) if not entry.is_passoff: increment_help(entry.user_id, entry.username, entry.student_name) @@ -75,7 +75,7 @@ async def next_passoff(self, interaction: discord.Interaction, button: discord.u if not entry: return await interaction.response.send_message("No students awaiting passoff.", ephemeral=True, delete_after=SHORT_TIMEOUT) - # TODO: update queue_history + # TODO: update queue_history (add a row with the dequeue time) await move_to_breakout(interaction, entry) @@ -98,7 +98,7 @@ async def next_online_passoff(self, interaction: discord.Interaction, button: di if not entry: return await interaction.response.send_message("No online students awaiting passoff.", ephemeral=True, delete_after=SHORT_TIMEOUT) - # TODO: update queue_history + # TODO: update queue_history (add a row with the dequeue time) await move_to_breakout(interaction, entry) @@ -117,7 +117,7 @@ class TAQueueControls3(discord.ui.ActionRow[discord.ui.LayoutView]): async def finish_button(self, interaction: discord.Interaction, button): online_ta_vc: discord.VoiceChannel = get_channel(interaction, TA_VOICE_CHANNEL_NAME) - # TODO: update queue_history + # TODO: update queue_history (update row with done_getting_help_time or time_helped depending on implementation) try: ta_voice_state: discord.VoiceState = await interaction.user.fetch_voice() From b5cfbbeb7cf0ca77755ebd27dc1e05c0f2d15259 Mon Sep 17 00:00:00 2001 From: bsharplydian Date: Wed, 10 Jun 2026 09:50:42 -0600 Subject: [PATCH 5/8] add: clarified TODO again --- ui/modals.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/modals.py b/ui/modals.py index 3f4e635..984b362 100644 --- a/ui/modals.py +++ b/ui/modals.py @@ -150,7 +150,7 @@ async def on_submit(self, interaction: discord.Interaction): if self.confirmation.value.lower() != 'y': await interaction.response.send_message("Clear aborted", ephemeral=True, delete_after=10) else: - # TODO: update queue_history for each student (add/update a row with done_getting_help_time or time_helped depending on implementation) + # TODO: update queue_history for each student if necessary (add/update a row with done_getting_help_time or time_helped depending on implementation) await interaction.client.queue.clear() await update_queue_messages(interaction.client) @@ -177,6 +177,8 @@ def __init__(self, student_user_id: int, student_name: str): )) async def on_submit(self, interaction: discord.Interaction): + # TODO: update queue_history if necessary (add/update a row with done_getting_help_time or time_helped depending on implementation) + front_before = await interaction.client.queue.get_front() user: discord.User = await interaction.client.fetch_user(self.student_user_id) await interaction.client.queue.remove(self.student_user_id) From e89f3fd2c21a0ff887ac54d5b5e458898d8f51b4 Mon Sep 17 00:00:00 2001 From: bsharplydian Date: Wed, 10 Jun 2026 10:45:38 -0600 Subject: [PATCH 6/8] refactor: change dates to DATETIMEs instead of numbers --- db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db.py b/db.py index 05b915e..70dcdb8 100644 --- a/db.py +++ b/db.py @@ -70,8 +70,8 @@ def _initialize_database() -> None: user_name TEXT NOT NULL, student_name TEXT NOT NULL, removed_by TEXT NOT NULL, - enqueue_time INTEGER NOT NULL, - dequeue_time INTEGER NOT NULL, + enqueue_time DATETIME NOT NULL, + dequeue_time DATETIME NOT NULL, question TEXT, is_passoff Bit, in_person Bit, From 7e9b837843accc6aba5e9b5bf1d3a58dc10e4faf Mon Sep 17 00:00:00 2001 From: Grant Harris Date: Wed, 10 Jun 2026 14:12:18 -0600 Subject: [PATCH 7/8] Optimize queue_history table --- db.py | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/db.py b/db.py index 05b915e..c34495b 100644 --- a/db.py +++ b/db.py @@ -47,35 +47,21 @@ def _initialize_database() -> None: """ ) - # original SQL table from old help queue - # """ - # CREATE TABLE IF NOT EXISTS queue_history ( - # id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - # NetId TEXT NOT NULL, - # removedBy TEXT NOT NULL, - # enqueueTime INTEGER NOT NULL, - # dequeueTime INTEGER NOT NULL, - # QUESTION TEXT, - # PASSOFF Bit, - # DoneGettingHelpTime INTEGER, - # ZOOMLINK TEXT, - # ) - # """ # dequeue_time refers to the TA offering help, as the student is no longer waiting in the queue conn.execute( """ CREATE TABLE IF NOT EXISTS queue_history ( - id INTEGER NOT NULL PRIMARY KEY, + id INTEGER PRIMARY KEY, user_name TEXT NOT NULL, student_name TEXT NOT NULL, removed_by TEXT NOT NULL, - enqueue_time INTEGER NOT NULL, - dequeue_time INTEGER NOT NULL, + enqueue_time TEXT NOT NULL, + dequeue_time TEXT NOT NULL, question TEXT, - is_passoff Bit, - in_person Bit, - done_getting_help_time INTEGER, + is_passoff INTEGER CHECK (is_passof IN (0,1)), + in_person INTEGER CHECK (in_person IN (0,1)), + done_getting_help_time TEXT ) """ ) From d72c63730f3233c69ff04b9b5fedfe23d7d3b341 Mon Sep 17 00:00:00 2001 From: Grant Harris Date: Wed, 10 Jun 2026 14:20:32 -0600 Subject: [PATCH 8/8] Clarify comment about dequeue_time --- db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db.py b/db.py index 3d2df0f..88a93ba 100644 --- a/db.py +++ b/db.py @@ -48,7 +48,7 @@ def _initialize_database() -> None: ) - # dequeue_time refers to the TA offering help, as the student is no longer waiting in the queue + # dequeue_time refers to the time the TA begins helping the student, as the student is no longer waiting in the queue conn.execute( """ CREATE TABLE IF NOT EXISTS queue_history (