Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,39 @@ 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 DATETIME NOT NULL,
dequeue_time DATETIME NOT NULL,
question TEXT,
is_passoff Bit,
in_person Bit,
done_getting_help_time INTEGER,
)
"""
)

# Ensure queue_settings has a default row
cursor = conn.cursor()
cursor.execute("SELECT COUNT(*) FROM queue_settings")
Expand Down
4 changes: 4 additions & 0 deletions ui/modals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions ui/views/queue_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions ui/views/ta_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down