fixed bug
authorGeorgios Atheridis <atheridis@tutamail.com>
Thu, 12 May 2022 08:16:37 +0000 (08:16 +0000)
committerGeorgios Atheridis <atheridis@tutamail.com>
Thu, 12 May 2022 08:16:37 +0000 (08:16 +0000)
skgyorugo/commands/available.py
skgyorugo/commands/forceavailable.py

index 30efb22d7a0c7492cebb3c62bd9fba192ffaebdd..5daf9712aafd1cb2cbaae3cd2b3d9569dfe1c13f 100644 (file)
@@ -143,14 +143,16 @@ def main(bot: Bot, message: Message):
                     ELSE 0
                 END
             ),
-            position = 1 + (
-                SELECT
-                    max(position)
-                FROM
-                    lol_queue
-                WHERE
-                    priority_queue = 1
-                    OR position <= (
+            position = (
+                CASE
+                    WHEN (
+                        SELECT
+                            position
+                        FROM
+                            lol_queue
+                        WHERE
+                            twitch_id = ?
+                    ) < (
                         SELECT
                             max(position)
                         FROM
@@ -168,6 +170,34 @@ def main(bot: Bot, message: Message):
                                 name = 'queuesize'
                         )
                     )
+                    THEN 1 + (
+                        SELECT
+                            max(position)
+                        FROM
+                            lol_queue
+                        WHERE
+                            priority_queue = 1
+                            OR position <= (
+                                SELECT
+                                    max(position)
+                                FROM
+                                    lol_queue
+                                WHERE
+                                    available = 1
+                                ORDER BY 
+                                    position
+                                LIMIT (
+                                    SELECT
+                                        data
+                                    FROM
+                                        lol_queue_data
+                                    WHERE
+                                        name = 'queuesize'
+                                )
+                            )
+                    )
+                    ELSE position
+                END
             ),
             time_remaining = time_remaining - (? - last_available)
         WHERE 
@@ -175,6 +205,7 @@ def main(bot: Bot, message: Message):
             AND available = 0;
         """,
         (
+            twitch_id,
             twitch_id,
             int(time.time()),
             twitch_id,
index 09d68d9b89eafa56f2ae279efddb6acef20a561d..4a0a06cb9ebf89a4398588f821879eb7ae09f7a2 100644 (file)
@@ -146,14 +146,16 @@ def main(bot: Bot, message: Message):
                     ELSE 0
                 END
             ),
-            position = 1 + (
-                SELECT
-                    max(position)
-                FROM
-                    lol_queue
-                WHERE
-                    priority_queue = 1
-                    OR position <= (
+            position = (
+                CASE
+                    WHEN (
+                        SELECT
+                            position
+                        FROM
+                            lol_queue
+                        WHERE
+                            twitch_id = ?
+                    ) < (
                         SELECT
                             max(position)
                         FROM
@@ -171,6 +173,34 @@ def main(bot: Bot, message: Message):
                                 name = 'queuesize'
                         )
                     )
+                    THEN 1 + (
+                        SELECT
+                            max(position)
+                        FROM
+                            lol_queue
+                        WHERE
+                            priority_queue = 1
+                            OR position <= (
+                                SELECT
+                                    max(position)
+                                FROM
+                                    lol_queue
+                                WHERE
+                                    available = 1
+                                ORDER BY 
+                                    position
+                                LIMIT (
+                                    SELECT
+                                        data
+                                    FROM
+                                        lol_queue_data
+                                    WHERE
+                                        name = 'queuesize'
+                                )
+                            )
+                    )
+                    ELSE position
+                END
             ),
             time_remaining = time_remaining - (? - last_available)
         WHERE 
@@ -178,6 +208,7 @@ def main(bot: Bot, message: Message):
             AND available = 0;
         """,
         (
+            twitch_id,
             twitch_id,
             int(time.time()),
             twitch_id,