From edb169ad3896e4ca5b4c8ef7e5799855d7109d94 Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Thu, 12 May 2022 05:12:37 +0000 Subject: [PATCH] changed available functionality to add the beginning of the queue --- skgyorugo/commands/available.py | 26 ++++++++++++++++++++++++++ skgyorugo/commands/cleanqueue.py | 6 ++++++ skgyorugo/commands/forceavailable.py | 26 ++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/skgyorugo/commands/available.py b/skgyorugo/commands/available.py index bf96c50..e180371 100644 --- a/skgyorugo/commands/available.py +++ b/skgyorugo/commands/available.py @@ -39,12 +39,38 @@ def main(bot: Bot, message: Message): conn = sqlite3.connect(os.path.join(PATH, "lol_data.db")) c = conn.cursor() + c.execute( + """ + UPDATE + lol_queue + SET + position = position + 1 + WHERE + position >= ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + """ + ) + c.execute( """ UPDATE lol_queue SET available = 1, + position = ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) time_remaining = time_remaining - (? - last_available) WHERE twitch_id = ? diff --git a/skgyorugo/commands/cleanqueue.py b/skgyorugo/commands/cleanqueue.py index 9450b45..340ee6b 100644 --- a/skgyorugo/commands/cleanqueue.py +++ b/skgyorugo/commands/cleanqueue.py @@ -63,4 +63,10 @@ def main(bot: Bot, message: Message): ) conn.commit() + bot.send_privmsg( + message.channel, + f"Successfully cleaned the queue.", + reply=message.tags["id"], + ) + conn.close() diff --git a/skgyorugo/commands/forceavailable.py b/skgyorugo/commands/forceavailable.py index 210a167..74017c7 100644 --- a/skgyorugo/commands/forceavailable.py +++ b/skgyorugo/commands/forceavailable.py @@ -42,12 +42,38 @@ def main(bot: Bot, message: Message): conn = sqlite3.connect(os.path.join(PATH, "lol_data.db")) c = conn.cursor() + c.execute( + """ + UPDATE + lol_queue + SET + position = position + 1 + WHERE + position >= ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) + """ + ) + c.execute( """ UPDATE lol_queue SET available = 1, + position = ( + SELECT + data + FROM + lol_queue_data + WHERE + name = 'queuesize' + ) time_remaining = time_remaining - (? - last_available) WHERE twitch_id = ? -- 2.30.2