changed available functionality to add the beginning of the queue
authorGeorgios Atheridis <atheridis@tutamail.com>
Thu, 12 May 2022 05:12:37 +0000 (05:12 +0000)
committerGeorgios Atheridis <atheridis@tutamail.com>
Thu, 12 May 2022 05:12:37 +0000 (05:12 +0000)
skgyorugo/commands/available.py
skgyorugo/commands/cleanqueue.py
skgyorugo/commands/forceavailable.py

index bf96c502daebe007c0f1f188c25df8c5fc66d349..e1803714766c3a3f91e559cdd95f2a61830c7463 100644 (file)
@@ -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 = ?
index 9450b4573e0a872630ead6b83fc2db22eec197a1..340ee6b7b0a5d482fb673e5c94ac257a3d548a61 100644 (file)
@@ -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()
index 210a167661b13da3a61d66700401812197e3085d..74017c7b85b4138deaec599f7deb88c1f65acaf2 100644 (file)
@@ -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 = ?