diff --git a/db.py b/db.py index 043b318..88a93ba 100644 --- a/db.py +++ b/db.py @@ -47,6 +47,24 @@ def _initialize_database() -> None: """ ) + + # 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 ( + id INTEGER PRIMARY KEY, + student_name TEXT NOT NULL, + TA_name TEXT NOT NULL, + question TEXT, + enqueue_time TEXT NOT NULL, + dequeue_time TEXT NOT NULL, + is_passoff INTEGER CHECK (is_passof IN (0,1)), + in_person INTEGER CHECK (in_person IN (0,1)), + time_finished TEXT + ) + """ + ) + # Ensure queue_settings has a default row cursor = conn.cursor() cursor.execute("SELECT COUNT(*) FROM queue_settings") diff --git a/ui/modals.py b/ui/modals.py index bf92943..984b362 100644 --- a/ui/modals.py +++ b/ui/modals.py @@ -150,6 +150,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 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) await interaction.response.send_message("Queue cleared", delete_after=60*5) @@ -175,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) 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 e878e95..6d46c48 100644 --- a/ui/views/ta_view.py +++ b/ui/views/ta_view.py @@ -78,6 +78,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 (add a row with the dequeue time) + if not entry.is_passoff: increment_help(entry.user_id, entry.username, entry.student_name) @@ -103,6 +105,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 (add a row with the dequeue time) + if not entry.is_passoff: increment_help(entry.user_id, entry.username, entry.student_name) @@ -132,6 +136,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 (add a row with the dequeue time) + await move_to_breakout(interaction, entry) # Notify the next student in line only if they changed @@ -153,6 +159,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 (add a row with the dequeue time) + await move_to_breakout(interaction, entry) # Notify the next student in line only if they changed @@ -170,6 +178,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 (update row with done_getting_help_time or time_helped depending on implementation) + try: ta_voice_state: discord.VoiceState = await interaction.user.fetch_voice() voice_channel: discord.VoiceChannel = ta_voice_state.channel